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 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'player/command.c') 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); -- cgit v1.2.3