decodebin3: Unify collection switching checks
authorEdward Hervey <bilboed@bilboed.com>
Fri, 22 Nov 2024 10:50:05 +0000 (11:50 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 25 Nov 2024 16:26:35 +0000 (16:26 +0000)
We only want to switch to a selection of an output collection if all streams are
present.

This was previously only done in one place (when triggering by new incoming
streams) but not when triggered by user/application.

Avoid this by moving the check to handle_stream_switch()

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

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

index c7daaca67ed78f7eb70a6a3c6909c2d60d00cf7b..17ae32c66643063ea5371369ad7b77e0f0c352ca 100644 (file)
@@ -3555,8 +3555,8 @@ mq_slot_handle_stream_start (MultiQueueSlot * slot, GstEvent * stream_event)
   }
 
 check_for_switch:
-  if (!dbin->upstream_handles_selection && collection == dbin->output_collection
-      && collection->all_streams_present) {
+  if (!dbin->upstream_handles_selection
+      && collection == dbin->output_collection) {
     handle_stream_switch (dbin);
   }
 
@@ -4312,6 +4312,8 @@ mq_slot_unassign_probe (GstPad * pad, GstPadProbeInfo * info,
  *
  * Figures out which slots to (de)activate for the given output_collection.
  *
+ * Will only take place if all streams of the output collection are present.
+ *
  * Must be called with SELECTION_LOCK taken.
  */
 static void
@@ -4330,6 +4332,12 @@ handle_stream_switch (GstDecodebin3 * dbin)
 
   g_return_if_fail (collection);
 
+  if (!collection->all_streams_present) {
+    GST_DEBUG_OBJECT (dbin,
+        "Not all streams are present yet. Delaying actual switch");
+    return;
+  }
+
   /* COMPARE the requested streams to the active and requested streams
    * on multiqueue. */
 
@@ -4558,7 +4566,7 @@ handle_select_streams (GstDecodebin3 * dbin, GstEvent * event)
   collection->seqnum = seqnum;
   collection->posted_streams_selected_msg = FALSE;
 
-  /* If the collection is the current output one, handle the switch */
+  /* If the collection is the current output one, handle the switch. */
   if (collection == dbin->output_collection)
     handle_stream_switch (dbin);