From 0be233a4469045a9be76ba51ee91ed6d96e1354a Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Thu, 23 Mar 2023 07:39:48 +0100 Subject: [PATCH] uridecodebin3: Remove play items that were never connected This is a follow-up of the previous commit that enabled support for redirection. The problem is that the urisourcebin that emitted the error redirection never produced any pads, and therefore was never linked to decodebin3. This resulted in the code waiting for that (output) item to finally switch over ... which will never happen. The fix is done by removing it early if it was never connected to decodebin3. Part-of: --- .../gst-plugins-base/gst/playback/gsturidecodebin3.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/subprojects/gst-plugins-base/gst/playback/gsturidecodebin3.c b/subprojects/gst-plugins-base/gst/playback/gsturidecodebin3.c index d3a661d684..0eb9c30e38 100644 --- a/subprojects/gst-plugins-base/gst/playback/gsturidecodebin3.c +++ b/subprojects/gst-plugins-base/gst/playback/gsturidecodebin3.c @@ -1059,6 +1059,7 @@ switch_and_activate_input_locked (GstURIDecodeBin3 * uridecodebin, GList *old_pads = get_all_play_item_source_pads (uridecodebin->input_item); GList *to_activate = NULL; GList *iternew, *iterold; + gboolean inactive_previous_item = old_pads == NULL; /* Deactivate old urisourcebins first ? Problem is they might remove the pads */ @@ -1126,6 +1127,17 @@ switch_and_activate_input_locked (GstURIDecodeBin3 * uridecodebin, uridecodebin->input_item->sub_item = NULL; } + /* If the previous play item was not active at all (i.e. was never linked to + * decodebin3), this one *also* becomes the output one */ + if (inactive_previous_item) { + GST_DEBUG_OBJECT (uridecodebin, + "Previous play item was never activated, discarding"); + uridecodebin->play_items = + g_list_remove (uridecodebin->play_items, uridecodebin->input_item); + free_play_item (uridecodebin, uridecodebin->input_item); + uridecodebin->output_item = new_item; + } + /* and set new one as input item */ uridecodebin->input_item = new_item;