decodebin3: ensure recalculate_group_id() is called with INPUT lock
authorGuillaume Desmottes <guillaume.desmottes@onestream.live>
Tue, 10 Jan 2023 10:19:12 +0000 (11:19 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 11 Jan 2023 18:37:05 +0000 (18:37 +0000)
This function uses main_input and current_group_id which are protected
by the input lock.
Some calls were already safe but not all.

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

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

index 7d733d3..a049e23 100644 (file)
@@ -972,6 +972,7 @@ query_duration_drop_probe (GstPad * pad, GstPadProbeInfo * info,
   return ret;
 }
 
+/* CALL with INPUT LOCK */
 static void
 recalculate_group_id (GstDecodebin3 * dbin)
 {
@@ -1003,6 +1004,7 @@ reset_input_parsebin (GstDecodebin3 * dbin, DecodebinInput * input)
 
   GST_DEBUG_OBJECT (dbin, "Resetting %" GST_PTR_FORMAT, input->parsebin);
 
+  INPUT_LOCK (dbin);
   GST_STATE_LOCK (dbin);
   gst_element_set_state (input->parsebin, GST_STATE_NULL);
   input->drained = FALSE;
@@ -1015,6 +1017,7 @@ reset_input_parsebin (GstDecodebin3 * dbin, DecodebinInput * input)
   }
   gst_element_sync_state_with_parent (input->parsebin);
   GST_STATE_UNLOCK (dbin);
+  INPUT_UNLOCK (dbin);
 }
 
 
@@ -1306,7 +1309,9 @@ sink_event_function (GstPad * sinkpad, GstDecodebin3 * dbin, GstEvent * event)
 
       /* Make sure group ids will be recalculated */
       input->group_id = GST_GROUP_ID_INVALID;
+      INPUT_LOCK (dbin);
       recalculate_group_id (dbin);
+      INPUT_UNLOCK (dbin);
       break;
     }
     case GST_EVENT_STREAM_COLLECTION: