uridecodebin3: Atomically switch urisourcebin

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>
This commit is contained in:
Edward Hervey 2024-02-22 17:00:50 +01:00 committed by GStreamer Marge Bot
parent 3da09ba971
commit 5422c6c6d4

View 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);