diff --git a/subprojects/gst-plugins-base/gst/playback/gsturisourcebin.c b/subprojects/gst-plugins-base/gst/playback/gsturisourcebin.c index 117f2a6f6a..2bff98af60 100644 --- a/subprojects/gst-plugins-base/gst/playback/gsturisourcebin.c +++ b/subprojects/gst-plugins-base/gst/playback/gsturisourcebin.c @@ -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);