From ed5db9bce79660358749edb3b08cd820ad437fe4 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Thu, 14 Apr 2022 15:21:48 +0200 Subject: [PATCH] decodebin3: Don't duplicate stream selections Make sure that the requested stream selection isn't identical to the current one. If that's the case, just carry on as usual. This avoids multiple `streams-selected` posting ... when the selection didn't change. Part-of: --- .../gst/playback/gstdecodebin3.c | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c b/subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c index 6209d653b5..514cd1a77d 100644 --- a/subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c +++ b/subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c @@ -1177,6 +1177,23 @@ stream_in_list (GList * list, const gchar * sid) return NULL; } +static gboolean +stream_list_equal (GList * lista, GList * listb) +{ + GList *tmp; + + if (g_list_length (lista) != g_list_length (listb)) + return FALSE; + + for (tmp = lista; tmp; tmp = tmp->next) { + gchar *osid = tmp->data; + if (!stream_in_list (listb, osid)) + return FALSE; + } + + return TRUE; +} + static void update_requested_selection (GstDecodebin3 * dbin) { @@ -1253,8 +1270,15 @@ update_requested_selection (GstDecodebin3 * dbin) } beach: - /* Finally set the requested selection */ + if (stream_list_equal (tmp, dbin->requested_selection)) { + /* If the selection is equal, there is nothign to do */ + GST_DEBUG_OBJECT (dbin, "Dropping duplicate selection"); + g_list_free (tmp); + tmp = NULL; + } + if (tmp) { + /* Finally set the requested selection */ if (dbin->requested_selection) { GST_FIXME_OBJECT (dbin, "Replacing non-NULL requested_selection, what should we do ??");