aggregator: More fixes around locking when accessing protected private fields
authorThibault Saunier <tsaunier@gnome.org>
Mon, 26 Jan 2015 10:32:47 +0000 (11:32 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 2 Dec 2017 15:10:26 +0000 (15:10 +0000)
In some more places we were accessing GstAggregator->segment
and GstAggregator->seqnum without holding the GST_OBJECT_LOCK

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

libs/gst/base/gstaggregator.c

index 6aecb17..d63ce22 100644 (file)
@@ -494,9 +494,13 @@ gst_aggregator_push_eos (GstAggregator * self)
   GstEvent *event;
   gst_aggregator_push_mandatory_events (self);
 
-  self->priv->send_eos = FALSE;
   event = gst_event_new_eos ();
+
+  GST_OBJECT_LOCK (self);
+  self->priv->send_eos = FALSE;
   gst_event_set_seqnum (event, self->priv->seqnum);
+  GST_OBJECT_UNLOCK (self);
+
   gst_pad_push_event (self->srcpad, event);
 }
 
@@ -883,7 +887,10 @@ gst_aggregator_default_sink_event (GstAggregator * self,
       GST_OBJECT_LOCK (aggpad);
       gst_event_copy_segment (event, &aggpad->segment);
       GST_OBJECT_UNLOCK (aggpad);
+
+      GST_OBJECT_LOCK (self);
       self->priv->seqnum = gst_event_get_seqnum (event);
+      GST_OBJECT_UNLOCK (self);
       goto eat;
     }
     case GST_EVENT_STREAM_START:
@@ -1246,10 +1253,13 @@ gst_aggregator_send_event (GstElement * element, GstEvent * event)
 
     gst_event_parse_seek (event, &rate, &fmt, &flags, &start_type,
         &start, &stop_type, &stop);
+
+    GST_OBJECT_LOCK (self);
     gst_segment_do_seek (&self->segment, rate, fmt, flags, start_type, start,
         stop_type, stop, NULL);
-
     self->priv->seqnum = gst_event_get_seqnum (event);
+    GST_OBJECT_UNLOCK (self);
+
     GST_DEBUG_OBJECT (element, "Storing segment %" GST_PTR_FORMAT, event);
   }
   GST_STATE_UNLOCK (element);