summaryrefslogtreecommitdiffstats
path: root/options
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
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')
-rw-r--r--options/m_config.c16
-rw-r--r--options/m_option.h2
-rw-r--r--options/options.c8
-rw-r--r--options/options.h2
4 files changed, 20 insertions, 8 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);
}
diff --git a/options/m_option.h b/options/m_option.h
index d344a79db2..48afc23df7 100644
--- a/options/m_option.h
+++ b/options/m_option.h
@@ -130,6 +130,8 @@ struct m_obj_desc {
// Set by m_obj_list_find(). If the requested name is an old alias, this
// is set to the old name (while the name field uses the new name).
const char *replaced_name;
+ // For convenience: these are added as global command-line options.
+ const struct m_sub_options *global_opts;
};
// Extra definition needed for \ref m_option_type_obj_settings_list options.
diff --git a/options/options.c b/options/options.c
index e00c46c676..e5de82d8a3 100644
--- a/options/options.c
+++ b/options/options.c
@@ -74,7 +74,6 @@ 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_sub_options ao_alsa_conf;
extern const struct m_obj_list vf_obj_list;
@@ -473,7 +472,8 @@ const m_option_t mp_opts[] = {
//---------------------- libao/libvo options ------------------------
OPT_SETTINGSLIST("ao", audio_driver_list, 0, &ao_obj_list, ),
- OPT_SETTINGSLIST("ao-defaults", ao_defs, 0, &ao_obj_list, ),
+ OPT_SETTINGSLIST("ao-defaults", ao_defs, 0, &ao_obj_list,
+ .deprecation_message = "deprecated, use global options"),
OPT_STRING("audio-device", audio_device, 0),
OPT_STRING("audio-client-name", audio_client_name, 0),
OPT_FLAG("audio-fallback-to-null", ao_null_fallback, 0),
@@ -648,10 +648,6 @@ const m_option_t mp_opts[] = {
#if HAVE_GL
OPT_SUBSTRUCT("", gl_video_opts, gl_video_conf, 0),
- OPT_SUBSTRUCT("", vo_opengl_opts, vo_opengl_conf, 0),
-#endif
-#if HAVE_ALSA
- OPT_SUBSTRUCT("", ao_alsa_opts, ao_alsa_conf, 0),
#endif
#if HAVE_ENCODING
diff --git a/options/options.h b/options/options.h
index 96345e66f4..7d735e93b4 100644
--- a/options/options.h
+++ b/options/options.h
@@ -334,8 +334,6 @@ typedef struct MPOpts {
char *input_file;
struct gl_video_opts *gl_video_opts;
- struct vo_opengl_opts *vo_opengl_opts;
- struct ao_alsa_opts *ao_alsa_opts;
} MPOpts;
extern const m_option_t mp_opts[];