From 060b16ac75ac227d4cfe1db89ccdc4f4b31545ff Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 21 Aug 2014 15:49:17 +0200 Subject: pad: don't accept flush-stop on inactive pads Inactive pads should at all times have the flushing flag set. This means that when we get a flush-stop on an inactive pad we must ignore it. On sinkpads, make this more explicit. We used to not clear the flush flag but remove the events and then return an error because the flushing flag was set. Now just simply refuse the event without doing anything. On srcpads, check that we are trying to push a flush-stop event and refuse it. We would allow this and mark the srcpad as non-flushing anymore. Fixes https://bugzilla.gnome.org/show_bug.cgi?id=735357 --- gst/gstpad.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/gst/gstpad.c b/gst/gstpad.c index bae09814e4..adb44ffca0 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -4774,6 +4774,9 @@ gst_pad_push_event_unchecked (GstPad * pad, GstEvent * event, type |= GST_PAD_PROBE_TYPE_EVENT_FLUSH; break; case GST_EVENT_FLUSH_STOP: + if (G_UNLIKELY (!GST_PAD_IS_ACTIVE (pad))) + goto inactive; + GST_PAD_UNSET_FLUSHING (pad); /* Remove sticky EOS events */ @@ -4862,6 +4865,12 @@ flushed: gst_event_unref (event); return GST_FLOW_FLUSHING; } +inactive: + { + GST_DEBUG_OBJECT (pad, "flush-stop on inactive pad"); + gst_event_unref (event); + return GST_FLOW_FLUSHING; + } probe_stopped: { GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_PENDING_EVENTS); @@ -5064,17 +5073,22 @@ gst_pad_send_event_unchecked (GstPad * pad, GstEvent * event, "have event type %d (FLUSH_START)", GST_EVENT_TYPE (event)); /* can't even accept a flush begin event when flushing */ - if (GST_PAD_IS_FLUSHING (pad)) + if (G_UNLIKELY (GST_PAD_IS_FLUSHING (pad))) goto flushing; GST_PAD_SET_FLUSHING (pad); GST_CAT_DEBUG_OBJECT (GST_CAT_EVENT, pad, "set flush flag"); break; case GST_EVENT_FLUSH_STOP: - if (G_LIKELY (GST_PAD_MODE (pad) != GST_PAD_MODE_NONE)) { - GST_PAD_UNSET_FLUSHING (pad); - GST_CAT_DEBUG_OBJECT (GST_CAT_EVENT, pad, "cleared flush flag"); - } + /* we can't accept flush-stop on inactive pads else the flushing flag + * would be cleared and it would look like the pad can accept data. + * Also, some elements restart a streaming thread in flush-stop which we + * can't allow on inactive pads */ + if (G_UNLIKELY (!GST_PAD_IS_ACTIVE (pad))) + goto inactive; + + GST_PAD_UNSET_FLUSHING (pad); + GST_CAT_DEBUG_OBJECT (GST_CAT_EVENT, pad, "cleared flush flag"); /* Remove pending EOS events */ GST_LOG_OBJECT (pad, "Removing pending EOS and SEGMENT events"); remove_event_by_type (pad, GST_EVENT_EOS); @@ -5189,6 +5203,16 @@ flushing: gst_event_unref (event); return GST_FLOW_FLUSHING; } +inactive: + { + GST_OBJECT_UNLOCK (pad); + if (need_unlock) + GST_PAD_STREAM_UNLOCK (pad); + GST_CAT_INFO_OBJECT (GST_CAT_EVENT, pad, + "Received flush-stop on inactive pad. Discarding"); + gst_event_unref (event); + return GST_FLOW_FLUSHING; + } eos: { GST_OBJECT_UNLOCK (pad); -- cgit v1.2.3