summaryrefslogtreecommitdiffstats
path: root/options/m_config.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-09-05 21:04:17 +0200
committerwm4 <wm4@nowhere>2016-09-05 21:04:17 +0200
commit4ab860cddc177047663bbe8940b0d34c621b6425 (patch)
treeb13ac6888948d4b5f132d03f3ac243ea7790db73 /options/m_config.c
parentcc813647d54843e4731cc36160f0c1e04e4b1404 (diff)
downloadmpv-4ab860cddc177047663bbe8940b0d34c621b6425.tar.bz2
mpv-4ab860cddc177047663bbe8940b0d34c621b6425.tar.xz
options: add a mechanism to make sub-option replacement slightly easier
Instead of requiring each VO or AO to manually add members to MPOpts and the global option table, make it possible to register them automatically via vo_driver/ao_driver.global_opts members. This avoids modifying options.c/options.h every time, including having to duplicate the exact ifdeffery used to enable a driver.
Diffstat (limited to 'options/m_config.c')
-rw-r--r--options/m_config.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/options/m_config.c b/options/m_config.c
index 3d1355904e..18a9ad4de7 100644
--- a/options/m_config.c
+++ b/options/m_config.c
@@ -406,6 +406,18 @@ static void add_sub_options(struct m_config *config,
add_options(config, &next, new_optstruct, new_optstruct_def, subopts->opts);
}
+static void add_global_subopts(struct m_config *config,
+ const struct m_obj_list *list)
+{
+ struct m_obj_desc desc;
+ for (int n = 0; ; n++) {
+ if (!list->get_desc(&desc, n))
+ break;
+ if (desc.global_opts)
+ add_sub_options(config, NULL, desc.global_opts);
+ }
+}
+
// Initialize a field with a given value. In case this is dynamic data, it has
// to be allocated and copied. src can alias dst, also can be NULL.
static void init_opt_inplace(const struct m_option *opt, void *dst,
@@ -477,6 +489,10 @@ static void m_config_add_option(struct m_config *config,
init_opt_inplace(arg, co.data, co.default_data);
}
+ // (The deprecation_message check is a hack to exclude --vo-defaults etc.)
+ if (arg->type == &m_option_type_obj_settings_list && !arg->deprecation_message)
+ add_global_subopts(config, (const struct m_obj_list *)arg->priv);
+
if (arg->name[0]) // no own name -> hidden
MP_TARRAY_APPEND(config, config->opts, config->num_opts, co);
}