diff options
-rw-r--r-- | DOCS/man/en/options.rst | 24 | ||||
-rw-r--r-- | core/cfg-mplayer.h | 1 | ||||
-rw-r--r-- | core/m_config.c | 16 | ||||
-rw-r--r-- | core/m_config.h | 2 | ||||
-rw-r--r-- | core/mplayer.c | 11 | ||||
-rw-r--r-- | core/options.h | 2 |
6 files changed, 56 insertions, 0 deletions
diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst index b99c2428fb..fab682fdd5 100644 --- a/DOCS/man/en/options.rst +++ b/DOCS/man/en/options.rst @@ -1739,6 +1739,30 @@ --referrer=<string> Specify a referrer path or URL for HTTP requests. +--reset-on-next-file=<all|option1,option2,...> + Normally, mpv will try to keep all settings when playing the next file on + the playlist, even if they were changed by the user during playback. (This + behavior is the opposite of MPlayer's, which tries to reset all settings + when starting next file.) + + This can be changed with this option. It accepts a list of options, and + mpv will reset the value of these options on playback start to the initial + value. The initial value is either the default value, or as set by the + config file or command line. + + In some cases, this might not work as expected. For example, ``--volume`` + will only be reset the volume if it's explicitly set in the config file + or the command line. + + The special name ``all`` resets as many options as possible. + + *EXAMPLE*: + + - ``--reset-on-next-file=fullscreen,speed`` Reset fullscreen and playback + speed settings if they were changed during playback. + - ``--reset-on-next-file=all`` Try to reset all settings that were changed + during playback. + --reuse-socket (udp:// only) Allows a socket to be reused by other processes as soon as it is closed. diff --git a/core/cfg-mplayer.h b/core/cfg-mplayer.h index dd99e6c4bd..8e0563e380 100644 --- a/core/cfg-mplayer.h +++ b/core/cfg-mplayer.h @@ -297,6 +297,7 @@ const m_option_t common_opts[] = { {"priority", &proc_priority, CONF_TYPE_STRING, 0, 0, 0, NULL}, #endif OPT_FLAG("config", load_config, CONF_GLOBAL | CONF_NOCFG | CONF_PRE_PARSE), + OPT_STRINGLIST("reset-on-next-file", reset_options, CONF_GLOBAL), // ------------------------- stream options -------------------- diff --git a/core/m_config.c b/core/m_config.c index b6c15d3d9a..65d60bdab9 100644 --- a/core/m_config.c +++ b/core/m_config.c @@ -258,6 +258,22 @@ void m_config_leave_file_local(struct m_config *config) } } +void m_config_mark_file_local(struct m_config *config, const char *opt) +{ + struct m_config_option *co = m_config_get_co(config, bstr0(opt)); + if (co) { + ensure_backup(config, co); + } else { + mp_tmsg(MSGT_CFGPARSER, MSGL_ERR, "Option %s not found.\n", opt); + } +} + +void m_config_mark_all_file_local(struct m_config *config) +{ + for (struct m_config_option *co = config->opts; co; co = co->next) + ensure_backup(config, co); +} + // Given an option --opt, add --no-opt (if applicable). static void add_negation_option(struct m_config *config, struct m_config_option *parent, diff --git a/core/m_config.h b/core/m_config.h index 345141a72a..98b21c9bf9 100644 --- a/core/m_config.h +++ b/core/m_config.h @@ -97,6 +97,8 @@ void m_config_free(struct m_config *config); void m_config_enter_file_local(struct m_config *config); void m_config_leave_file_local(struct m_config *config); +void m_config_mark_file_local(struct m_config *config, const char *opt); +void m_config_mark_all_file_local(struct m_config *config); /* Register some options to be used. * \param config The config object. diff --git a/core/mplayer.c b/core/mplayer.c index 0a108cb514..7dbd4f59bb 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -3877,6 +3877,17 @@ static void play_current_file(struct MPContext *mpctx) load_per_file_options(mpctx->mconfig, mpctx->playlist->current->params, mpctx->playlist->current->num_params); + if (opts->reset_options) { + for (int n = 0; opts->reset_options[n]; n++) { + const char *opt = opts->reset_options[n]; + if (strcmp(opt, "all") == 0) { + m_config_mark_all_file_local(mpctx->mconfig); + } else { + m_config_mark_file_local(mpctx->mconfig, opt); + } + } + } + // We must enable getch2 here to be able to interrupt network connection // or cache filling if (opts->consolecontrols && !opts->slave_mode) { diff --git a/core/options.h b/core/options.h index 080ca021d7..0f57381f30 100644 --- a/core/options.h +++ b/core/options.h @@ -43,6 +43,8 @@ typedef struct mp_vo_opts { } mp_vo_opts; typedef struct MPOpts { + char **reset_options; + char **audio_driver_list; int fixed_vo; char *mixer_device; |