urisourcebin: When streams-aware, remove pads immediately
authorEdward Hervey <edward@centricular.com>
Wed, 9 Jun 2021 09:25:36 +0000 (11:25 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 30 Mar 2022 14:30:54 +0000 (14:30 +0000)
For the same reason we add them immediately

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

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

index 117f2a6..2bff98a 100644 (file)
@@ -103,6 +103,7 @@ struct _ChildSrcPadInfo
    * the pad owns the ChildSrcPadInfo as qdata */
   GstPad *src_pad;
   GstCaps *cur_caps;            /* holds ref */
+  GstPad *ghost_pad;            /* ghostpad if any */
 
   /* Configured output slot, if any */
   OutputSlotInfo *output_slot;
@@ -673,11 +674,11 @@ new_demuxer_pad_added_cb (GstElement * element, GstPad * pad,
   /* If the demuxer handles buffering and is streams-aware, we can expose it
      as-is directly. We still add an event probe to deal with EOS */
   if (urisrc->demuxer_handles_buffering && urisrc->source_streams_aware) {
-    GstPad *ghostpad = create_output_pad (urisrc, pad);
+    info->ghost_pad = create_output_pad (urisrc, pad);
     GST_DEBUG_OBJECT (element,
         "New streams-aware demuxer pad %s:%s , exposing directly",
         GST_DEBUG_PAD_NAME (pad));
-    expose_output_pad (urisrc, ghostpad);
+    expose_output_pad (urisrc, info->ghost_pad);
     GST_URI_SOURCE_BIN_UNLOCK (urisrc);
   } else {
     GST_DEBUG_OBJECT (element, "new demuxer pad, name: <%s>. "
@@ -1414,6 +1415,11 @@ pad_removed_cb (GstElement * element, GstPad * pad, GstURISourceBin * urisrc)
     remove_output_pad (urisrc, info->output_pad);
   } else {
     GST_LOG_OBJECT (urisrc, "Removed pad has no output slot or pad");
+    if (urisrc->source_streams_aware) {
+      GST_DEBUG_OBJECT (info->ghost_pad,
+          "Streams-aware, removing pad immediately");
+      gst_element_remove_pad ((GstElement *) urisrc, info->ghost_pad);
+    }
   }
   GST_URI_SOURCE_BIN_UNLOCK (urisrc);