uridecodebin3: Atomically switch urisourcebin
authorEdward Hervey <edward@centricular.com>
Thu, 22 Feb 2024 16:00:50 +0000 (17:00 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 23 Feb 2024 08:29:47 +0000 (08:29 +0000)
When switching urisourcebin, ensure that we first unlink *all* pads from
decodebin3 before linking them again.

This is to ensure that decodebin3 completely knows that all previous pads are no
longer needed and can prepare itself to being re-used.

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

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

index 6d326adfb15ff9c1ea01c26859365106e0dda3ee..65185210142a5c0d4eed3dd0750971dc9c441576 100644 (file)
@@ -1115,7 +1115,7 @@ switch_and_activate_input_locked (GstURIDecodeBin3 * uridecodebin,
       new_spad->db3_pad_is_request = old_spad->db3_pad_is_request;
       old_spad->db3_sink_pad = NULL;
 
-      gst_pad_link (new_spad->src_pad, new_spad->db3_sink_pad);
+      /* NOTE : Pad will be linked further down */
       old_pads = g_list_remove (old_pads, old_spad);
     } else {
       GST_DEBUG_OBJECT (new_spad->src_pad, "Needs a new pad");
@@ -1142,7 +1142,7 @@ switch_and_activate_input_locked (GstURIDecodeBin3 * uridecodebin,
         new_spad->db3_pad_is_request = old_spad->db3_pad_is_request;
         old_spad->db3_sink_pad = NULL;
 
-        gst_pad_link (new_spad->src_pad, new_spad->db3_sink_pad);
+        /* NOTE : Pad will be linked further down */
         old_pads = g_list_remove (old_pads, old_spad);
         to_activate = g_list_remove (to_activate, new_spad);
         break;
@@ -1161,7 +1161,14 @@ switch_and_activate_input_locked (GstURIDecodeBin3 * uridecodebin,
     }
   }
 
-  /* Link new source pads */
+  /* Link existing pads */
+  for (iternew = new_pads; iternew; iternew = iternew->next) {
+    GstSourcePad *new_spad = iternew->data;
+    if (new_spad->db3_sink_pad)
+      gst_pad_link (new_spad->src_pad, new_spad->db3_sink_pad);
+  }
+
+  /* Request (and link) new pads */
   for (iternew = to_activate; iternew; iternew = iternew->next) {
     GstSourcePad *new_spad = iternew->data;
     link_src_pad_to_db3 (uridecodebin, new_spad);