audioringbuffer: check if acquired in set_timestamp
authorDavid Svensson Fors <davidsf@axis.com>
Mon, 23 Sep 2013 09:35:43 +0000 (11:35 +0200)
committerSebastian Dröge <slomo@circular-chaos.org>
Tue, 1 Oct 2013 20:12:07 +0000 (22:12 +0200)
Also use GST_OBJECT_LOCK when accessing object data in set_timestamp.

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

gst-libs/gst/audio/gstaudioringbuffer.c

index 0494161..0a883ef 100644 (file)
@@ -1984,9 +1984,20 @@ gst_audio_ring_buffer_set_timestamp (GstAudioRingBuffer * buf, gint readseg,
 
   GST_INFO_OBJECT (buf, "Storing timestamp %" GST_TIME_FORMAT
       " @ %d", GST_TIME_ARGS (timestamp), readseg);
-  if (buf->timestamps) {
-    buf->timestamps[readseg] = timestamp;
-  } else {
-    GST_ERROR_OBJECT (buf, "Could not store timestamp, no timestamps buffer");
+
+  GST_OBJECT_LOCK (buf);
+  if (G_UNLIKELY (!buf->acquired))
+    goto not_acquired;
+
+  buf->timestamps[readseg] = timestamp;
+
+done:
+  GST_OBJECT_UNLOCK (buf);
+  return;
+
+not_acquired:
+  {
+    GST_DEBUG_OBJECT (buf, "we are not acquired");
+    goto done;
   }
 }