aggregator: Protect all latency related members with the object lock
authorOlivier Crête <olivier.crete@collabora.com>
Thu, 22 Jan 2015 00:44:57 +0000 (19:44 -0500)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 2 Dec 2017 15:10:26 +0000 (15:10 +0000)
The locking was not consistent, now consistently use the object lock.

https://bugzilla.gnome.org/show_bug.cgi?id=742684

libs/gst/base/gstaggregator.c

index 73a655f..ba4bc85 100644 (file)
@@ -565,7 +565,6 @@ gst_aggregator_wait_and_check (GstAggregator * self, gboolean * timeout)
     clock = GST_ELEMENT_CLOCK (self);
     if (clock)
       gst_object_ref (clock);
-    GST_OBJECT_UNLOCK (self);
 
     time = base_time + start;
 
@@ -584,6 +583,8 @@ gst_aggregator_wait_and_check (GstAggregator * self, gboolean * timeout)
         GST_TIME_ARGS (latency_min),
         GST_TIME_ARGS (gst_clock_get_time (clock)));
 
+    GST_OBJECT_UNLOCK (self);
+
     self->priv->aggregate_id = gst_clock_new_single_shot_id (clock, time);
     gst_object_unref (clock);
     SRC_STREAM_UNLOCK (self);
@@ -1175,6 +1176,7 @@ gst_aggregator_query_latency (GstAggregator * self, GstQuery * query)
       gst_aggregator_query_sink_latency_foreach, &data);
   SRC_STREAM_UNLOCK (self);
 
+  GST_OBJECT_LOCK (self);
   our_latency = self->priv->latency;
 
   if (data.live && GST_CLOCK_TIME_IS_VALID (our_latency) &&
@@ -1218,6 +1220,8 @@ gst_aggregator_query_latency (GstAggregator * self, GstQuery * query)
       && GST_CLOCK_TIME_IS_VALID (data.max))
     data.max += self->priv->sub_latency_max;
 
+  GST_OBJECT_UNLOCK (self);
+
   GST_DEBUG_OBJECT (self, "configured latency live:%s min:%" G_GINT64_FORMAT
       " max:%" G_GINT64_FORMAT, data.live ? "true" : "false", data.min,
       data.max);