From 6fe83fdc339aad0b5ddadbe55d25c57bc490640e Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 22 Sep 2016 20:35:38 +0200 Subject: player: some M_SETOPT_RUNTIME cleanups Add this flag where needed. You shouldn't be able to set e.g. config-dir in these situations. Remove the mpctx->initialized check from the property/option bridge, since it's in use strictly only after initialization. Likewise, the apply-profile command doesn't need to check this. --- player/command.c | 25 ++++++------------------- player/configfiles.c | 3 ++- player/loadfile.c | 2 +- 3 files changed, 9 insertions(+), 21 deletions(-) (limited to 'player') diff --git a/player/command.c b/player/command.c index 4bb26303b1..fc40740b16 100644 --- a/player/command.c +++ b/player/command.c @@ -331,12 +331,12 @@ direct_option: } // Property-option bridge. (Maps the property to the option with the same name.) -static int mp_property_generic_option_do(void *ctx, struct m_property *prop, - int action, void *arg, bool force) +static int mp_property_generic_option(void *ctx, struct m_property *prop, + int action, void *arg) { MPContext *mpctx = ctx; const char *optname = prop->name; - int flags = mpctx->initialized && !force ? M_SETOPT_RUNTIME : 0; + int flags = M_SETOPT_RUNTIME; struct m_config_option *opt = m_config_get_co(mpctx->mconfig, bstr0(optname)); @@ -360,18 +360,6 @@ static int mp_property_generic_option_do(void *ctx, struct m_property *prop, return M_PROPERTY_NOT_IMPLEMENTED; } -static int mp_property_generic_option(void *ctx, struct m_property *prop, - int action, void *arg) -{ - return mp_property_generic_option_do(ctx, prop, action, arg, true); -} - -static int mp_property_generic_option_bridge(void *ctx, struct m_property *prop, - int action, void *arg) -{ - return mp_property_generic_option_do(ctx, prop, action, arg, false); -} - // Dumb special-case: the option name ends in a "*". static int mp_property_generic_option_star(void *ctx, struct m_property *prop, int action, void *arg) @@ -380,7 +368,7 @@ static int mp_property_generic_option_star(void *ctx, struct m_property *prop, char name[80]; snprintf(name, sizeof(name), "%s*", prop->name); prop2.name = name; - return mp_property_generic_option_bridge(ctx, &prop2, action, arg); + return mp_property_generic_option(ctx, &prop2, action, arg); } /// Playback speed (RW) @@ -5478,8 +5466,7 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re case MP_CMD_APPLY_PROFILE: { char *profile = cmd->args[0].v.s; - int flags = mpctx->initialized ? M_SETOPT_RUNTIME : 0; - if (m_config_set_profile(mpctx->mconfig, profile, flags) < 0) + if (m_config_set_profile(mpctx->mconfig, profile, M_SETOPT_RUNTIME) < 0) return -1; break; } @@ -5523,7 +5510,7 @@ void command_init(struct MPContext *mpctx) struct m_property prop = { .name = co->name, - .call = mp_property_generic_option_bridge, + .call = mp_property_generic_option, }; bstr bname = bstr0(prop.name); diff --git a/player/configfiles.c b/player/configfiles.c index 95eb91c377..3ab0d368bc 100644 --- a/player/configfiles.c +++ b/player/configfiles.c @@ -92,7 +92,8 @@ static int try_load_config(struct MPContext *mpctx, const char *file, int flags) // 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) +#define FILE_LOCAL_FLAGS \ + (M_SETOPT_BACKUP | M_SETOPT_RUNTIME | M_SETOPT_PRESERVE_CMDLINE) static void mp_load_per_file_config(struct MPContext *mpctx) { diff --git a/player/loadfile.c b/player/loadfile.c index 9fdd38127f..ba0e0bd257 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -770,7 +770,7 @@ static void load_per_file_options(m_config_t *conf, { for (int n = 0; n < params_count; n++) { m_config_set_option_ext(conf, params[n].name, params[n].value, - M_SETOPT_BACKUP); + M_SETOPT_RUNTIME | M_SETOPT_BACKUP); } } -- cgit v1.2.3