audio: restore volume setting after AO reinit if needed
commit87dad2a4704b2fb0f983d5cb665a065437288d35
authorUoti Urpala <uau@mplayer2.org>
Mon, 9 Apr 2012 18:02:27 +0000 (9 21:02 +0300)
committerUoti Urpala <uau@mplayer2.org>
Wed, 11 Apr 2012 00:50:31 +0000 (11 03:50 +0300)
treee457d371a271e9fd669b4633d41ec7384ef912c3
parent157a6c1e8343cf0d174e6f9edee441bfefebe578
audio: restore volume setting after AO reinit if needed

MPlayer volume control was originally implemented with the assumption
that it controls a system-wide volume setting which keeps its value
even if a process closes and reopens the audio device. However, this
is not actually true for --softvol mode or some audio output APIs that
only consider volume as a per-client setting for software mixing. This
could have annoying results, as the volume would be reset to a default
value if the AO was closed and reopened, for example whem moving to a
new file or crossing ordered chapter boundaries. Add code to set the
previous volume again after audio reinitialization if the current
audio chain is known to behave this way (softvol active or the AO
driver is known to not keep persistent volume externally).

This also avoids an inconsistency with the mute flag. The frontend
assumed the mute status is persistent across file changes, but it
could be similarly lost.

The audio drivers that are assumed to not keep persistent volume are:
coreaudio, dsound, esd, nas, openal, sdl. None of these changes have
been tested. I'm guessing that ESD and NAS do per-connection
non-persistent volume settings.

Partially based on code by wm4.
libao2/ao_coreaudio.c
libao2/ao_dsound.c
libao2/ao_esd.c
libao2/ao_nas.c
libao2/ao_openal.c
libao2/ao_sdl.c
libao2/audio_out.h
mixer.c
mixer.h
mplayer.c