mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-21 15:56:42 +00:00
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
This commit is contained in:
parent
f0054bcc82
commit
2308999849
1 changed files with 27 additions and 5 deletions
|
@ -1605,6 +1605,7 @@ gst_pulsesink_set_volume (GstPulseSink * psink, gdouble volume)
|
||||||
pa_cvolume v;
|
pa_cvolume v;
|
||||||
pa_operation *o = NULL;
|
pa_operation *o = NULL;
|
||||||
GstPulseRingBuffer *pbuf;
|
GstPulseRingBuffer *pbuf;
|
||||||
|
uint32_t idx;
|
||||||
|
|
||||||
pa_threaded_mainloop_lock (psink->mainloop);
|
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);
|
pbuf = GST_PULSERING_BUFFER_CAST (GST_BASE_AUDIO_SINK (psink)->ringbuffer);
|
||||||
if (pbuf == NULL || pbuf->stream == NULL)
|
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);
|
gst_pulse_cvolume_from_linear (&v, pbuf->sample_spec.channels, volume);
|
||||||
|
|
||||||
if (!(o = pa_context_set_sink_input_volume (pbuf->context,
|
if (!(o = pa_context_set_sink_input_volume (pbuf->context, idx,
|
||||||
pa_stream_get_index (pbuf->stream), &v, NULL, NULL)))
|
&v, NULL, NULL)))
|
||||||
goto volume_failed;
|
goto volume_failed;
|
||||||
|
|
||||||
/* We don't really care about the result of this call */
|
/* We don't really care about the result of this call */
|
||||||
|
@ -1634,6 +1638,16 @@ unlock:
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* ERRORS */
|
/* 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:
|
volume_failed:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (psink, RESOURCE, FAILED,
|
GST_ELEMENT_ERROR (psink, RESOURCE, FAILED,
|
||||||
|
@ -1675,6 +1689,7 @@ gst_pulsesink_get_volume (GstPulseSink * psink)
|
||||||
GstPulseRingBuffer *pbuf;
|
GstPulseRingBuffer *pbuf;
|
||||||
pa_operation *o = NULL;
|
pa_operation *o = NULL;
|
||||||
gdouble v;
|
gdouble v;
|
||||||
|
uint32_t idx;
|
||||||
|
|
||||||
pa_threaded_mainloop_lock (psink->mainloop);
|
pa_threaded_mainloop_lock (psink->mainloop);
|
||||||
|
|
||||||
|
@ -1682,8 +1697,10 @@ gst_pulsesink_get_volume (GstPulseSink * psink)
|
||||||
if (pbuf == NULL || pbuf->stream == NULL)
|
if (pbuf == NULL || pbuf->stream == NULL)
|
||||||
goto no_buffer;
|
goto no_buffer;
|
||||||
|
|
||||||
if (!(o = pa_context_get_sink_input_info (pbuf->context,
|
if ((idx = pa_stream_get_index (pbuf->stream)) == PA_INVALID_INDEX)
|
||||||
pa_stream_get_index (pbuf->stream),
|
goto no_index;
|
||||||
|
|
||||||
|
if (!(o = pa_context_get_sink_input_info (pbuf->context, idx,
|
||||||
gst_pulsesink_sink_input_info_cb, pbuf)))
|
gst_pulsesink_sink_input_info_cb, pbuf)))
|
||||||
goto info_failed;
|
goto info_failed;
|
||||||
|
|
||||||
|
@ -1713,6 +1730,11 @@ no_buffer:
|
||||||
GST_DEBUG_OBJECT (psink, "we have no ringbuffer");
|
GST_DEBUG_OBJECT (psink, "we have no ringbuffer");
|
||||||
goto unlock;
|
goto unlock;
|
||||||
}
|
}
|
||||||
|
no_index:
|
||||||
|
{
|
||||||
|
GST_DEBUG_OBJECT (psink, "we don't have a stream index");
|
||||||
|
goto unlock;
|
||||||
|
}
|
||||||
info_failed:
|
info_failed:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (psink, RESOURCE, FAILED,
|
GST_ELEMENT_ERROR (psink, RESOURCE, FAILED,
|
||||||
|
|
Loading…
Reference in a new issue