summaryrefslogtreecommitdiffstats
path: root/player
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 /player
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 'player')
-rw-r--r--player/client.c52
1 files changed, 18 insertions, 34 deletions
diff --git a/player/client.c b/player/client.c
index d3b0567a97..6b5eaf7883 100644
--- a/player/client.c
+++ b/player/client.c
@@ -1071,44 +1071,28 @@ static void setproperty_fn(void *arg)
struct setproperty_request *req = arg;
const struct m_option *type = get_mp_type(req->format);
- int err;
- switch (req->format) {
- case MPV_FORMAT_STRING: {
- // Go through explicit string conversion. M_PROPERTY_SET_NODE doesn't
- // do this, because it tries to be somewhat type-strict. But the client
- // needs a way to set everything by string.
- char *s = *(char **)req->data;
- MP_VERBOSE(req->mpctx, "Set property string: %s='%s'\n", req->name, s);
- err = mp_property_do(req->name, M_PROPERTY_SET_STRING, s, req->mpctx);
- break;
- }
- case MPV_FORMAT_NODE:
- case MPV_FORMAT_FLAG:
- case MPV_FORMAT_INT64:
- case MPV_FORMAT_DOUBLE: {
- struct mpv_node node;
- if (req->format == MPV_FORMAT_NODE) {
- node = *(struct mpv_node *)req->data;
- } else {
- // These are basically emulated via mpv_node.
- node.format = req->format;
- memcpy(&node.u, req->data, type->type->size);
- }
- if (mp_msg_test(req->mpctx->log, MSGL_V)) {
- struct m_option ot = {.type = &m_option_type_node};
- char *t = m_option_print(&ot, &node);
- MP_VERBOSE(req->mpctx, "Set property: %s=%s\n", req->name, t ? t : "?");
- talloc_free(t);
- }
- err = mp_property_do(req->name, M_PROPERTY_SET_NODE, &node, req->mpctx);
- break;
- }
- default:
- abort();
+ struct mpv_node *node;
+ struct mpv_node tmp;
+ if (req->format == MPV_FORMAT_NODE) {
+ node = req->data;
+ } else {
+ tmp.format = req->format;
+ memcpy(&tmp.u, req->data, type->type->size);
+ node = &tmp;
}
+ int err = mp_property_do(req->name, M_PROPERTY_SET_NODE, node, req->mpctx);
+
req->status = translate_property_error(err);
+ if (mp_msg_test(req->mpctx->log, MSGL_V)) {
+ struct m_option ot = {.type = &m_option_type_node};
+ char *t = m_option_print(&ot, node);
+ MP_VERBOSE(req->mpctx, "Set property: %s=%s -> %d\n",
+ req->name, t ? t : "?", err);
+ talloc_free(t);
+ }
+
if (req->reply_ctx) {
status_reply(req->reply_ctx, MPV_EVENT_SET_PROPERTY_REPLY,
req->userdata, req->status);