From 0ae3492f6b915941f3355b23a7d3cfd0c5e74079 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 5 Oct 2012 07:14:17 +0200 Subject: [PATCH] pad: don't store sticky events on flushing/EOS pads Don't store sticky events on flushing or EOS pads. This was done correctly for source pads but not for sink pads. --- gst/gstpad.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/gst/gstpad.c b/gst/gstpad.c index 5dcc1ce..82d43d1 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -4360,8 +4360,9 @@ probe_stopped_unref: } } +/* must be called with pad object lock */ static gboolean -gst_pad_store_sticky_event (GstPad * pad, GstEvent * event, gboolean locked) +gst_pad_store_sticky_event (GstPad * pad, GstEvent * event) { guint i, len; GstEventType type; @@ -4409,14 +4410,12 @@ gst_pad_store_sticky_event (GstPad * pad, GstEvent * event, gboolean locked) switch (GST_EVENT_TYPE (event)) { case GST_EVENT_CAPS: - if (locked) - GST_OBJECT_UNLOCK (pad); + GST_OBJECT_UNLOCK (pad); GST_DEBUG_OBJECT (pad, "notify caps"); g_object_notify_by_pspec ((GObject *) pad, pspec_caps); - if (locked) - GST_OBJECT_LOCK (pad); + GST_OBJECT_LOCK (pad); break; default: break; @@ -4609,10 +4608,10 @@ gst_pad_push_event (GstPad * pad, GstEvent * event) if (G_UNLIKELY (GST_PAD_IS_EOS (pad))) goto eos; - /* srcpad sticky events are store immediately, the received flag is set + /* srcpad sticky events are stored immediately, the received flag is set * to FALSE and will be set to TRUE when we can successfully push the * event to the peer pad */ - if (gst_pad_store_sticky_event (pad, event, TRUE)) { + if (gst_pad_store_sticky_event (pad, event)) { GST_DEBUG_OBJECT (pad, "event %s updated", GST_EVENT_TYPE_NAME (event)); } if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) @@ -4822,11 +4821,23 @@ gst_pad_send_event_unchecked (GstPad * pad, GstEvent * event, if (sticky) { if (ret == GST_FLOW_OK) { + GST_OBJECT_LOCK (pad); + /* can't store on flushing pads */ + if (G_UNLIKELY (GST_PAD_IS_FLUSHING (pad))) + goto flushing; + + if (G_UNLIKELY (GST_PAD_IS_EOS (pad))) + goto eos; + /* after the event function accepted the event, we can store the sticky * event on the pad */ - gst_pad_store_sticky_event (pad, event, FALSE); + if (gst_pad_store_sticky_event (pad, event)) { + GST_DEBUG_OBJECT (pad, "event %s updated", GST_EVENT_TYPE_NAME (event)); + } if (event_type == GST_EVENT_EOS) GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_EOS); + + GST_OBJECT_UNLOCK (pad); } gst_event_unref (event); } -- 2.7.4