From cf55fa64710bdd5999b437f0cccdb036324ae11e Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 10 Apr 2015 20:40:50 +0200 Subject: player: use config parser for setting up pseudo-gui profile --- options/parse_configfile.c | 4 ++-- options/parse_configfile.h | 3 +++ player/main.c | 16 +++++++--------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/options/parse_configfile.c b/options/parse_configfile.c index b97fd382ed..42e47689db 100644 --- a/options/parse_configfile.c +++ b/options/parse_configfile.c @@ -42,8 +42,8 @@ static bool skip_ws(bstr *s) return s->len; } -static int m_config_parse(m_config_t *config, const char *location, bstr data, - char *initial_section, int flags) +int m_config_parse(m_config_t *config, const char *location, bstr data, + char *initial_section, int flags) { m_profile_t *profile = m_config_add_profile(config, initial_section); void *tmp = talloc_new(NULL); diff --git a/options/parse_configfile.h b/options/parse_configfile.h index 4a42cee001..3cf54b54db 100644 --- a/options/parse_configfile.h +++ b/options/parse_configfile.h @@ -24,4 +24,7 @@ int m_config_parse_config_file(m_config_t* config, const char *conffile, char *initial_section, int flags); +int m_config_parse(m_config_t *config, const char *location, bstr data, + char *initial_section, int flags); + #endif /* MPLAYER_PARSER_CFG_H */ diff --git a/player/main.c b/player/main.c index 2f64c3b67e..c517e871f6 100644 --- a/player/main.c +++ b/player/main.c @@ -99,6 +99,12 @@ const char mp_help_text[] = " --list-options list all mpv options\n" "\n"; +static const char def_config[] = + "[pseudo-gui]\n" + "terminal=no\n" + "force-window=yes\n" + "idle=once\n"; + static pthread_mutex_t terminal_owner_lock = PTHREAD_MUTEX_INITIALIZER; static struct MPContext *terminal_owner; @@ -313,14 +319,6 @@ static int cfg_include(void *ctx, char *filename, int flags) return r; } -static void add_default_profiles(struct m_config *cfg) -{ - struct m_profile *ui = m_config_add_profile(cfg, "pseudo-gui"); - m_config_set_profile_option(cfg, ui, bstr0("terminal"), bstr0("no")); - m_config_set_profile_option(cfg, ui, bstr0("force-window"), bstr0("yes")); - m_config_set_profile_option(cfg, ui, bstr0("idle"), bstr0("once")); -} - struct MPContext *mp_create(void) { mp_time_init(); @@ -354,7 +352,7 @@ struct MPContext *mp_create(void) mpctx->mconfig->includefunc_ctx = mpctx; mpctx->mconfig->use_profiles = true; mpctx->mconfig->is_toplevel = true; - add_default_profiles(mpctx->mconfig); + m_config_parse(mpctx->mconfig, "", bstr0(def_config), NULL, 0); mpctx->global->opts = mpctx->opts; -- cgit v1.2.3