urisourcebin: Set pad probe before linking pad
authorEdward Hervey <edward@centricular.com>
Thu, 3 Oct 2024 15:16:25 +0000 (17:16 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 18 Oct 2024 10:13:13 +0000 (10:13 +0000)
We want to grab all events that pass through, so we need to set the
probe **before** the pad is linked

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

subprojects/gst-plugins-base/gst/playback/gsturisourcebin.c

index bc54a04feb752774d6e69e3c834ba8ff18ad1b42..86994ecb60528c0207b3bdbb200f40d46d7ebb36 100644 (file)
@@ -884,11 +884,6 @@ new_demuxer_pad_added_cb (GstElement * element, GstPad * pad,
   slot = new_output_slot (info, pad);
   output_pad = gst_object_ref (slot->output_pad);
 
-  slot->demuxer_event_probe_id =
-      gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM |
-      GST_PAD_PROBE_TYPE_EVENT_FLUSH, (GstPadProbeCallback) demux_pad_events,
-      slot, NULL);
-
   GST_URI_SOURCE_BIN_UNLOCK (urisrc);
   expose_output_pad (urisrc, output_pad);
   gst_object_unref (output_pad);
@@ -1275,11 +1270,18 @@ new_output_slot (ChildSrcPadInfo * info, GstPad * originating_pad)
     gst_pad_sticky_events_foreach (originating_pad, copy_sticky_events,
         &copy_data);
 
+    if (info->demuxer) {
+      /* Make sure we add the event probe *before* linking */
+      slot->demuxer_event_probe_id =
+          gst_pad_add_probe (originating_pad,
+          GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM | GST_PAD_PROBE_TYPE_EVENT_FLUSH,
+          (GstPadProbeCallback) demux_pad_events, slot, NULL);
     }
 
     slot->output_pad = create_output_pad (slot, srcpad);
     gst_object_unref (srcpad);
     gst_pad_link (originating_pad, slot->queue_sinkpad);
+    GST_PAD_STREAM_UNLOCK (originating_pad);
   }
   /* If buffering is required, create the element. If downloadbuffer is
    * required, it will take precedence over queue2 */