summaryrefslogtreecommitdiffstats
path: root/options/m_config.c
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/m_config.c
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/m_config.c')
-rw-r--r--options/m_config.c56
1 files changed, 36 insertions, 20 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)
{