summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2009-07-27 11:51:39 +0200
committerWim Taymans <wim.taymans@collabora.co.uk>2009-07-27 11:51:39 +0200
commit2308999849d370760b9aa41498710cfe9760f030 (patch)
treed44045e9be3132046da59557370c3bf21201eb55
parentf0054bcc8250b2d4463ac721dc99a0d6cf815d69 (diff)
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
-rw-r--r--ext/pulse/pulsesink.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/ext/pulse/pulsesink.c b/ext/pulse/pulsesink.c
index fbaac8ca4..97454a914 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,