From 6ab013cbdd9d627f7cdd5eb1eca8df0da112b929 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 18 Dec 2019 07:50:08 +0100 Subject: command: make change-list work with pure properties too Until now, it only worked on options. Useful for the next commit. --- player/command.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/player/command.c b/player/command.c index 21d62f965c..8576e36da7 100644 --- a/player/command.c +++ b/player/command.c @@ -4473,14 +4473,14 @@ static void cmd_change_list(void *p) int osd_duration = mpctx->opts->osd_duration; int osdl = cmd->msg_osd ? 1 : OSD_LEVEL_INVISIBLE; - struct m_config_option *co = m_config_get_co(mpctx->mconfig, bstr0(name)); - if (!co) { + struct m_option prop = {0}; + if (mp_property_do(name, M_PROPERTY_GET_TYPE, &prop, mpctx) <= 0) { set_osd_msg(mpctx, osdl, osd_duration, "Unknown option: '%s'", name); cmd->success = false; return; } - const struct m_option_type *type = co->opt->type; + const struct m_option_type *type = prop.type; bool found = false; for (int i = 0; type->actions && type->actions[i].name; i++) { const struct m_option_action *action = &type->actions[i]; @@ -4493,9 +4493,18 @@ static void cmd_change_list(void *p) return; } + union m_option_value val = {0}; + if (mp_property_do(name, M_PROPERTY_GET, &val, mpctx) <= 0) { + set_osd_msg(mpctx, osdl, osd_duration, "Could not read: '%s'", name); + cmd->success = false; + return; + } + char *optname = mp_tprintf(80, "%s-%s", name, op); // the dirty truth - int r = m_config_set_option_cli(mpctx->mconfig, bstr0(optname), - bstr0(value), 0); + int r = m_option_parse(mpctx->log, &prop, bstr0(optname), bstr0(value), &val); + if (r >= 0 && mp_property_do(name, M_PROPERTY_SET, &val, mpctx) <= 0) + r = -1; + m_option_free(&prop, &val); if (r < 0) { set_osd_msg(mpctx, osdl, osd_duration, "Failed setting option: '%s'", name); -- cgit v1.2.3