pad: Keep track of reconfigure events and the pad-needs-reconfiguring status

This commit is contained in:
Sebastian Dröge 2011-05-03 13:42:44 +02:00
parent 25916cff66
commit 5a7ec99214
2 changed files with 25 additions and 18 deletions

View file

@ -705,6 +705,12 @@ gst_pad_set_active (GstPad * pad, gboolean active)
GST_WARNING_OBJECT (pad, "Failed to activate pad"); GST_WARNING_OBJECT (pad, "Failed to activate pad");
} }
GST_OBJECT_UNLOCK (pad); GST_OBJECT_UNLOCK (pad);
} else {
if (!active) {
GST_OBJECT_LOCK (pad);
GST_OBJECT_FLAG_UNSET (pad, GST_PAD_NEED_RECONFIGURE);
GST_OBJECT_UNLOCK (pad);
}
} }
return ret; return ret;
@ -2063,7 +2069,7 @@ gst_pad_link_full (GstPad * srcpad, GstPad * sinkpad, GstPadLinkCheck flags)
GST_CAT_INFO (GST_CAT_PADS, "linked %s:%s and %s:%s, successful", GST_CAT_INFO (GST_CAT_PADS, "linked %s:%s and %s:%s, successful",
GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
gst_pad_send_event (srcpad, gst_event_new_renegotiate ()); gst_pad_send_event (srcpad, gst_event_new_reconfigure ());
} else { } else {
GST_CAT_INFO (GST_CAT_PADS, "link between %s:%s and %s:%s failed", GST_CAT_INFO (GST_CAT_PADS, "link between %s:%s and %s:%s failed",
GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
@ -4541,9 +4547,9 @@ gst_pad_push_event (GstPad * pad, GstEvent * event)
goto flushed; goto flushed;
} }
break; break;
case GST_EVENT_RENEGOTIATE: case GST_EVENT_RECONFIGURE:
if (GST_PAD_IS_SINK (pad) && GST_PAD_GETCAPSFUNC (pad) == NULL) if (GST_PAD_IS_SINK (pad))
goto drop_renegotiate; GST_OBJECT_FLAG_SET (pad, GST_PAD_NEED_RECONFIGURE);
default: default:
while (G_UNLIKELY (GST_PAD_IS_BLOCKED (pad))) { while (G_UNLIKELY (GST_PAD_IS_BLOCKED (pad))) {
/* block the event as long as the pad is blocked */ /* block the event as long as the pad is blocked */
@ -4700,6 +4706,9 @@ gst_pad_send_event (GstPad * pad, GstEvent * event)
need_unlock = TRUE; need_unlock = TRUE;
GST_OBJECT_LOCK (pad); GST_OBJECT_LOCK (pad);
break; break;
case GST_EVENT_RECONFIGURE:
if (GST_PAD_IS_SRC (pad))
GST_OBJECT_FLAG_SET (pad, GST_PAD_NEED_RECONFIGURE);
default: default:
GST_CAT_DEBUG_OBJECT (GST_CAT_EVENT, pad, "have event type %s", GST_CAT_DEBUG_OBJECT (GST_CAT_EVENT, pad, "have event type %s",
GST_EVENT_TYPE_NAME (event)); GST_EVENT_TYPE_NAME (event));
@ -4925,14 +4934,6 @@ concurrent_stop:
GST_OBJECT_UNLOCK (pad); GST_OBJECT_UNLOCK (pad);
return TRUE; return TRUE;
} }
drop_renegotiate:
{
GST_CAT_DEBUG_OBJECT (GST_CAT_EVENT, pad,
"No getcaps function on sink pad, dropping renegotiate event");
gst_event_unref (event);
GST_OBJECT_UNLOCK (pad);
return FALSE;
}
} }
/** /**

View file

@ -510,18 +510,23 @@ typedef enum {
* @GST_PAD_IN_GETCAPS: GstPadGetCapsFunction() is running now * @GST_PAD_IN_GETCAPS: GstPadGetCapsFunction() is running now
* @GST_PAD_IN_SETCAPS: GstPadSetCapsFunction() is running now * @GST_PAD_IN_SETCAPS: GstPadSetCapsFunction() is running now
* @GST_PAD_BLOCKING: is pad currently blocking on a buffer or event * @GST_PAD_BLOCKING: is pad currently blocking on a buffer or event
* @GST_PAD_NEED_RECONFIGURE: the pad should be reconfigured/renegotiated.
* The flag has to be unset manually after
* reconfiguration happened.
* Since: 0.10.34.
* @GST_PAD_FLAG_LAST: offset to define more flags * @GST_PAD_FLAG_LAST: offset to define more flags
* *
* Pad state flags * Pad state flags
*/ */
typedef enum { typedef enum {
GST_PAD_BLOCKED = (GST_OBJECT_FLAG_LAST << 0), GST_PAD_BLOCKED = (GST_OBJECT_FLAG_LAST << 0),
GST_PAD_FLUSHING = (GST_OBJECT_FLAG_LAST << 1), GST_PAD_FLUSHING = (GST_OBJECT_FLAG_LAST << 1),
GST_PAD_IN_GETCAPS = (GST_OBJECT_FLAG_LAST << 2), GST_PAD_IN_GETCAPS = (GST_OBJECT_FLAG_LAST << 2),
GST_PAD_IN_SETCAPS = (GST_OBJECT_FLAG_LAST << 3), GST_PAD_IN_SETCAPS = (GST_OBJECT_FLAG_LAST << 3),
GST_PAD_BLOCKING = (GST_OBJECT_FLAG_LAST << 4), GST_PAD_BLOCKING = (GST_OBJECT_FLAG_LAST << 4),
GST_PAD_NEED_RECONFIGURE = (GST_OBJECT_FLAG_LAST << 5),
/* padding */ /* padding */
GST_PAD_FLAG_LAST = (GST_OBJECT_FLAG_LAST << 16) GST_PAD_FLAG_LAST = (GST_OBJECT_FLAG_LAST << 16)
} GstPadFlags; } GstPadFlags;
/* FIXME: this awful circular dependency need to be resolved properly (see padtemplate.h) */ /* FIXME: this awful circular dependency need to be resolved properly (see padtemplate.h) */
@ -699,6 +704,7 @@ struct _GstPadClass {
#define GST_PAD_IS_FLUSHING(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLUSHING)) #define GST_PAD_IS_FLUSHING(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLUSHING))
#define GST_PAD_IS_IN_GETCAPS(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_IN_GETCAPS)) #define GST_PAD_IS_IN_GETCAPS(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_IN_GETCAPS))
#define GST_PAD_IS_IN_SETCAPS(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_IN_SETCAPS)) #define GST_PAD_IS_IN_SETCAPS(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_IN_SETCAPS))
#define GST_PAD_NEEDS_RECONFIGURE(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_NEED_RECONFIGURE))
#define GST_PAD_IS_SRC(pad) (GST_PAD_DIRECTION(pad) == GST_PAD_SRC) #define GST_PAD_IS_SRC(pad) (GST_PAD_DIRECTION(pad) == GST_PAD_SRC)
#define GST_PAD_IS_SINK(pad) (GST_PAD_DIRECTION(pad) == GST_PAD_SINK) #define GST_PAD_IS_SINK(pad) (GST_PAD_DIRECTION(pad) == GST_PAD_SINK)