From 63cfa2a50da29ef897ce598abe60a3cbda950989 Mon Sep 17 00:00:00 2001 From: Havard Graff Date: Sat, 22 Jan 2011 23:09:32 +0100 Subject: [PATCH] baseaudiosrc: protect against ringbuffer disappearing while in a query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Observed a case where the src went to null-state during the query, hence the spec pointer was no longer valid, and gst_util_unit64_scale_int crashed (assertion `denom > 0´failed) Add locking to make sure the ringbuffer can't disappear. --- gst-libs/gst/audio/gstbaseaudiosrc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gst-libs/gst/audio/gstbaseaudiosrc.c b/gst-libs/gst/audio/gstbaseaudiosrc.c index 06aa3abffa..adf9254ae6 100644 --- a/gst-libs/gst/audio/gstbaseaudiosrc.c +++ b/gst-libs/gst/audio/gstbaseaudiosrc.c @@ -628,9 +628,12 @@ gst_base_audio_src_query (GstBaseSrc * bsrc, GstQuery * query) GstClockTime min_latency, max_latency; GstRingBufferSpec *spec; + GST_OBJECT_LOCK (src); if (G_UNLIKELY (src->ringbuffer == NULL - || src->ringbuffer->spec.rate == 0)) + || src->ringbuffer->spec.rate == 0)) { + GST_OBJECT_UNLOCK (src); goto done; + } spec = &src->ringbuffer->spec; @@ -642,6 +645,7 @@ gst_base_audio_src_query (GstBaseSrc * bsrc, GstQuery * query) max_latency = gst_util_uint64_scale_int (spec->segtotal * spec->segsize, GST_SECOND, spec->rate * spec->bytes_per_sample); + GST_OBJECT_UNLOCK (src); GST_DEBUG_OBJECT (src, "report latency min %" GST_TIME_FORMAT " max %" GST_TIME_FORMAT,