inputselector: Ensure that events are pushed first on active pad
authorThibault Saunier <tsaunier@igalia.com>
Thu, 14 May 2020 21:13:05 +0000 (17:13 -0400)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 15 May 2020 13:51:43 +0000 (13:51 +0000)
Making it less random and fixing a race in a GES test where we have
as pipeline:

```
videotestsrc ! output-selector name=s ! input-selector name=i s. ! timecodestamper ! i.
```

which we seek, leading to the seek reaching the video testsrc
without going through the timecodestamper and generating a buffer
even before timecodestamper gets the seek which means that its internal
state is wrong compared to the datastream it gets and attaches wrong
timecode metas.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/485>

plugins/elements/gstinputselector.c

index 099ae35..523cd6e 100644 (file)
@@ -1543,6 +1543,20 @@ gst_input_selector_event (GstPad * pad, GstObject * parent, GstEvent * event)
   /* Send upstream events to all sinkpads */
   iter = gst_element_iterate_sink_pads (GST_ELEMENT_CAST (sel));
 
+  GST_INPUT_SELECTOR_LOCK (sel);
+  eventpad = gst_input_selector_get_active_sinkpad (sel);
+  if (eventpad) {
+    gst_object_ref (eventpad);
+    GST_INPUT_SELECTOR_UNLOCK (sel);
+
+    gst_event_ref (event);
+    result |= gst_pad_push_event (eventpad, event);
+    pushed_pads = g_list_append (pushed_pads, eventpad);
+    gst_object_unref (eventpad);
+  } else {
+    GST_INPUT_SELECTOR_UNLOCK (sel);
+  }
+
   /* This is now essentially a copy of gst_pad_event_default_dispatch
    * with a different iterator */
   while (!done) {