pad: Make sure pending, older sticky events are sent downstream in dynamic linking scenarios

If a pad block was triggered from sending a sticky event downstream, it
could happen that the pad block is relinking pads, which then requires
to resend previous sticky events.
This commit is contained in:
Sebastian Dröge 2013-05-09 17:21:13 +02:00
parent 114f9584d4
commit 1b87f0c36a

View file

@ -4565,6 +4565,19 @@ gst_pad_store_sticky_event (GstPad * pad, GstEvent * event)
return ret; return ret;
} }
static gboolean
sticky_changed (GstPad * pad, PadEvent * ev, gpointer user_data)
{
PushStickyData *data = user_data;
/* Forward all sticky events before our current one that are pending */
if (ev->event != data->event
&& GST_EVENT_TYPE (ev->event) < GST_EVENT_TYPE (data->event))
return push_sticky (pad, ev, data);
return TRUE;
}
/* should be called with pad LOCK */ /* should be called with pad LOCK */
static GstFlowReturn static GstFlowReturn
gst_pad_push_event_unchecked (GstPad * pad, GstEvent * event, gst_pad_push_event_unchecked (GstPad * pad, GstEvent * event,
@ -4628,6 +4641,18 @@ gst_pad_push_event_unchecked (GstPad * pad, GstEvent * event,
/* send probes after modifying the events above */ /* send probes after modifying the events above */
PROBE_PUSH (pad, type | GST_PAD_PROBE_TYPE_PUSH, event, probe_stopped); PROBE_PUSH (pad, type | GST_PAD_PROBE_TYPE_PUSH, event, probe_stopped);
/* recheck sticky events because the probe might have cause a relink */
if (GST_PAD_HAS_PENDING_EVENTS (pad) && GST_PAD_IS_SRC (pad)
&& (GST_EVENT_IS_SERIALIZED (event)
|| GST_EVENT_IS_STICKY (event))) {
PushStickyData data = { GST_FLOW_OK, FALSE, event };
GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_PENDING_EVENTS);
/* Push all sticky events before our current one
* that have changed */
events_foreach (pad, sticky_changed, &data);
}
/* now check the peer pad */ /* now check the peer pad */
peerpad = GST_PAD_PEER (pad); peerpad = GST_PAD_PEER (pad);
if (peerpad == NULL) if (peerpad == NULL)