From 0f8edca902c09622493d23776859bab2348837f6 Mon Sep 17 00:00:00 2001 From: Stian Johansen Date: Wed, 23 Feb 2011 10:55:12 +0100 Subject: [PATCH] baseaudiosrc: Add src object lock around call to ringbuffer parse caps. A race was observed between query() and setcaps() where the latter would change the ringbuffer spec while the former was performing operations based this data. --- gst-libs/gst/audio/gstbaseaudiosrc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gst-libs/gst/audio/gstbaseaudiosrc.c b/gst-libs/gst/audio/gstbaseaudiosrc.c index adf9254ae6..7c7ec935b0 100644 --- a/gst-libs/gst/audio/gstbaseaudiosrc.c +++ b/gst-libs/gst/audio/gstbaseaudiosrc.c @@ -560,14 +560,20 @@ gst_base_audio_src_setcaps (GstBaseSrc * bsrc, GstCaps * caps) spec->buffer_time = src->buffer_time; spec->latency_time = src->latency_time; + GST_OBJECT_LOCK (src); if (!gst_ring_buffer_parse_caps (spec, caps)) + { + GST_OBJECT_UNLOCK (src); goto parse_error; + } /* calculate suggested segsize and segtotal */ spec->segsize = spec->rate * spec->bytes_per_sample * spec->latency_time / GST_MSECOND; spec->segtotal = spec->buffer_time / spec->latency_time; + GST_OBJECT_UNLOCK (src); + GST_DEBUG ("release old ringbuffer"); gst_ring_buffer_release (src->ringbuffer);