gstpad: Fix flush-stop event handling
authorThiago Santos <thiago.sousa.santos@collabora.co.uk>
Mon, 13 Sep 2010 23:39:50 +0000 (20:39 -0300)
committerThiago Santos <thiago.sousa.santos@collabora.co.uk>
Mon, 13 Sep 2010 23:52:03 +0000 (20:52 -0300)
A flush-stop event would make a pad unflushing, causing it
to start acting as an activated pad. This, for example,
could lead to the chain function being called when stuff
isn't initialized.

This could happend when setting qtdemux to NULL while a seek
was being handled in the upstream filesrc (in push mode).

This patch makes it check if it is activated before setting
it to unflushing.

gst/gstpad.c

index c331684..9639f1d 100644 (file)
@@ -5074,8 +5074,10 @@ gst_pad_send_event (GstPad * pad, GstEvent * event)
       GST_CAT_DEBUG_OBJECT (GST_CAT_EVENT, pad, "set flush flag");
       break;
     case GST_EVENT_FLUSH_STOP:
-      GST_PAD_UNSET_FLUSHING (pad);
-      GST_CAT_DEBUG_OBJECT (GST_CAT_EVENT, pad, "cleared flush flag");
+      if (G_LIKELY (GST_PAD_ACTIVATE_MODE (pad) != GST_ACTIVATE_NONE)) {
+        GST_PAD_UNSET_FLUSHING (pad);
+        GST_CAT_DEBUG_OBJECT (GST_CAT_EVENT, pad, "cleared flush flag");
+      }
       GST_OBJECT_UNLOCK (pad);
       /* grab stream lock */
       GST_PAD_STREAM_LOCK (pad);