summaryrefslogtreecommitdiffstats
path: root/options/m_property.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-04-15 11:31:24 +0200
committerwm4 <wm4@nowhere>2016-04-15 11:32:40 +0200
commita9bd4535d2eac283824d8598aa17f1f44f83a74a (patch)
tree808f3b0b6034f5fe74fbcaa103164520cbe4a6a6 /options/m_property.c
parent8c02c92ab962107ee43c71854bd9712cc492046e (diff)
downloadmpv-a9bd4535d2eac283824d8598aa17f1f44f83a74a.tar.bz2
mpv-a9bd4535d2eac283824d8598aa17f1f44f83a74a.tar.xz
client API: improve mpv_set_property() handling of MPV_FORMAT_NODE
If a mpv_node wrapped a string, the behavior was different from calling mpv_set_property() with MPV_FORMAT_STRING directly. Change this. The original intention was to be strict about types if MPV_FORMAT_NODE is used. But I think the result was less than ideal, and the same change towards less strict behavior was made to mpv_set_option() ages ago.
Diffstat (limited to 'options/m_property.c')
-rw-r--r--options/m_property.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/options/m_property.c b/options/m_property.c
index 951b788d4b..de2361b868 100644
--- a/options/m_property.c
+++ b/options/m_property.c
@@ -104,16 +104,8 @@ int m_property_do(struct mp_log *log, const struct m_property *prop_list,
return str != NULL;
}
case M_PROPERTY_SET_STRING: {
- if (!log)
- return M_PROPERTY_ERROR;
- bstr optname = bstr0(name), a, b;
- if (bstr_split_tok(optname, "/", &a, &b))
- optname = b;
- if (m_option_parse(log, &opt, optname, bstr0(arg), &val) < 0)
- return M_PROPERTY_ERROR;
- r = do_action(prop_list, name, M_PROPERTY_SET, &val, ctx);
- m_option_free(&opt, &val);
- return r;
+ struct mpv_node node = { .format = MPV_FORMAT_STRING, .u.string = arg };
+ return do_action(prop_list, name, M_PROPERTY_SET_NODE, &node, ctx);
}
case M_PROPERTY_SWITCH: {
if (!log)
@@ -163,11 +155,12 @@ int m_property_do(struct mp_log *log, const struct m_property *prop_list,
return r;
}
case M_PROPERTY_SET_NODE: {
+ if (!log)
+ return M_PROPERTY_ERROR;
if ((r = do_action(prop_list, name, M_PROPERTY_SET_NODE, arg, ctx)) !=
M_PROPERTY_NOT_IMPLEMENTED)
return r;
- struct mpv_node *node = arg;
- int err = m_option_set_node(&opt, &val, node);
+ int err = m_option_set_node_or_string(log, &opt, name, &val, arg);
if (err == M_OPT_UNKNOWN) {
r = M_PROPERTY_NOT_IMPLEMENTED;
} else if (err < 0) {