summaryrefslogtreecommitdiffstats
path: root/options
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-09-02 15:59:40 +0200
committerwm4 <wm4@nowhere>2016-09-02 21:21:47 +0200
commit849480d0c9d5ef76bd3296034b2ad5019fb9c21d (patch)
treeef72fcfbbcce7fb0c88048ae70a0ec42cdf7866a /options
parenta07dae57e31882024518008c5c1c45f932c15193 (diff)
downloadmpv-849480d0c9d5ef76bd3296034b2ad5019fb9c21d.tar.bz2
mpv-849480d0c9d5ef76bd3296034b2ad5019fb9c21d.tar.xz
vo_opengl: deprecate sub-options, add them as global options
vo_opengl sub-option were always rather annoying to handle. It seems better to make them global options instead. This is simpler and easier to use. The only disadvantage we are aware of is that it's not clear that many/all of these new global options work with vo_opengl only. --vo=opengl-hq is also deprecated. There is extensive compatibility with the old behavior. One exception is that --vo-defaults will not apply to opengl-hq (though with opengl it still works). vo-cmdline is also dysfunctional and will be removed in a following commit. These changes also affect opengl-cb. The update mechanism is still rather inefficient: it requires syncing with the VO after each option change, rather than batching updates. There's also no granularity (video.c just updates "everything", and if auto-ICC profiles are enabled, vo_opengl.c will fetch them on each update). Most of the manpage changes were done by Niklas Haas <git@haasn.xyz>.
Diffstat (limited to 'options')
-rw-r--r--options/m_config.c56
-rw-r--r--options/m_config.h4
-rw-r--r--options/m_option.c17
-rw-r--r--options/m_option.h13
-rw-r--r--options/options.c7
-rw-r--r--options/options.h3
6 files changed, 78 insertions, 22 deletions
diff --git a/options/m_config.c b/options/m_config.c
index 19eb61d082..125702c362 100644
--- a/options/m_config.c
+++ b/options/m_config.c
@@ -257,39 +257,44 @@ struct m_config *m_config_from_obj_desc_noalloc(void *talloc_ctx,
return m_config_new(talloc_ctx, log, 0, desc->priv_defaults, desc->options);
}
-static int m_config_set_obj_params(struct m_config *conf, char **args)
+static int m_config_set_obj_params(struct m_config *config, struct mp_log *log,
+ struct mpv_global *global, char **args)
{
for (int n = 0; args && args[n * 2 + 0]; n++) {
- int r = m_config_set_option(conf, bstr0(args[n * 2 + 0]),
- bstr0(args[n * 2 + 1]));
- if (r < 0)
- return r;
+ const char *opt = args[n * 2 + 0];
+ const char *val = args[n * 2 + 1];
+ struct m_config_option *co = m_config_get_co(config, bstr0(opt));
+ struct m_config *target = config;
+ if (co && co->opt->type == &m_option_type_subopt_legacy) {
+ const char *newopt = co->opt->priv;
+ assert(global);
+ target = mp_get_root_config(global);
+ mp_warn(log, "Using suboptions is deprecated. Use the global '--%s' "
+ "option instead of '%s' suboption.\n", newopt, opt);
+ opt = newopt;
+ }
+ if (m_config_set_option(target, bstr0(opt), bstr0(val)) < 0)
+ return -1;
}
+
return 0;
}
-static int m_config_apply_defaults(struct m_config *config, const char *name,
- struct m_obj_settings *defaults)
+struct m_config *m_config_from_obj_desc_and_args(void *ta_parent,
+ struct mp_log *log, struct mpv_global *global, struct m_obj_desc *desc,
+ const char *name, struct m_obj_settings *defaults, char **args)
{
- int r = 0;
+ struct m_config *config = m_config_from_obj_desc(ta_parent, log, desc);
+
for (int n = 0; defaults && defaults[n].name; n++) {
struct m_obj_settings *entry = &defaults[n];
if (name && strcmp(entry->name, name) == 0) {
- r = m_config_set_obj_params(config, entry->attribs);
- break;
+ if (m_config_set_obj_params(config, log, global, entry->attribs) < 0)
+ goto error;
}
}
- return r;
-}
-struct m_config *m_config_from_obj_desc_and_args(void *ta_parent,
- struct mp_log *log, struct mpv_global *global, struct m_obj_desc *desc,
- const char *name, struct m_obj_settings *defaults, char **args)
-{
- struct m_config *config = m_config_from_obj_desc(ta_parent, log, desc);
- if (m_config_apply_defaults(config, name, defaults) < 0)
- goto error;
- if (m_config_set_obj_params(config, args) < 0)
+ if (m_config_set_obj_params(config, log, global, args) < 0)
goto error;
return config;
@@ -1143,6 +1148,17 @@ void m_config_notify_change_co(struct m_config *config,
mp_msg_update_msglevels(config->global);
}
+bool m_config_is_in_group(struct m_config *config,
+ const struct m_sub_options *group,
+ struct m_config_option *co)
+{
+ for (int n = 0; n < config->num_groups; n++) {
+ if (config->groups[n].group == group)
+ return is_group_included(config, co->group, n);
+ }
+ return false;
+}
+
void *mp_get_config_group(void *ta_parent, struct mpv_global *global,
const struct m_sub_options *group)
{
diff --git a/options/m_config.h b/options/m_config.h
index e1fbb758b6..7a4c15a08e 100644
--- a/options/m_config.h
+++ b/options/m_config.h
@@ -208,6 +208,10 @@ int m_config_option_requires_param(struct m_config *config, bstr name);
void m_config_notify_change_co(struct m_config *config,
struct m_config_option *co);
+bool m_config_is_in_group(struct m_config *config,
+ const struct m_sub_options *group,
+ struct m_config_option *co);
+
// Return all (visible) option names as NULL terminated string list.
char **m_config_list_options(void *ta_parent, const struct m_config *config);
diff --git a/options/m_option.c b/options/m_option.c
index a44ca0012d..3cd9a1fb8c 100644
--- a/options/m_option.c
+++ b/options/m_option.c
@@ -2653,8 +2653,11 @@ static int get_obj_param(struct mp_log *log, bstr opt_name, bstr obj_name,
{
int r;
- if (!config)
- return 0; // skip
+ if (!config) {
+ *out_name = name; // preserve args for opengl-hq legacy handling
+ *out_val = val;
+ return 1;
+ }
// va.start != NULL => of the form name=val (not positional)
// If it's just "name", and the associated option exists and is a flag,
@@ -3356,3 +3359,13 @@ const m_option_type_t m_option_type_alias = {
const m_option_type_t m_option_type_removed = {
.name = "removed",
};
+
+static int parse_dummy(struct mp_log *log, const m_option_t *opt,
+ struct bstr name, struct bstr param, void *dst)
+{
+ return 1;
+}
+const m_option_type_t m_option_type_subopt_legacy = {
+ .name = "legacy suboption",
+ .parse = parse_dummy,
+};
diff --git a/options/m_option.h b/options/m_option.h
index 548db319a1..d1426467e7 100644
--- a/options/m_option.h
+++ b/options/m_option.h
@@ -63,6 +63,7 @@ extern const m_option_type_t m_option_type_size_box;
extern const m_option_type_t m_option_type_channels;
extern const m_option_type_t m_option_type_aspect;
extern const m_option_type_t m_option_type_node;
+extern const m_option_type_t m_option_type_subopt_legacy;
// Used internally by m_config.c
extern const m_option_type_t m_option_type_alias;
@@ -694,6 +695,12 @@ extern const char m_option_path_separator;
.type = &m_option_type_subconfig, \
.priv = (void*)&subconf)
+// Same as above, but for legacy suboption usage, which have no associated
+// field (no actual data anywhere).
+#define OPT_SUBSTRUCT_LEGACY(optname, subconf) \
+ {.name = optname, .offset = -1, .type = &m_option_type_subconfig, \
+ .priv = (void*)&subconf}
+
// Provide a another name for the option.
#define OPT_ALIAS(optname, newname) \
{.name = optname, .type = &m_option_type_alias, .priv = newname, \
@@ -710,4 +717,10 @@ extern const char m_option_path_separator;
{.name = optname, .type = &m_option_type_removed, .priv = msg, \
.deprecation_message = "", .offset = -1}
+// Redirect a suboption (e.g. from --vo) to a global option. The redirection
+// is handled as a special case instead of being applied automatically.
+#define OPT_SUBOPT_LEGACY(optname, globalname) \
+ {.name = optname, .type = &m_option_type_subopt_legacy, .priv = globalname, \
+ .offset = -1}
+
#endif /* MPLAYER_M_OPTION_H */
diff --git a/options/options.c b/options/options.c
index bd16a0a025..37e6c9fd61 100644
--- a/options/options.c
+++ b/options/options.c
@@ -73,6 +73,8 @@ extern const struct m_sub_options ad_lavc_conf;
extern const struct m_sub_options input_config;
extern const struct m_sub_options encode_config;
extern const struct m_sub_options image_writer_conf;
+extern const struct m_sub_options gl_video_conf;
+extern const struct m_sub_options vo_opengl_conf;
extern const struct m_obj_list vf_obj_list;
extern const struct m_obj_list af_obj_list;
@@ -641,6 +643,11 @@ const m_option_t mp_opts[] = {
OPT_SUBSTRUCT("", vo, vo_sub_opts, 0),
+#if HAVE_GL
+ OPT_SUBSTRUCT("", gl_video_opts, gl_video_conf, 0),
+ OPT_SUBSTRUCT("", vo_opengl_opts, vo_opengl_conf, 0),
+#endif
+
#if HAVE_ENCODING
OPT_SUBSTRUCT("", encode_opts, encode_config, 0),
#endif
diff --git a/options/options.h b/options/options.h
index d450675e61..59ed7b4a43 100644
--- a/options/options.h
+++ b/options/options.h
@@ -331,6 +331,9 @@ typedef struct MPOpts {
char *ipc_path;
char *input_file;
+
+ struct gl_video_opts *gl_video_opts;
+ struct vo_opengl_opts *vo_opengl_opts;
} MPOpts;
extern const m_option_t mp_opts[];