From 75cab315ea3b6bb8858368f5df504dec0e683967 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 4 Oct 2016 13:19:21 +0200 Subject: command: include deprecated/aliased options in property bridge If we really want client API users to use mpv_set_property() instead of mpv_set_option(), then compatibility handling of deprecated options should be included. Otherwise, there's the danger that client API users either break too early (and without a warning), or mpv_set_option() will continue to have a reason to exist. --- player/command.c | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) (limited to 'player/command.c') diff --git a/player/command.c b/player/command.c index b502080ed5..468a1cc901 100644 --- a/player/command.c +++ b/player/command.c @@ -4046,11 +4046,6 @@ static const struct m_property mp_properties_base[] = { // conflicts with option M_PROPERTY_DEPRECATED_ALIAS("audio-format", "audio-codec-name"), - - M_PROPERTY_DEPRECATED_ALIAS("ass-style-override", "sub-ass-style-override"), - M_PROPERTY_DEPRECATED_ALIAS("ass-use-margins", "sub-ass-use-margins"), - M_PROPERTY_DEPRECATED_ALIAS("ass-vsfilter-aspect-compat", - "sub-ass-vsfilter-aspect-compat"), }; // Each entry describes which properties an event (possibly) changes. @@ -5603,26 +5598,41 @@ void command_init(struct MPContext *mpctx) for (int n = 0; n < num_opts; n++) { struct m_config_option *co = m_config_get_co_index(mpctx->mconfig, n); assert(co->name[0]); - if (!co->data || (co->opt->flags & M_OPT_NOPROP) || + if ((co->opt->flags & M_OPT_NOPROP) || (co->opt->type->flags & M_OPT_TYPE_HAS_CHILD)) continue; - struct m_property prop = { - .name = co->name, - .call = mp_property_generic_option, - }; + struct m_property prop = {0}; + + if (co->data) { + prop = (struct m_property){ + .name = co->name, + .call = mp_property_generic_option, + }; - bstr bname = bstr0(prop.name); - if (bstr_eatend0(&bname, "*")) { - prop.name = bstrto0(ctx, bname); - prop.call = mp_property_generic_option_star; + bstr bname = bstr0(prop.name); + if (bstr_eatend0(&bname, "*")) { + 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, + }; } - // The option might be covered by a manual property already. - if (m_property_list_find(ctx->properties, prop.name)) - continue; + if (prop.name) { + // The option might be covered by a manual property already. + if (m_property_list_find(ctx->properties, prop.name)) + continue; - ctx->properties[count++] = prop; + ctx->properties[count++] = prop; + } } } -- cgit v1.2.3