From ffcf4ece6e69764dde0ee6a4e796e97151259cd9 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 22 Dec 2013 23:08:31 +0100 Subject: player: move code around The only thing that used mp_load_per_file_config() was inside configfiles.c too, so remove the declaration from core.h and move the function before its use. --- player/configfiles.c | 78 +++++++++++++++++++++++++--------------------------- player/core.h | 1 - 2 files changed, 37 insertions(+), 42 deletions(-) diff --git a/player/configfiles.c b/player/configfiles.c index 04dc631701..b3804c0bd0 100644 --- a/player/configfiles.c +++ b/player/configfiles.c @@ -72,46 +72,6 @@ bool mp_parse_cfgfiles(struct MPContext *mpctx) return true; } -// Set options file-local, and don't set them if the user set them via the -// command line. -#define FILE_LOCAL_FLAGS (M_SETOPT_BACKUP | M_SETOPT_PRESERVE_CMDLINE) - -static void mp_auto_load_profile(struct MPContext *mpctx, char *category, - bstr item) -{ - if (!item.len) - return; - - char t[512]; - snprintf(t, sizeof(t), "%s.%.*s", category, BSTR_P(item)); - m_profile_t *p = m_config_get_profile0(mpctx->mconfig, t); - if (p) { - MP_INFO(mpctx, "Auto-loading profile '%s'\n", t); - m_config_set_profile(mpctx->mconfig, p, FILE_LOCAL_FLAGS); - } -} - -void mp_load_auto_profiles(struct MPContext *mpctx) -{ - struct MPOpts *opts = mpctx->opts; - - mp_auto_load_profile(mpctx, "protocol", - mp_split_proto(bstr0(mpctx->filename), NULL)); - mp_auto_load_profile(mpctx, "extension", - bstr0(mp_splitext(mpctx->filename, NULL))); - - mp_load_per_file_config(mpctx); - - if (opts->vo.video_driver_list) - mp_auto_load_profile(mpctx, "vo", bstr0(opts->vo.video_driver_list[0].name)); - if (opts->audio_driver_list) - mp_auto_load_profile(mpctx, "ao", bstr0(opts->audio_driver_list[0].name)); -} - -/** - * Tries to load a config file (in file local mode) - * @return 0 if file was not found, 1 otherwise - */ static int try_load_config(struct MPContext *mpctx, const char *file, int flags) { if (!mp_path_exists(file)) @@ -121,7 +81,11 @@ static int try_load_config(struct MPContext *mpctx, const char *file, int flags) return 1; } -void mp_load_per_file_config(struct MPContext *mpctx) +// Set options file-local, and don't set them if the user set them via the +// command line. +#define FILE_LOCAL_FLAGS (M_SETOPT_BACKUP | M_SETOPT_PRESERVE_CMDLINE) + +static void mp_load_per_file_config(struct MPContext *mpctx) { struct MPOpts *opts = mpctx->opts; char *confpath; @@ -154,6 +118,38 @@ void mp_load_per_file_config(struct MPContext *mpctx) } } +static void mp_auto_load_profile(struct MPContext *mpctx, char *category, + bstr item) +{ + if (!item.len) + return; + + char t[512]; + snprintf(t, sizeof(t), "%s.%.*s", category, BSTR_P(item)); + m_profile_t *p = m_config_get_profile0(mpctx->mconfig, t); + if (p) { + MP_INFO(mpctx, "Auto-loading profile '%s'\n", t); + m_config_set_profile(mpctx->mconfig, p, FILE_LOCAL_FLAGS); + } +} + +void mp_load_auto_profiles(struct MPContext *mpctx) +{ + struct MPOpts *opts = mpctx->opts; + + mp_auto_load_profile(mpctx, "protocol", + mp_split_proto(bstr0(mpctx->filename), NULL)); + mp_auto_load_profile(mpctx, "extension", + bstr0(mp_splitext(mpctx->filename, NULL))); + + mp_load_per_file_config(mpctx); + + if (opts->vo.video_driver_list) + mp_auto_load_profile(mpctx, "vo", bstr0(opts->vo.video_driver_list[0].name)); + if (opts->audio_driver_list) + mp_auto_load_profile(mpctx, "ao", bstr0(opts->audio_driver_list[0].name)); +} + #define MP_WATCH_LATER_CONF "watch_later" static char *mp_get_playback_resume_config_filename(struct mpv_global *global, diff --git a/player/core.h b/player/core.h index 711c99840b..5b4cc738e5 100644 --- a/player/core.h +++ b/player/core.h @@ -350,7 +350,6 @@ void clear_audio_decode_buffers(struct MPContext *mpctx); // configfiles.c bool mp_parse_cfgfiles(struct MPContext *mpctx); void mp_load_auto_profiles(struct MPContext *mpctx); -void mp_load_per_file_config(struct MPContext *mpctx); void mp_load_playback_resume(struct MPContext *mpctx, const char *file); void mp_write_watch_later_conf(struct MPContext *mpctx); struct playlist_entry *mp_check_playlist_resume(struct MPContext *mpctx, -- cgit v1.2.3