diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2023-07-04 20:50:56 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2023-07-04 22:17:07 -0700 |
commit | 3ef4f9fd1e6ae233adb0bbfd90573623ee1059e6 (patch) | |
tree | a4ce04703e37a683f33d8675c6f10e21d4070e6a /src/modules/mixer | |
parent | 68f6dee32dea0fb1bfe40d901169cf68aa6528d0 (diff) |
modules/*: return invalid setting on -EINVAL in setup
In the interests of improving error handling of interactive
setups, return the setting that was invalid when setup returns
-EINVAL.
For now this is only supported for non-finalized/non-baking setup
calls, i.e. (!res_setup).
In the future I want this also supported for finalizing when
res_setup is set. A lot of the -EINVAL returns are actually
during that stage (or need to be added) due to that being when
the more sensitive parsing occurs going from strings to native
numeric types and such.
The main reason it's not already being done in this commit is
it'll churn quite a bit to get there, since the setup funcs don't
generally have the setting pointers onhand at that phase. It'll
require changing the string-value-centric local variables to
instead all be the til_setting_t* holding those values.
And if setup funcs aren't going to be so value-centric, the
settings API will likely change to not even return the values
directly anymore and only return the full-blown til_settings_t as
the main return pointer, perhaps rid of their res_setting use
even.
Anyway, while here I did some random little cleanups too.
Diffstat (limited to 'src/modules/mixer')
-rw-r--r-- | src/modules/mixer/mixer.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/modules/mixer/mixer.c b/src/modules/mixer/mixer.c index 07f72a3..793df50 100644 --- a/src/modules/mixer/mixer.c +++ b/src/modules/mixer/mixer.c @@ -340,7 +340,6 @@ static int mixer_setup(const til_settings_t *settings, til_setting_t **res_setti .name = input_names[i], .key = input_keys[i], .preferred = input_preferred[i], - .annotations = NULL, .as_nested_settings = 1, }, &inputs[i], @@ -354,28 +353,28 @@ static int mixer_setup(const til_settings_t *settings, til_setting_t **res_setti inputs_settings[i] = (*res_setting)->value_as_nested_settings; inputs[i] = til_settings_get_value_by_idx(inputs_settings[i], 0, &inputs_module_setting[i]); - if (!inputs[i]) - return -EINVAL; - - if (!inputs_module_setting[i]->desc) { + if (!inputs[i] || !inputs_module_setting[i]->desc) { r = til_setting_desc_new(inputs_settings[i], &(til_setting_spec_t){ .name = input_module_name_names[i], - .preferred = "ref", + .preferred = input_preferred[i], .as_label = 1, }, res_desc); if (r < 0) return r; - *res_setting = inputs_module_setting[i]; + *res_setting = inputs[i] ? inputs_module_setting[i] : NULL; return 1; } mod = til_lookup_module(inputs[i]); - if (!mod) + if (!mod) { + *res_setting = inputs_module_setting[i]; + return -EINVAL; + } if (mod->setup) { r = mod->setup(inputs_settings[i], res_setting, res_desc, NULL); |