[vlc-commits] PulseAudio: fix theoretical crash setting volume w/o stream
Rémi Denis-Courmont
git at videolan.org
Wed Oct 31 20:18:03 CET 2012
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Oct 31 21:15:29 2012 +0200| [76303c26463e4199e85dd9f9d492294b7dd8c479] | committer: Rémi Denis-Courmont
PulseAudio: fix theoretical crash setting volume w/o stream
There is no core support for this as yet, so the crash cannot happen.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=76303c26463e4199e85dd9f9d492294b7dd8c479
---
modules/audio_output/pulse.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
index e3dec5e..de21594 100644
--- a/modules/audio_output/pulse.c
+++ b/modules/audio_output/pulse.c
@@ -633,8 +633,11 @@ static void Flush(audio_output_t *aout, bool wait)
static int VolumeSet(audio_output_t *aout, float vol)
{
aout_sys_t *sys = aout->sys;
- pa_operation *op;
- uint32_t idx = pa_stream_get_index(sys->stream);
+ if (sys->stream == NULL)
+ {
+ msg_Err (aout, "cannot change volume while not playing");
+ return -1;
+ }
/* VLC provides the software volume so convert directly to PulseAudio
* software volume, pa_volume_t. This is not a linear amplification factor
@@ -648,11 +651,13 @@ static int VolumeSet(audio_output_t *aout, float vol)
pa_cvolume cvolume = sys->cvolume;
pa_cvolume_scale(&cvolume, PA_VOLUME_NORM);
pa_sw_cvolume_multiply_scalar(&cvolume, &cvolume, volume);
-
assert(pa_cvolume_valid(&cvolume));
+ pa_operation *op;
+ uint32_t idx = pa_stream_get_index(sys->stream);
pa_threaded_mainloop_lock(sys->mainloop);
- op = pa_context_set_sink_input_volume(sys->context, idx, &cvolume, NULL, NULL);
+ op = pa_context_set_sink_input_volume(sys->context, idx, &cvolume,
+ NULL, NULL);
if (likely(op != NULL))
pa_operation_unref(op);
pa_threaded_mainloop_unlock(sys->mainloop);
@@ -663,9 +668,14 @@ static int VolumeSet(audio_output_t *aout, float vol)
static int MuteSet(audio_output_t *aout, bool mute)
{
aout_sys_t *sys = aout->sys;
+ if (sys->stream == NULL)
+ {
+ msg_Err (aout, "cannot change volume while not playing");
+ return -1;
+ }
+
pa_operation *op;
uint32_t idx = pa_stream_get_index(sys->stream);
-
pa_threaded_mainloop_lock(sys->mainloop);
op = pa_context_set_sink_input_mute(sys->context, idx, mute, NULL, NULL);
if (likely(op != NULL))
More information about the vlc-commits
mailing list