summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-06-15 15:22:06 +0200
committerwm4 <wm4@nowhere>2017-06-15 15:29:54 +0200
commitb8193e40719a2a72d9b25e8ea3070c0e84beb48e (patch)
tree489acbb02a0d443856853881096e650ce78fd69a
parentfd7de84833a7f492678e0caa18125ff9f9aa38a5 (diff)
downloadmpv-b8193e40719a2a72d9b25e8ea3070c0e84beb48e.tar.bz2
mpv-b8193e40719a2a72d9b25e8ea3070c0e84beb48e.tar.xz
command: add all options to property->option bridge
Before this, options with co->data==NULL (i.e. no storage) were not added to the bridge (except alias options). There are a few options which might make sense to allow via the bridge ("profile" and "include"). So allow them. In command_init(), we merely remove the co->data check, the rest of the diff is due to switching the if/else branches for convenience. We also must explicitly error on M_PROPERTY_GET if co->data==NULL. All other cases check it in some way. Explicitly exclude options from the property bridge, which would be added due this, and the result would be pointless.
-rw-r--r--DOCS/man/input.rst8
-rw-r--r--options/m_option.h4
-rw-r--r--options/options.c18
-rw-r--r--player/command.c26
4 files changed, 34 insertions, 22 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index 6759226c6e..ed3dc2311f 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -2210,6 +2210,14 @@ caveats with some properties (due to historical reasons):
These properties behave different from the deprecated options with the same
names.
+``profile``, ``include``
+ These are write-only, and will perform actions as they are written to,
+ exactly as if they were used on the mpv CLI commandline. Their only use is
+ when using libmpv before ``mpv_initialize()``, which in turn is probably
+ only useful in encoding mode. Normal libmpv users should use other
+ mechanisms, such as the ``apply-profile`` command, and the
+ ``mpv_load_config_file`` API function. Avoid these properties.
+
Property Expansion
------------------
diff --git a/options/m_option.h b/options/m_option.h
index 8f4e5e6a5c..78db2b5c85 100644
--- a/options/m_option.h
+++ b/options/m_option.h
@@ -693,7 +693,7 @@ extern const char m_option_path_separator;
#define OPT_PRINT(optname, fn) \
{.name = optname, \
- .flags = M_OPT_FIXED | M_OPT_NOCFG | M_OPT_PRE_PARSE, \
+ .flags = M_OPT_FIXED | M_OPT_NOCFG | M_OPT_PRE_PARSE | M_OPT_NOPROP, \
.type = &m_option_type_print_fn, \
.priv = MP_EXPECT_TYPE(m_opt_print_fn, fn), \
.offset = -1}
@@ -726,6 +726,6 @@ extern const char m_option_path_separator;
// "--optname" doesn't exist, but inform the user about a replacement with msg.
#define OPT_REMOVED(optname, msg) \
{.name = optname, .type = &m_option_type_removed, .priv = msg, \
- .deprecation_message = "", .offset = -1}
+ .deprecation_message = "", .flags = M_OPT_NOPROP, .offset = -1}
#endif /* MPLAYER_M_OPTION_H */
diff --git a/options/options.c b/options/options.c
index 1bcdc720f2..90cbe61d6f 100644
--- a/options/options.c
+++ b/options/options.c
@@ -254,21 +254,25 @@ const struct m_sub_options dvd_conf = {
const m_option_t mp_opts[] = {
// handled in command line pre-parser (parse_commandline.c)
- {"v", CONF_TYPE_STORE, M_OPT_FIXED | CONF_NOCFG, .offset = -1},
+ {"v", CONF_TYPE_STORE, M_OPT_FIXED | CONF_NOCFG | M_OPT_NOPROP, .offset = -1},
{"playlist", CONF_TYPE_STRING, CONF_NOCFG | M_OPT_MIN | M_OPT_FIXED | M_OPT_FILE,
.min = 1, .offset = -1},
- {"{", CONF_TYPE_STORE, CONF_NOCFG | M_OPT_FIXED, .offset = -1},
- {"}", CONF_TYPE_STORE, CONF_NOCFG | M_OPT_FIXED, .offset = -1},
+ {"{", CONF_TYPE_STORE, CONF_NOCFG | M_OPT_FIXED | M_OPT_NOPROP, .offset = -1},
+ {"}", CONF_TYPE_STORE, CONF_NOCFG | M_OPT_FIXED | M_OPT_NOPROP, .offset = -1},
// handled in m_config.c
{ "include", CONF_TYPE_STRING, M_OPT_FILE, .offset = -1},
{ "profile", CONF_TYPE_STRING_LIST, 0, .offset = -1},
- { "show-profile", CONF_TYPE_STRING, CONF_NOCFG | M_OPT_FIXED, .offset = -1},
- { "list-options", CONF_TYPE_STORE, CONF_NOCFG | M_OPT_FIXED, .offset = -1},
+ { "show-profile", CONF_TYPE_STRING, CONF_NOCFG | M_OPT_FIXED | M_OPT_NOPROP,
+ .offset = -1},
+ { "list-options", CONF_TYPE_STORE, CONF_NOCFG | M_OPT_FIXED | M_OPT_NOPROP,
+ .offset = -1},
OPT_FLAG("list-properties", property_print_help,
CONF_NOCFG | M_OPT_FIXED | M_OPT_NOPROP),
- { "help", CONF_TYPE_STRING, CONF_NOCFG | M_OPT_FIXED, .offset = -1},
- { "h", CONF_TYPE_STRING, CONF_NOCFG | M_OPT_FIXED, .offset = -1},
+ { "help", CONF_TYPE_STRING, CONF_NOCFG | M_OPT_FIXED | M_OPT_NOPROP,
+ .offset = -1},
+ { "h", CONF_TYPE_STRING, CONF_NOCFG | M_OPT_FIXED | M_OPT_NOPROP,
+ .offset = -1},
OPT_PRINT("list-protocols", stream_print_proto_list),
OPT_PRINT("version", print_version),
diff --git a/player/command.c b/player/command.c
index af7d4006d7..cdef20d7a3 100644
--- a/player/command.c
+++ b/player/command.c
@@ -402,14 +402,14 @@ static int mp_property_generic_option(void *ctx, struct m_property *prop,
if (!opt)
return M_PROPERTY_UNKNOWN;
- void *valptr = opt->data;
-
switch (action) {
case M_PROPERTY_GET_TYPE:
*(struct m_option *)arg = *(opt->opt);
return M_PROPERTY_OK;
case M_PROPERTY_GET:
- m_option_copy(opt->opt, arg, valptr);
+ if (!opt->data)
+ return M_PROPERTY_NOT_IMPLEMENTED;
+ m_option_copy(opt->opt, arg, opt->data);
return M_PROPERTY_OK;
case M_PROPERTY_SET:
if (m_config_set_option_raw_direct(mpctx->mconfig, opt, arg, flags) < 0)
@@ -5672,7 +5672,16 @@ void command_init(struct MPContext *mpctx)
struct m_property prop = {0};
- if (co->data) {
+ if (co->opt->type == &m_option_type_alias) {
+ const char *alias = (const char *)co->opt->priv;
+
+ prop = (struct m_property){
+ .name = co->name,
+ .call = co->opt->deprecation_message ?
+ mp_property_deprecated_alias : mp_property_alias,
+ .priv = (void *)alias,
+ };
+ } else {
prop = (struct m_property){
.name = co->name,
.call = mp_property_generic_option,
@@ -5683,15 +5692,6 @@ void command_init(struct MPContext *mpctx)
prop.name = bstrto0(ctx, bname);
prop.call = mp_property_generic_option_star;
}
- } else if (co->opt->type == &m_option_type_alias) {
- const char *alias = (const char *)co->opt->priv;
-
- prop = (struct m_property){
- .name = co->name,
- .call = co->opt->deprecation_message ?
- mp_property_deprecated_alias : mp_property_alias,
- .priv = (void *)alias,
- };
}
if (prop.name) {