summaryrefslogtreecommitdiffstats
path: root/mixer.h
diff options
context:
space:
mode:
authorUoti Urpala <uau@mplayer2.org>2012-04-09 21:02:27 +0300
committerUoti Urpala <uau@mplayer2.org>2012-04-11 03:50:31 +0300
commit87dad2a4704b2fb0f983d5cb665a065437288d35 (patch)
treee457d371a271e9fd669b4633d41ec7384ef912c3 /mixer.h
parent157a6c1e8343cf0d174e6f9edee441bfefebe578 (diff)
downloadmpv-87dad2a4704b2fb0f983d5cb665a065437288d35.tar.bz2
mpv-87dad2a4704b2fb0f983d5cb665a065437288d35.tar.xz
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.
Diffstat (limited to 'mixer.h')
-rw-r--r--mixer.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/mixer.h b/mixer.h
index 0c6d6a91db..fc5b6c1e71 100644
--- a/mixer.h
+++ b/mixer.h
@@ -32,8 +32,12 @@ typedef struct mixer {
float softvol_max;
bool muted;
float vol_l, vol_r;
+ /* Contains ao driver name or "softvol" if volume is not persistent
+ * and needs to be restored after the driver is reinitialized. */
+ const char *restore_volume;
} mixer_t;
+void mixer_reinit(struct mixer *mixer, struct ao *ao);
void mixer_getvolume(mixer_t *mixer, float *l, float *r);
void mixer_setvolume(mixer_t *mixer, float l, float r);
void mixer_incvolume(mixer_t *mixer);