baseaudiosrc: protect against ringbuffer disappearing while in a query

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.
This commit is contained in:
Havard Graff 2011-01-22 23:09:32 +01:00 committed by Sebastian Dröge
parent 588ac0ae6f
commit 63cfa2a50d

View file

@ -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,