inputselector: Only try to push the first EOS received
authorThiago Santos <thiagoss@osg.samsung.com>
Fri, 24 Apr 2015 19:51:24 +0000 (16:51 -0300)
committerThiago Santos <thiagoss@osg.samsung.com>
Fri, 24 Apr 2015 20:19:49 +0000 (17:19 -0300)
Subsequent EOS will push on the source pad that already received
EOS and that will make the event function return FALSE. It needs
only to push the first one and only return TRUE for the subsequent
ones.

plugins/elements/gstinputselector.c
plugins/elements/gstinputselector.h

index d19b650..7fad86a 100644 (file)
@@ -521,7 +521,16 @@ gst_selector_pad_event (GstPad * pad, GstObject * parent, GstEvent * event)
         GST_INPUT_SELECTOR_BROADCAST (sel);
       }
 
+      if (sel->eos_sent) {
+        gst_event_unref (event);
+        event = NULL;
+      } else {
+        /* prevent any further EOS event being pushed */
+        sel->eos_sent = TRUE;
+      }
+
       selpad->eos_sent = TRUE;
+
       GST_DEBUG_OBJECT (pad, "received EOS");
       break;
     case GST_EVENT_GAP:{
@@ -550,19 +559,21 @@ gst_selector_pad_event (GstPad * pad, GstObject * parent, GstEvent * event)
   GST_INPUT_SELECTOR_UNLOCK (sel);
   if (new_tags)
     g_object_notify (G_OBJECT (selpad), "tags");
-  if (forward) {
-    GST_DEBUG_OBJECT (pad, "forwarding event");
-    res = gst_pad_push_event (sel->srcpad, event);
-  } else {
-    /* If we aren't forwarding the event because the pad is not the
-     * active_sinkpad, then set the flag on the pad
-     * that says a segment needs sending if/when that pad is activated.
-     * For all other cases, we send the event immediately, which makes
-     * sparse streams and other segment updates work correctly downstream.
-     */
-    if (GST_EVENT_IS_STICKY (event))
-      selpad->events_pending = TRUE;
-    gst_event_unref (event);
+  if (event) {
+    if (forward) {
+      GST_DEBUG_OBJECT (pad, "forwarding event");
+      res = gst_pad_push_event (sel->srcpad, event);
+    } else {
+      /* If we aren't forwarding the event because the pad is not the
+       * active_sinkpad, then set the flag on the pad
+       * that says a segment needs sending if/when that pad is activated.
+       * For all other cases, we send the event immediately, which makes
+       * sparse streams and other segment updates work correctly downstream.
+       */
+      if (GST_EVENT_IS_STICKY (event))
+        selpad->events_pending = TRUE;
+      gst_event_unref (event);
+    }
   }
 
   return res;
@@ -1635,6 +1646,8 @@ gst_input_selector_reset (GstInputSelector * sel)
     gst_object_unref (sel->active_sinkpad);
     sel->active_sinkpad = NULL;
   }
+  sel->eos_sent = FALSE;
+
   /* reset each of our sinkpads state */
   for (walk = GST_ELEMENT_CAST (sel)->sinkpads; walk; walk = g_list_next (walk)) {
     GstSelectorPad *selpad = GST_SELECTOR_PAD_CAST (walk->data);
index 13cdddb..3dff175 100644 (file)
@@ -77,6 +77,7 @@ struct _GstInputSelector {
   GMutex lock;
   GCond cond;
   gboolean eos;
+  gboolean eos_sent;
   gboolean flushing;
 };