From 7807f46cd1b8f58ee8f2e5f6d7240d7ca7502311 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Mon, 9 Apr 2012 17:39:01 +0300 Subject: audio: keep volume level internally (not only in AO) Current volume was always queried from the the audio output driver (or filter in case of --softvol). The only case where it was stored on mixer level was that when turning off mute, volume was set to the value it had before mute was activated. Change the mixer code to always store the current target volume internally. It still checks for significant changes from external sources and resets the internal value in that case. The main functionality changes are: Volume will now be kept separately from mute status. Increasing or decreasing volume will now change it relative to the original value before mute, even if mute is implemented by setting AO level volume to 0. Volume changes no longer automatically disable mute. The exception is relative changes up (like the volume increase key in default keybindings); that's the only case which still disables mute. Keeping the value internally avoids problems with granularity of possible volume values supported by AO. Increase/decrease keys could work unsymmetrically, or when specifying a smaller than default --volstep, even fail completely. In one case occurring in practice, if the AO only supports changing volume in steps of about 2 and rounds down the requested volume, then volume down key would decrease by 4 but volume up would increase by 2 (previous volume plus or minus the default change of 3, rounded down to a multiple of 2). Now, the internal value will keep full precision. --- command.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'command.c') diff --git a/command.c b/command.c index 7ce0e7e924..3c1805b412 100644 --- a/command.c +++ b/command.c @@ -756,18 +756,17 @@ static int mp_property_mute(m_option_t *prop, int action, void *arg, case M_PROPERTY_SET: if (!arg) return M_PROPERTY_ERROR; - if ((!!*(int *) arg) != mpctx->mixer.muted) - mixer_mute(&mpctx->mixer); + mixer_setmute(&mpctx->mixer, *(int *) arg); mpctx->user_muted = mpctx->mixer.muted; return M_PROPERTY_OK; case M_PROPERTY_STEP_UP: case M_PROPERTY_STEP_DOWN: - mixer_mute(&mpctx->mixer); + mixer_setmute(&mpctx->mixer, !mixer_getmute(&mpctx->mixer)); mpctx->user_muted = mpctx->mixer.muted; return M_PROPERTY_OK; default: - return m_property_flag(prop, action, arg, &mpctx->mixer.muted); - + return m_property_flag_ro(prop, action, arg, + mixer_getmute(&mpctx->mixer)); } } -- cgit v1.2.3 From e29cb8f323031b32369bc2104ea1fd4422dd2945 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Mon, 9 Apr 2012 21:06:10 +0300 Subject: audio: restore balance setting after reinit Restore the audio balance setting when the audio chain is reinitialized (also after switching to another file). Also add a note about the balance code being seriously buggy. --- command.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'command.c') diff --git a/command.c b/command.c index 3c1805b412..e4ce53f87a 100644 --- a/command.c +++ b/command.c @@ -871,9 +871,6 @@ static int mp_property_balance(m_option_t *prop, int action, void *arg, { float bal; - if (!mpctx->sh_audio || mpctx->sh_audio->channels < 2) - return M_PROPERTY_UNAVAILABLE; - switch (action) { case M_PROPERTY_GET: if (!arg) -- cgit v1.2.3 From 9624f10aa85039c73d4bdb70e8062daeabaa90c6 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Mon, 9 Apr 2012 22:11:49 +0300 Subject: audio: fix unmute-at-end logic The player tried to disable mute before exiting, so that if mute is emulated by setting volume to 0 and the volume setting is a system-global one, we don't leave it at 0. However, the logic doing this at process exit was flawed, as volume settings are handled by audio output instances and the audio output that set the mute state may have been closed earlier. Trying to write reliably working logic that restores volume at exit only would be tricky, so change the code to always unmute an audio driver before closing it and restore mute status if one is opened again later. --- command.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'command.c') diff --git a/command.c b/command.c index e4ce53f87a..d511e52c4a 100644 --- a/command.c +++ b/command.c @@ -719,8 +719,6 @@ static int mp_property_volume(m_option_t *prop, int action, void *arg, return M_PROPERTY_NOT_IMPLEMENTED; } - mpctx->user_muted = 0; - switch (action) { case M_PROPERTY_SET: if (!arg) @@ -757,12 +755,10 @@ static int mp_property_mute(m_option_t *prop, int action, void *arg, if (!arg) return M_PROPERTY_ERROR; mixer_setmute(&mpctx->mixer, *(int *) arg); - mpctx->user_muted = mpctx->mixer.muted; return M_PROPERTY_OK; case M_PROPERTY_STEP_UP: case M_PROPERTY_STEP_DOWN: mixer_setmute(&mpctx->mixer, !mixer_getmute(&mpctx->mixer)); - mpctx->user_muted = mpctx->mixer.muted; return M_PROPERTY_OK; default: return m_property_flag_ro(prop, action, arg, -- cgit v1.2.3