path: root/audio
diff options
authorwm4 <wm4@nowhere>2013-04-10 19:07:26 +0200
committerwm4 <wm4@nowhere>2013-04-10 21:29:04 +0200
commit62daa08d3b9e32f6d7f81bae4407faab4347c90d (patch)
treef2aacda70508d317677c4def60e18eee86271f0d /audio
parent2c3e5428c2f1a2811ac138a9167aadcef5c7b26d (diff)
mplayer: keep volume persistent, even when using --volume
Consider: mpv --volume 10 file1.mkv file2.mkv Before this commit, the volume was reset to 10 when playing file2.mkv. This was inconsistent to most other options. E.g. --brightness is a rather similar case. In general, settings should never be reset when playing the next file, unless the option was explicitly marked file-local. This commit corrects the behavior of the --volume and --mute options. File local --volume still works as expected: mpv --{ --volume 10 file1.mkv file2.mkv --} This sets the volume always to 10 on playback start. Move the m_config_leave_file_local() call down so that the mixer code in uninit_player() can set the option volume and mute variables without overwriting the global option values. Another subtle issue is that we don't want to set volume if there's no need to, which is why the user_set_volume/mute fields are introduced. This is important because setting the volume might change the system volume depending on other options.
Diffstat (limited to 'audio')
2 files changed, 6 insertions, 0 deletions
diff --git a/audio/mixer.c b/audio/mixer.c
index d97391cf7e..b67e548a3c 100644
--- a/audio/mixer.c
+++ b/audio/mixer.c
@@ -130,6 +130,7 @@ void mixer_setvolume(mixer_t *mixer, float l, float r)
if (!mixer->ao || mixer->muted_using_volume)
setvolume_internal(mixer, mixer->vol_l, mixer->vol_r);
+ mixer->user_set_volume = true;
void mixer_getbothvolume(mixer_t *mixer, float *b)
@@ -152,6 +153,7 @@ void mixer_setmute(struct mixer *mixer, bool mute)
mixer->muted = mute;
mixer->muted_by_us = mute;
+ mixer->user_set_mute = true;
@@ -264,6 +266,8 @@ void mixer_reinit(struct mixer *mixer, struct ao *ao)
mixer_setmute(mixer, true);
if (mixer->balance != 0)
mixer_setbalance(mixer, mixer->balance);
+ mixer->user_set_mute = false;
+ mixer->user_set_volume = false;
/* Called before uninitializing the audio output. The main purpose is to
diff --git a/audio/mixer.h b/audio/mixer.h
index 3de92e1e03..3160c20cfe 100644
--- a/audio/mixer.h
+++ b/audio/mixer.h
@@ -41,6 +41,8 @@ typedef struct mixer {
* and needs to be restored after the driver is reinitialized. */
const char *restore_volume;
float balance;
+ bool user_set_mute;
+ bool user_set_volume;
} mixer_t;
void mixer_reinit(struct mixer *mixer, struct ao *ao);