summaryrefslogtreecommitdiffstats
path: root/libao2
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 /libao2
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 'libao2')
-rw-r--r--libao2/ao_coreaudio.c2
-rw-r--r--libao2/ao_dsound.c2
-rw-r--r--libao2/ao_esd.c2
-rw-r--r--libao2/ao_nas.c2
-rw-r--r--libao2/ao_openal.c1
-rw-r--r--libao2/ao_sdl.c2
-rw-r--r--libao2/audio_out.h1
7 files changed, 12 insertions, 0 deletions
diff --git a/libao2/ao_coreaudio.c b/libao2/ao_coreaudio.c
index 34374f4c9c..50e943e9ac 100644
--- a/libao2/ao_coreaudio.c
+++ b/libao2/ao_coreaudio.c
@@ -450,6 +450,8 @@ int device_id, display_help = 0;
ao->b_revert = 0;
ao->b_changed_mixing = 0;
+ global_ao->no_persistent_volume = true;
+
if (device_id == 0) {
/* Find the ID of the default Device. */
err = GetAudioProperty(kAudioObjectSystemObject,
diff --git a/libao2/ao_dsound.c b/libao2/ao_dsound.c
index 63cc02e92c..b33f2949fd 100644
--- a/libao2/ao_dsound.c
+++ b/libao2/ao_dsound.c
@@ -420,6 +420,8 @@ static int init(int rate, int channels, int format, int flags)
int res;
if (!InitDirectSound()) return 0;
+ global_ao->no_persistent_volume = true;
+
// ok, now create the buffers
WAVEFORMATEXTENSIBLE wformat;
DSBUFFERDESC dsbpridesc;
diff --git a/libao2/ao_esd.c b/libao2/ao_esd.c
index d5423991bd..e7c6701aa0 100644
--- a/libao2/ao_esd.c
+++ b/libao2/ao_esd.c
@@ -164,6 +164,8 @@ static int init(int rate_hz, int channels, int format, int flags)
float lag_seconds, lag_net = 0., lag_serv;
struct timeval proto_start, proto_end;
+ global_ao->no_persistent_volume = true;
+
if (esd_fd < 0) {
esd_fd = esd_open_sound(server);
if (esd_fd < 0) {
diff --git a/libao2/ao_nas.c b/libao2/ao_nas.c
index fb49c5e60e..d3274df9a5 100644
--- a/libao2/ao_nas.c
+++ b/libao2/ao_nas.c
@@ -424,6 +424,8 @@ static int init(int rate,int channels,int format,int flags)
(void)flags; /* shut up 'unused parameter' warning */
+ global_ao->no_persistent_volume = true;
+
nas_data=malloc(sizeof(struct ao_nas_data));
memset(nas_data, 0, sizeof(struct ao_nas_data));
diff --git a/libao2/ao_openal.c b/libao2/ao_openal.c
index e425b5769c..490aac0eb8 100644
--- a/libao2/ao_openal.c
+++ b/libao2/ao_openal.c
@@ -108,6 +108,7 @@ static int init(int rate, int channels, int format, int flags) {
const opt_t subopts[] = {
{NULL}
};
+ global_ao->no_persistent_volume = true;
if (subopt_parse(ao_subdevice, subopts) != 0) {
print_help();
return 0;
diff --git a/libao2/ao_sdl.c b/libao2/ao_sdl.c
index e9ae7298d5..6ff8b83cb3 100644
--- a/libao2/ao_sdl.c
+++ b/libao2/ao_sdl.c
@@ -135,6 +135,8 @@ static int init(int rate,int channels,int format,int flags){
/* SDL Audio Specifications */
SDL_AudioSpec aspec, obtained;
+ global_ao->no_persistent_volume = true;
+
/* Allocate ring-buffer memory */
buffer = av_fifo_alloc(BUFFSIZE);
diff --git a/libao2/audio_out.h b/libao2/audio_out.h
index 2e59c42aa4..5a9d52def3 100644
--- a/libao2/audio_out.h
+++ b/libao2/audio_out.h
@@ -99,6 +99,7 @@ struct ao {
int buffer_playable_size;
bool initialized;
bool untimed;
+ bool no_persistent_volume;
const struct ao_driver *driver;
void *priv;
struct MPOpts *opts;