basesink: Don't accept segments after EOS
authorEdward Hervey <edward.hervey@collabora.co.uk>
Mon, 6 Jun 2011 09:20:29 +0000 (11:20 +0200)
committerEdward Hervey <edward.hervey@collabora.co.uk>
Mon, 6 Jun 2011 09:20:29 +0000 (11:20 +0200)
And refactor the code slightly to avoid code duplication.

This solves a regression introduced by bdbc0693

libs/gst/base/gstbasesink.c

index 0cdbfc5..9c85cd5 100644 (file)
@@ -3316,22 +3316,20 @@ gst_base_sink_event (GstPad * pad, GstEvent * event)
       if (G_UNLIKELY (basesink->flushing))
         goto flushing;
 
-      if (G_UNLIKELY (basesink->priv->received_eos)) {
-        /* we can't accept anything when we are EOS */
+      if (G_UNLIKELY (basesink->priv->received_eos))
+        goto after_eos;
+
+      /* we set the received EOS flag here so that we can use it when testing if
+       * we are prerolled and to refuse more buffers. */
+      basesink->priv->received_eos = TRUE;
+
+      /* EOS is a prerollable object, we call the unlocked version because it
+       * does not check the received_eos flag. */
+      ret = gst_base_sink_queue_object_unlocked (basesink, pad,
+          _PR_IS_EVENT, GST_MINI_OBJECT_CAST (event), TRUE);
+      if (G_UNLIKELY (ret != GST_FLOW_OK))
         result = FALSE;
-        gst_event_unref (event);
-      } else {
-        /* we set the received EOS flag here so that we can use it when testing if
-         * we are prerolled and to refuse more buffers. */
-        basesink->priv->received_eos = TRUE;
-
-        /* EOS is a prerollable object, we call the unlocked version because it
-         * does not check the received_eos flag. */
-        ret = gst_base_sink_queue_object_unlocked (basesink, pad,
-            _PR_IS_EVENT, GST_MINI_OBJECT_CAST (event), TRUE);
-        if (G_UNLIKELY (ret != GST_FLOW_OK))
-          result = FALSE;
-      }
+
       GST_BASE_SINK_PREROLL_UNLOCK (basesink);
       break;
     }
@@ -3358,6 +3356,9 @@ gst_base_sink_event (GstPad * pad, GstEvent * event)
       if (G_UNLIKELY (basesink->flushing))
         goto flushing;
 
+      if (G_UNLIKELY (basesink->priv->received_eos))
+        goto after_eos;
+
       /* the new segment is a non prerollable item and does not block anything,
        * we need to configure the current clipping segment and insert the event
        * in the queue to serialize it with the buffers for rendering. */
@@ -3424,6 +3425,15 @@ flushing:
     gst_event_unref (event);
     goto done;
   }
+
+after_eos:
+  {
+    GST_DEBUG_OBJECT (basesink, "Event received after EOS, dropping");
+    GST_BASE_SINK_PREROLL_UNLOCK (basesink);
+    result = FALSE;
+    gst_event_unref (event);
+    goto done;
+  }
 }
 
 /* default implementation to calculate the start and end