summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-04-10 19:07:26 +0200
committerwm4 <wm4@nowhere>2013-04-10 21:29:04 +0200
commit62daa08d3b9e32f6d7f81bae4407faab4347c90d (patch)
treef2aacda70508d317677c4def60e18eee86271f0d /core
parent2c3e5428c2f1a2811ac138a9167aadcef5c7b26d (diff)
downloadmpv-62daa08d3b9e32f6d7f81bae4407faab4347c90d.tar.bz2
mpv-62daa08d3b9e32f6d7f81bae4407faab4347c90d.tar.xz
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 'core')
-rw-r--r--core/mplayer.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/core/mplayer.c b/core/mplayer.c
index ee1df36654..0a108cb514 100644
--- a/core/mplayer.c
+++ b/core/mplayer.c
@@ -450,6 +450,8 @@ static void uninit_subs(struct demuxer *demuxer)
void uninit_player(struct MPContext *mpctx, unsigned int mask)
{
+ struct MPOpts *opts = &mpctx->opts;
+
mask &= mpctx->initialized_flags;
mp_msg(MSGT_CPLAYER, MSGL_DBG2, "\n*** uninit(0x%X)\n", mask);
@@ -542,8 +544,15 @@ void uninit_player(struct MPContext *mpctx, unsigned int mask)
if (mask & INITIALIZED_AO) {
mpctx->initialized_flags &= ~INITIALIZED_AO;
- if (mpctx->mixer.ao)
+ if (mpctx->mixer.ao) {
+ // Normally the mixer remembers volume, but do it even if the
+ // volume is set explicitly with --volume=...
+ if (opts->mixer_init_volume >= 0 && mpctx->mixer.user_set_volume)
+ mixer_getbothvolume(&mpctx->mixer, &opts->mixer_init_volume);
+ if (opts->mixer_init_mute >= 0 && mpctx->mixer.user_set_mute)
+ opts->mixer_init_mute = mixer_getmute(&mpctx->mixer);
mixer_uninit(&mpctx->mixer);
+ }
if (mpctx->ao)
ao_uninit(mpctx->ao, mpctx->stop_play != AT_END_OF_FILE);
mpctx->ao = NULL;
@@ -4148,9 +4157,6 @@ terminate_playback: // don't jump here after ao/vo/getch initialization!
mp_msg(MSGT_CPLAYER, MSGL_INFO, "\n");
- // xxx handle this as INITIALIZED_CONFIG?
- m_config_leave_file_local(mpctx->mconfig);
-
// time to uninit all, except global stuff:
int uninitialize_parts = INITIALIZED_ALL;
if (opts->fixed_vo)
@@ -4160,6 +4166,9 @@ terminate_playback: // don't jump here after ao/vo/getch initialization!
uninitialize_parts -= INITIALIZED_AO;
uninit_player(mpctx, uninitialize_parts);
+ // xxx handle this as INITIALIZED_CONFIG?
+ m_config_leave_file_local(mpctx->mconfig);
+
mpctx->filename = NULL;
mpctx->file_format = DEMUXER_TYPE_UNKNOWN;
talloc_free(mpctx->resolve_result);