diff options
author | malc <av1474@comtv.ru> | 2009-10-02 02:37:40 +0400 |
---|---|---|
committer | malc <av1474@comtv.ru> | 2009-10-02 02:37:40 +0400 |
commit | 301901b56c75e4e2ec65ed7598cd69b9d5fb4fe3 (patch) | |
tree | 51b658a1cdaefac04a0aab16d2f4954ebc23d609 /audio/ossaudio.c | |
parent | c227f0995e1722a1abccc28cadf0664266bd8043 (diff) |
oss/alsa: Do not invoke UB described in 7.15.1.1
Additional argument (whether to try poll mode) is only passed with
VOICE_ENABLE command.
Thanks to Markus Armbruster for noticing the potential breakage.
Diffstat (limited to 'audio/ossaudio.c')
-rw-r--r-- | audio/ossaudio.c | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 946a9dc98f..dae25e93ab 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -583,34 +583,37 @@ static int oss_init_out (HWVoiceOut *hw, struct audsettings *as) static int oss_ctl_out (HWVoiceOut *hw, int cmd, ...) { int trig; - va_list ap; - int poll_mode; OSSVoiceOut *oss = (OSSVoiceOut *) hw; - va_start (ap, cmd); - poll_mode = va_arg (ap, int); - va_end (ap); - switch (cmd) { case VOICE_ENABLE: - ldebug ("enabling voice\n"); - if (poll_mode && oss_poll_out (hw)) { - poll_mode = 0; - } - hw->poll_mode = poll_mode; + { + va_list ap; + int poll_mode; - if (!oss->mmapped) { - return 0; - } + va_start (ap, cmd); + poll_mode = va_arg (ap, int); + va_end (ap); - audio_pcm_info_clear_buf (&hw->info, oss->pcm_buf, hw->samples); - trig = PCM_ENABLE_OUTPUT; - if (ioctl (oss->fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) { - oss_logerr ( - errno, - "SNDCTL_DSP_SETTRIGGER PCM_ENABLE_OUTPUT failed\n" - ); - return -1; + ldebug ("enabling voice\n"); + if (poll_mode && oss_poll_out (hw)) { + poll_mode = 0; + } + hw->poll_mode = poll_mode; + + if (!oss->mmapped) { + return 0; + } + + audio_pcm_info_clear_buf (&hw->info, oss->pcm_buf, hw->samples); + trig = PCM_ENABLE_OUTPUT; + if (ioctl (oss->fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) { + oss_logerr ( + errno, + "SNDCTL_DSP_SETTRIGGER PCM_ENABLE_OUTPUT failed\n" + ); + return -1; + } } break; |