From 9dc4d48ff599419814523ea631d46d038d75e95d Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Fri, 21 Apr 2023 17:44:43 +0200 Subject: [PATCH] core: pipeline: protect priv->is_live with object lock It's supposed to be according to the comment where it's defined. Part-of: --- subprojects/gstreamer/gst/gstpipeline.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/subprojects/gstreamer/gst/gstpipeline.c b/subprojects/gstreamer/gst/gstpipeline.c index f2e694fc0a..8ba8643680 100644 --- a/subprojects/gstreamer/gst/gstpipeline.c +++ b/subprojects/gstreamer/gst/gstpipeline.c @@ -519,7 +519,9 @@ gst_pipeline_change_state (GstElement * element, GstStateChange transition) break; } case GST_STATE_CHANGE_PAUSED_TO_READY: + GST_OBJECT_LOCK (element); pipeline->priv->is_live = FALSE; + GST_OBJECT_UNLOCK (element); reset_start_time (pipeline, 0); break; case GST_STATE_CHANGE_READY_TO_NULL: @@ -529,9 +531,11 @@ gst_pipeline_change_state (GstElement * element, GstStateChange transition) result = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); if (GST_STATE_TRANSITION_NEXT (transition) == GST_STATE_PAUSED) { + GST_OBJECT_LOCK (element); pipeline->priv->is_live = result == GST_STATE_CHANGE_NO_PREROLL; GST_INFO_OBJECT (pipeline, "pipeline is%slive", pipeline->priv->is_live ? " " : " not "); + GST_OBJECT_UNLOCK (element); } switch (transition) { @@ -621,6 +625,7 @@ gst_pipeline_handle_message (GstBin * bin, GstMessage * message) case GST_MESSAGE_RESET_TIME: { GstClockTime running_time; + gboolean is_live; gst_message_parse_reset_time (message, &running_time); @@ -628,9 +633,12 @@ gst_pipeline_handle_message (GstBin * bin, GstMessage * message) * children. */ reset_start_time (pipeline, running_time); + GST_OBJECT_LOCK (pipeline); + is_live = pipeline->priv->is_live; + GST_OBJECT_UNLOCK (pipeline); + /* If we are live, sample a new base_time immediately */ - if (pipeline->priv->is_live - && GST_STATE_TARGET (pipeline) == GST_STATE_PLAYING) { + if (is_live && GST_STATE_TARGET (pipeline) == GST_STATE_PLAYING) { gst_pipeline_change_state (GST_ELEMENT (pipeline), GST_STATE_CHANGE_PAUSED_TO_PLAYING); }