diff options
author | wm4 <wm4@nowhere> | 2012-09-26 23:56:29 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-10-12 10:10:32 +0200 |
commit | 8fc2aef3b7f95a10de01a9f441907b9cd5d41c45 (patch) | |
tree | 99258161ba09bf910a880873702e1f88c7912650 /m_property.c | |
parent | 46e8d338092a2060300de9953d01778806d87d6d (diff) | |
download | mpv-8fc2aef3b7f95a10de01a9f441907b9cd5d41c45.tar.bz2 mpv-8fc2aef3b7f95a10de01a9f441907b9cd5d41c45.tar.xz |
commands: don't use dummy option declaration for properties
The property-to-option bridge (when properties change values normally
set by the command line parser) uses M_PROPERTY_GET_TYPE to get the
exact option type. In these cases, the entry in mp_properties[] is
unused, except for the name field and the property callback. Instead,
mp_property_generic_option() implements M_PROPERTY_GET_TYPE and returns
the m_option as defined in cfg-mplayer.h. However, if a property is
unavailable, mp_property_generic_option() is never actually called, and
M_PROPERTY_GET_TYPE will return the dummy option entry.
We could make sure that the dummy option entry equals the option entry
defined in cfg-mplayer.h. But this would duplicate all information.
Add a dummy option type m_option_type_dummy, which is used by entries
using the property-to-option bridge. Make M_PROPERTY_GET_TYPE fail if
this type is encountered.
This dummy should never be used, as it isn
Diffstat (limited to 'm_property.c')
-rw-r--r-- | m_property.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/m_property.c b/m_property.c index acdf91200c..1644dbd997 100644 --- a/m_property.c +++ b/m_property.c @@ -35,6 +35,10 @@ #include "mp_msg.h" #include "mpcommon.h" +const struct m_option_type m_option_type_dummy = { + .name = "Unknown", +}; + static int do_action(const m_option_t *prop_list, const char *name, int action, void *arg, void *ctx) { @@ -59,7 +63,9 @@ static int do_action(const m_option_t *prop_list, const char *name, return M_PROPERTY_UNKNOWN; int (*control)(const m_option_t*, int, void*, void*) = prop->p; int r = control(prop, action, arg, ctx); - if (action == M_PROPERTY_GET_TYPE && r < 0) { + if (action == M_PROPERTY_GET_TYPE && r < 0 && + prop->type != &m_option_type_dummy) + { *(struct m_option *)arg = *prop; return M_PROPERTY_OK; } |