diff options
author | Uoti Urpala <uau@mplayer2.org> | 2012-04-09 17:39:01 +0300 |
---|---|---|
committer | Uoti Urpala <uau@mplayer2.org> | 2012-04-11 00:13:11 +0300 |
commit | 7807f46cd1b8f58ee8f2e5f6d7240d7ca7502311 (patch) | |
tree | 85233d07756f55a756a2f103773b24013cc57955 /command.c | |
parent | 3a01606dc05b2cedb9792a6f8adefeba6e434ab0 (diff) | |
download | mpv-7807f46cd1b8f58ee8f2e5f6d7240d7ca7502311.tar.bz2 mpv-7807f46cd1b8f58ee8f2e5f6d7240d7ca7502311.tar.xz |
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.
Diffstat (limited to 'command.c')
-rw-r--r-- | command.c | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -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)); } } |