From 6d4b4c0de3152bc2deb2df09ec3e98e032124593 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 12 Jan 2018 04:02:55 +0100 Subject: audio: add global options for resampler defaults This is part of trying to get rid of --af-defaults, and the af resample filter. It requires a complicated mechanism to set the defaults on the resample filter for backwards compatibility. --- options/m_config.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'options/m_config.c') diff --git a/options/m_config.c b/options/m_config.c index 8bf7e0ef91..a487b64869 100644 --- a/options/m_config.c +++ b/options/m_config.c @@ -194,11 +194,18 @@ struct m_config *m_config_new(void *talloc_ctx, struct mp_log *log, return config; } -struct m_config *m_config_from_obj_desc(void *talloc_ctx, struct mp_log *log, - struct m_obj_desc *desc) +static struct m_config *m_config_from_obj_desc(void *talloc_ctx, + struct mp_log *log, + struct mpv_global *global, + struct m_obj_desc *desc) { - return m_config_new(talloc_ctx, log, desc->priv_size, desc->priv_defaults, - desc->options); + struct m_config *c = + m_config_new(talloc_ctx, log, desc->priv_size, desc->priv_defaults, + desc->options); + c->global = global; + if (desc->set_defaults && c->global) + desc->set_defaults(c->global, c->optstruct); + return c; } // Like m_config_from_obj_desc(), but don't allocate option struct. @@ -260,7 +267,7 @@ 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); + struct m_config *config = m_config_from_obj_desc(ta_parent, log, global, desc); for (int n = 0; defaults && defaults[n].name; n++) { struct m_obj_settings *entry = &defaults[n]; -- cgit v1.2.3