Message ID | 87ws3f3zsb.fsf@pike.pond.sub.org |
---|---|
State | Superseded |
Headers | show |
On Thu, 1 Oct 2009, Markus Armbruster wrote: > malc <av1474@comtv.ru> writes: > > > On Thu, 1 Oct 2009, Markus Armbruster wrote: > > > >> malc <av1474@comtv.ru> writes: > >> > >> > On Wed, 30 Sep 2009, Markus Armbruster wrote: > >> > > > > > [..snip..] > > [..snip..] > > The ctl_out() and ctl_in() callbacks I checked (ALSA, OSS), get the > variable argument unconditionally. > > Getting more variable arguments than the caller passed is undefined > behavior (C99 7.15.1.1), although in practice is usually gets some > unpredictable value, which is harmless as long as it's not actually > used. I wasn't aware of that, thank you for pointing that out. > > Not getting all variable arguments the caller passed is fine. > > So, the calls you fixed up weren't broken in the first place, and the > change isn't worth the trouble, in my opinion. > > However, there are calls with undefined behavior, because they pass two > arguments (two fixed, zero variable), and at least some callees use > three (two fixed, one variable). Fix for that below. > I'd much rather fix oss and alsa, they should look for poll_mode only in case of enable, one more time thanks for heads up.
malc <av1474@comtv.ru> writes: > On Thu, 1 Oct 2009, Markus Armbruster wrote: > >> malc <av1474@comtv.ru> writes: >> >> > On Thu, 1 Oct 2009, Markus Armbruster wrote: >> > >> >> malc <av1474@comtv.ru> writes: >> >> >> >> > On Wed, 30 Sep 2009, Markus Armbruster wrote: >> >> > >> > >> > [..snip..] >> > > [..snip..] > >> >> The ctl_out() and ctl_in() callbacks I checked (ALSA, OSS), get the >> variable argument unconditionally. >> >> Getting more variable arguments than the caller passed is undefined >> behavior (C99 7.15.1.1), although in practice is usually gets some >> unpredictable value, which is harmless as long as it's not actually >> used. > > I wasn't aware of that, thank you for pointing that out. > >> >> Not getting all variable arguments the caller passed is fine. >> >> So, the calls you fixed up weren't broken in the first place, and the >> change isn't worth the trouble, in my opinion. >> >> However, there are calls with undefined behavior, because they pass two >> arguments (two fixed, zero variable), and at least some callees use >> three (two fixed, one variable). Fix for that below. >> > > I'd much rather fix oss and alsa, they should look for poll_mode only in > case of enable, one more time thanks for heads up. Makes sense. Better check the other drivers as well, because I didn't.
On Fri, 2 Oct 2009, Markus Armbruster wrote: > malc <av1474@comtv.ru> writes: > [..snip..] > > Makes sense. > > Better check the other drivers as well, because I didn't. Nothing else implements polled mode. And one more thing audio_at_exit tears down captures, those might need some finalizations of their own, much like WAV does (in fact apart from VNC audio the only other capture that exits now is also a WAV renderer, which can be started/stopped from the monitor)
diff --git a/audio/audio.c b/audio/audio.c index 80a717b..874933c 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1243,7 +1243,7 @@ void AUD_set_active_in (SWVoiceIn *sw, int on) if (nb_active == 1) { hw->enabled = 0; - hw->pcm_ops->ctl_in (hw, VOICE_DISABLE); + hw->pcm_ops->ctl_in (hw, VOICE_DISABLE, 0); } } } @@ -1363,7 +1363,7 @@ static void audio_run_out (AudioState *s) #endif hw->enabled = 0; hw->pending_disable = 0; - hw->pcm_ops->ctl_out (hw, VOICE_DISABLE); + hw->pcm_ops->ctl_out (hw, VOICE_DISABLE, 0); for (sc = hw->cap_head.lh_first; sc; sc = sc->entries.le_next) { sc->sw.active = 0; audio_recalc_and_notify_capture (sc->cap); @@ -1761,7 +1761,7 @@ static void audio_atexit (void) while ((hwo = audio_pcm_hw_find_any_enabled_out (hwo))) { SWVoiceCap *sc; - hwo->pcm_ops->ctl_out (hwo, VOICE_DISABLE); + hwo->pcm_ops->ctl_out (hwo, VOICE_DISABLE, 0); hwo->pcm_ops->fini_out (hwo); for (sc = hwo->cap_head.lh_first; sc; sc = sc->entries.le_next) { @@ -1775,7 +1775,7 @@ static void audio_atexit (void) } while ((hwi = audio_pcm_hw_find_any_enabled_in (hwi))) { - hwi->pcm_ops->ctl_in (hwi, VOICE_DISABLE); + hwi->pcm_ops->ctl_in (hwi, VOICE_DISABLE, 0); hwi->pcm_ops->fini_in (hwi); }