From b8193e40719a2a72d9b25e8ea3070c0e84beb48e Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 15 Jun 2017 15:22:06 +0200 Subject: command: add all options to property->option bridge Before this, options with co->data==NULL (i.e. no storage) were not added to the bridge (except alias options). There are a few options which might make sense to allow via the bridge ("profile" and "include"). So allow them. In command_init(), we merely remove the co->data check, the rest of the diff is due to switching the if/else branches for convenience. We also must explicitly error on M_PROPERTY_GET if co->data==NULL. All other cases check it in some way. Explicitly exclude options from the property bridge, which would be added due this, and the result would be pointless. --- player/command.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'player/command.c') diff --git a/player/command.c b/player/command.c index af7d4006d7..cdef20d7a3 100644 --- a/player/command.c +++ b/player/command.c @@ -402,14 +402,14 @@ static int mp_property_generic_option(void *ctx, struct m_property *prop, if (!opt) return M_PROPERTY_UNKNOWN; - void *valptr = opt->data; - switch (action) { case M_PROPERTY_GET_TYPE: *(struct m_option *)arg = *(opt->opt); return M_PROPERTY_OK; case M_PROPERTY_GET: - m_option_copy(opt->opt, arg, valptr); + if (!opt->data) + return M_PROPERTY_NOT_IMPLEMENTED; + m_option_copy(opt->opt, arg, opt->data); return M_PROPERTY_OK; case M_PROPERTY_SET: if (m_config_set_option_raw_direct(mpctx->mconfig, opt, arg, flags) < 0) @@ -5672,7 +5672,16 @@ void command_init(struct MPContext *mpctx) struct m_property prop = {0}; - if (co->data) { + if (co->opt->type == &m_option_type_alias) { + const char *alias = (const char *)co->opt->priv; + + prop = (struct m_property){ + .name = co->name, + .call = co->opt->deprecation_message ? + mp_property_deprecated_alias : mp_property_alias, + .priv = (void *)alias, + }; + } else { prop = (struct m_property){ .name = co->name, .call = mp_property_generic_option, @@ -5683,15 +5692,6 @@ void command_init(struct MPContext *mpctx) prop.name = bstrto0(ctx, bname); prop.call = mp_property_generic_option_star; } - } else if (co->opt->type == &m_option_type_alias) { - const char *alias = (const char *)co->opt->priv; - - prop = (struct m_property){ - .name = co->name, - .call = co->opt->deprecation_message ? - mp_property_deprecated_alias : mp_property_alias, - .priv = (void *)alias, - }; } if (prop.name) { -- cgit v1.2.3