From 2308999849d370760b9aa41498710cfe9760f030 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 27 Jul 2009 11:51:39 +0200 Subject: pulsesink: avoid using ivalid stream indexes when we get an invalid stream index from pulse because we were just starting, avoid using it for getting and setting the volume. Fixes #589365 --- ext/pulse/pulsesink.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'ext/pulse/pulsesink.c') diff --git a/ext/pulse/pulsesink.c b/ext/pulse/pulsesink.c index fbaac8ca..97454a91 100644 --- a/ext/pulse/pulsesink.c +++ b/ext/pulse/pulsesink.c @@ -1605,6 +1605,7 @@ gst_pulsesink_set_volume (GstPulseSink * psink, gdouble volume) pa_cvolume v; pa_operation *o = NULL; GstPulseRingBuffer *pbuf; + uint32_t idx; pa_threaded_mainloop_lock (psink->mainloop); @@ -1615,12 +1616,15 @@ gst_pulsesink_set_volume (GstPulseSink * psink, gdouble volume) pbuf = GST_PULSERING_BUFFER_CAST (GST_BASE_AUDIO_SINK (psink)->ringbuffer); if (pbuf == NULL || pbuf->stream == NULL) - goto unlock; + goto no_buffer; + + if ((idx = pa_stream_get_index (pbuf->stream)) == PA_INVALID_INDEX) + goto no_index; gst_pulse_cvolume_from_linear (&v, pbuf->sample_spec.channels, volume); - if (!(o = pa_context_set_sink_input_volume (pbuf->context, - pa_stream_get_index (pbuf->stream), &v, NULL, NULL))) + if (!(o = pa_context_set_sink_input_volume (pbuf->context, idx, + &v, NULL, NULL))) goto volume_failed; /* We don't really care about the result of this call */ @@ -1634,6 +1638,16 @@ unlock: return; /* ERRORS */ +no_buffer: + { + GST_DEBUG_OBJECT (psink, "we have no ringbuffer"); + goto unlock; + } +no_index: + { + GST_DEBUG_OBJECT (psink, "we don't have a stream index"); + goto unlock; + } volume_failed: { GST_ELEMENT_ERROR (psink, RESOURCE, FAILED, @@ -1675,6 +1689,7 @@ gst_pulsesink_get_volume (GstPulseSink * psink) GstPulseRingBuffer *pbuf; pa_operation *o = NULL; gdouble v; + uint32_t idx; pa_threaded_mainloop_lock (psink->mainloop); @@ -1682,8 +1697,10 @@ gst_pulsesink_get_volume (GstPulseSink * psink) if (pbuf == NULL || pbuf->stream == NULL) goto no_buffer; - if (!(o = pa_context_get_sink_input_info (pbuf->context, - pa_stream_get_index (pbuf->stream), + if ((idx = pa_stream_get_index (pbuf->stream)) == PA_INVALID_INDEX) + goto no_index; + + if (!(o = pa_context_get_sink_input_info (pbuf->context, idx, gst_pulsesink_sink_input_info_cb, pbuf))) goto info_failed; @@ -1713,6 +1730,11 @@ no_buffer: GST_DEBUG_OBJECT (psink, "we have no ringbuffer"); goto unlock; } +no_index: + { + GST_DEBUG_OBJECT (psink, "we don't have a stream index"); + goto unlock; + } info_failed: { GST_ELEMENT_ERROR (psink, RESOURCE, FAILED, -- cgit