From 4ab860cddc177047663bbe8940b0d34c621b6425 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 5 Sep 2016 21:04:17 +0200 Subject: 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. --- audio/out/ao.c | 1 + audio/out/ao_alsa.c | 3 ++- audio/out/internal.h | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) (limited to 'audio') diff --git a/audio/out/ao.c b/audio/out/ao.c index df2fdd5416..3bfa481bc5 100644 --- a/audio/out/ao.c +++ b/audio/out/ao.c @@ -109,6 +109,7 @@ static bool get_desc(struct m_obj_desc *dst, int index) .priv_size = ao->priv_size, .priv_defaults = ao->priv_defaults, .options = ao->options, + .global_opts = ao->global_opts, .hidden = ao->encode, .p = ao, }; diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c index e780d349c2..c542bee030 100644 --- a/audio/out/ao_alsa.c +++ b/audio/out/ao_alsa.c @@ -60,7 +60,7 @@ struct ao_alsa_opts { }; #define OPT_BASE_STRUCT struct ao_alsa_opts -const struct m_sub_options ao_alsa_conf = { +static const struct m_sub_options ao_alsa_conf = { .opts = (const struct m_option[]) { OPT_STRING("alsa-device", device, 0), OPT_FLAG("alsa-resample", resample, 0), @@ -1180,4 +1180,5 @@ const struct ao_driver audio_out_alsa = { OPT_SUBOPT_LEGACY("ignore-chmap", "alsa-ignore-chmap"), {0} }, + .global_opts = &ao_alsa_conf, }; diff --git a/audio/out/internal.h b/audio/out/internal.h index bd8816366e..f9dc073b4d 100644 --- a/audio/out/internal.h +++ b/audio/out/internal.h @@ -181,6 +181,7 @@ struct ao_driver { int priv_size; const void *priv_defaults; const struct m_option *options; + const struct m_sub_options *global_opts; }; // These functions can be called by AOs. -- cgit v1.2.3