diff options
author | wm4 <wm4@nowhere> | 2013-10-25 22:52:54 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-10-25 22:52:54 +0200 |
commit | ecc0705f83aea409fcd14fbbab10af7b0675d275 (patch) | |
tree | e2fbeb9d09622da889b95896086075e1c73b14a8 /mpvcore/m_config.c | |
parent | d8896f0dba78d05f7ceb50ae9ca5097f384945bd (diff) | |
download | mpv-ecc0705f83aea409fcd14fbbab10af7b0675d275.tar.bz2 mpv-ecc0705f83aea409fcd14fbbab10af7b0675d275.tar.xz |
options: don't let watch_later etc. overwite command line options
There are certain cases where mpv will automatically set options, such
as per-file configs, per protocol/VO/AO/extension profiles, and
watch_later resume configs. All these were overwriting the user's
options, even when they were specified on command line.
Add something that explicitly preserves command line options. This
means you can now actually use the command line to override any
options that the playback resume functionality backups and restores.
It still happily overrides options set at runtime (e.g. changed via
properties while playing a file; then playing the next file might
override them again), but maybe that's not a problem with typical use.
Diffstat (limited to 'mpvcore/m_config.c')
-rw-r--r-- | mpvcore/m_config.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/mpvcore/m_config.c b/mpvcore/m_config.c index 810dceba44..463fc8e6f7 100644 --- a/mpvcore/m_config.c +++ b/mpvcore/m_config.c @@ -495,6 +495,9 @@ static int m_config_parse_option(struct m_config *config, struct bstr name, if ((flags & M_SETOPT_PRE_PARSE_ONLY) && !(co->opt->flags & M_OPT_PRE_PARSE)) return 0; + if ((flags & M_SETOPT_PRESERVE_CMDLINE) && co->is_set_from_cmdline) + set = false; + // Check if this option isn't forbidden in the current mode if ((flags & M_SETOPT_FROM_CONFIG_FILE) && (co->opt->flags & M_OPT_NOCFG)) { mp_tmsg(MSGT_CFGPARSER, MSGL_ERR, @@ -530,7 +533,21 @@ static int m_config_parse_option(struct m_config *config, struct bstr name, return parse_subopts(config, (char *)co->name, prefix, param, flags); } - return m_option_parse(co->opt, name, param, set ? co->data : NULL); + int r = m_option_parse(co->opt, name, param, set ? co->data : NULL); + + if (r >= 0 && set && (flags & M_SETOPT_FROM_CMDLINE)) { + co->is_set_from_cmdline = true; + // Mark aliases too + if (co->data) { + for (int n = 0; n < config->num_opts; n++) { + struct m_config_option *co2 = &config->opts[n]; + if (co2->data == co->data) + co2->is_set_from_cmdline = true; + } + } + } + + return r; } static int parse_subopts(struct m_config *config, char *name, char *prefix, |