summaryrefslogtreecommitdiffstats
path: root/options/m_property.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-11-13 17:25:59 +0100
committerwm4 <wm4@nowhere>2014-11-13 17:26:22 +0100
commit13033ce2c4e05eaf031c09a4d41f3db9512af9c0 (patch)
treec0f1846b16e782085fbc5079fee7789983270ace /options/m_property.c
parentdbf59abe0525ad38dac369af248ad735ef66cfe8 (diff)
downloadmpv-13033ce2c4e05eaf031c09a4d41f3db9512af9c0.tar.bz2
mpv-13033ce2c4e05eaf031c09a4d41f3db9512af9c0.tar.xz
command: make sub-properties more flexible
This makes it work with all kind of types, instead of just some simple ones.
Diffstat (limited to 'options/m_property.c')
-rw-r--r--options/m_property.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/options/m_property.c b/options/m_property.c
index 1beaf83402..1204f924b6 100644
--- a/options/m_property.c
+++ b/options/m_property.c
@@ -477,10 +477,10 @@ int m_property_read_sub(const struct m_sub_property *props, int action, void *ar
continue;
MP_TARRAY_GROW(list, list->values, list->num);
MP_TARRAY_GROW(list, list->keys, list->num);
- struct m_option type = {.type = prop->type};
mpv_node *val = &list->values[list->num];
- if (m_option_get_node(&type, list, val, (void*)&prop->value) < 0) {
- char *s = m_option_print(&type, &prop->value);
+ if (m_option_get_node(&prop->type, list, val, (void*)&prop->value) < 0)
+ {
+ char *s = m_option_print(&prop->type, &prop->value);
val->format = MPV_FORMAT_STRING;
val->u.string = talloc_steal(list, s);
}
@@ -500,8 +500,7 @@ int m_property_read_sub(const struct m_sub_property *props, int action, void *ar
const struct m_sub_property *prop = &props[n];
if (prop->unavailable)
continue;
- struct m_option type = {.type = prop->type};
- char *s = m_option_print(&type, &prop->value);
+ char *s = m_option_print(&prop->type, &prop->value);
ta_xasprintf_append(&res, "%s=%s\n", prop->name, s);
talloc_free(s);
}
@@ -521,15 +520,14 @@ int m_property_read_sub(const struct m_sub_property *props, int action, void *ar
return M_PROPERTY_UNKNOWN;
if (prop->unavailable)
return M_PROPERTY_UNAVAILABLE;
- struct m_option type = {.type = prop->type};
switch (ka->action) {
case M_PROPERTY_GET: {
- memset(ka->arg, 0, type.type->size);
- m_option_copy(&type, ka->arg, &prop->value);
+ memset(ka->arg, 0, prop->type.type->size);
+ m_option_copy(&prop->type, ka->arg, &prop->value);
return M_PROPERTY_OK;
}
case M_PROPERTY_GET_TYPE:
- *(struct m_option *)ka->arg = type;
+ *(struct m_option *)ka->arg = prop->type;
return M_PROPERTY_OK;
}
}