From d1c563c0a9f24e8ed661c29a8718f7fde162a4ff Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 2 Aug 2013 17:59:43 +0200 Subject: options: don't make options set during playback file local (e.g. --vf) Refactor file local options handling: instead of making all options implicitly file local between loading a file and terminating playback, explicitly make options file local which are required to be file local. Or in other words, introduce a M_SETOPT_BACKUP flag, which forces file local-ness when setting an option, and use this for file local command line options, per-file config files, and per-protocol/extension/vo/ao profiles. In particular, this changes the "vf" input command such that video filters stay permanent even when going to the next file in the playlist. The underlying reason for this is that the "vf" command uses the option setting command. This influences the "af" command as well. --- core/mplayer.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'core/mplayer.c') diff --git a/core/mplayer.c b/core/mplayer.c index 2092a04f70..31b1e88efa 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -634,9 +634,9 @@ static void mk_config_dir(char *subdir) talloc_free(tmp); } -static int cfg_include(struct m_config *conf, char *filename) +static int cfg_include(struct m_config *conf, char *filename, int flags) { - return m_config_parse_config_file(conf, filename); + return m_config_parse_config_file(conf, filename, flags); } #define DEF_CONFIG "# Write your default config options here!\n\n\n" @@ -648,7 +648,7 @@ static bool parse_cfgfiles(struct MPContext *mpctx, m_config_t *conf) int conffile_fd; if (!opts->load_config) return true; - if (!m_config_parse_config_file(conf, MPLAYER_CONFDIR "/mpv.conf") < 0) + if (!m_config_parse_config_file(conf, MPLAYER_CONFDIR "/mpv.conf", 0) < 0) return false; mk_config_dir(NULL); if ((conffile = mp_find_user_config_file("config")) == NULL) @@ -662,7 +662,7 @@ static bool parse_cfgfiles(struct MPContext *mpctx, m_config_t *conf) write(conffile_fd, DEF_CONFIG, sizeof(DEF_CONFIG) - 1); close(conffile_fd); } - if (m_config_parse_config_file(conf, conffile) < 0) + if (m_config_parse_config_file(conf, conffile, 0) < 0) return false; talloc_free(conffile); } @@ -688,7 +688,7 @@ static void load_per_protocol_config(m_config_t *conf, const char * const file) if (p) { mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Loading protocol-related profile '%s'\n", protocol); - m_config_set_profile(conf, p); + m_config_set_profile(conf, p, M_SETOPT_BACKUP); } } @@ -711,7 +711,7 @@ static void load_per_extension_config(m_config_t *conf, const char * const file) if (p) { mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Loading extension-related profile '%s'\n", extension); - m_config_set_profile(conf, p); + m_config_set_profile(conf, p, M_SETOPT_BACKUP); } } @@ -731,12 +731,12 @@ static void load_per_output_config(m_config_t *conf, char *cfg, char *out) if (p) { mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Loading extension-related profile '%s'\n", profile); - m_config_set_profile(conf, p); + m_config_set_profile(conf, p, M_SETOPT_BACKUP); } } /** - * Tries to load a config file + * Tries to load a config file (in file local mode) * @return 0 if file was not found, 1 otherwise */ static int try_load_config(m_config_t *conf, const char *file) @@ -744,7 +744,7 @@ static int try_load_config(m_config_t *conf, const char *file) if (!mp_path_exists(file)) return 0; mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Loading config '%s'\n", file); - m_config_parse_config_file(conf, file); + m_config_parse_config_file(conf, file, M_SETOPT_BACKUP); return 1; } @@ -899,8 +899,10 @@ static void load_per_file_options(m_config_t *conf, struct playlist_param *params, int params_count) { - for (int n = 0; n < params_count; n++) - m_config_set_option(conf, params[n].name, params[n].value); + for (int n = 0; n < params_count; n++) { + m_config_set_option_ext(conf, params[n].name, params[n].value, + M_SETOPT_BACKUP); + } } /* When demux performs a blocking operation (network connection or @@ -4147,8 +4149,6 @@ static void play_current_file(struct MPContext *mpctx) mpctx->add_osd_seek_info &= OSD_SEEK_INFO_EDITION; - m_config_enter_file_local(mpctx->mconfig); - load_per_protocol_config(mpctx->mconfig, mpctx->filename); load_per_extension_config(mpctx->mconfig, mpctx->filename); load_per_file_config(mpctx->mconfig, mpctx->filename, opts->use_filedir_conf); @@ -4170,9 +4170,9 @@ static void play_current_file(struct MPContext *mpctx) 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); + m_config_backup_all_opts(mpctx->mconfig); } else { - m_config_mark_file_local(mpctx->mconfig, opt); + m_config_backup_opt(mpctx->mconfig, opt); } } } @@ -4445,7 +4445,7 @@ terminate_playback: // don't jump here after ao/vo/getch initialization! uninit_player(mpctx, uninitialize_parts); // xxx handle this as INITIALIZED_CONFIG? - m_config_leave_file_local(mpctx->mconfig); + m_config_restore_backups(mpctx->mconfig); mpctx->filename = NULL; talloc_free(mpctx->resolve_result); -- cgit v1.2.3