mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2026-02-06 04:06:34 -05:00
ucm: fix variant issue where variables or macros are overwritten
It is necessary to reset the state logic before each verb variant is parsed. So save the original variable list and macros and restore them before each parser iteration. BugLink: https://github.com/alsa-project/alsa-ucm-conf/pull/633 Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
f6dce4f9d0
commit
bd0ce670c2
3 changed files with 82 additions and 1 deletions
|
|
@ -2250,15 +2250,52 @@ static int parse_master_section(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg,
|
|||
err = parse_verb_file(uc_mgr, use_case_name, comment, file);
|
||||
} else {
|
||||
/* parse variants */
|
||||
struct list_head orig_variable_list;
|
||||
snd_config_t *orig_macros = NULL;
|
||||
int first_iteration = 1;
|
||||
|
||||
/* save original variable list */
|
||||
err = uc_mgr_duplicate_variables(&orig_variable_list, &uc_mgr->variable_list);
|
||||
if (err < 0)
|
||||
goto __error;
|
||||
|
||||
/* save original macros */
|
||||
if (uc_mgr->macros) {
|
||||
err = snd_config_copy(&orig_macros, uc_mgr->macros);
|
||||
if (err < 0)
|
||||
goto __variant_error;
|
||||
}
|
||||
|
||||
snd_config_for_each(i, next, variant) {
|
||||
char *vfile, *vcomment;
|
||||
const char *id;
|
||||
|
||||
/* restore variables and macros for second and later iterations */
|
||||
if (!first_iteration) {
|
||||
uc_mgr_free_value(&uc_mgr->variable_list);
|
||||
|
||||
err = uc_mgr_duplicate_variables(&uc_mgr->variable_list, &orig_variable_list);
|
||||
if (err < 0)
|
||||
goto __variant_error;
|
||||
|
||||
if (uc_mgr->macros) {
|
||||
snd_config_delete(uc_mgr->macros);
|
||||
uc_mgr->macros = NULL;
|
||||
}
|
||||
if (orig_macros) {
|
||||
err = snd_config_copy(&uc_mgr->macros, orig_macros);
|
||||
if (err < 0)
|
||||
goto __variant_error;
|
||||
}
|
||||
}
|
||||
first_iteration = 0;
|
||||
|
||||
n = snd_config_iterator_entry(i);
|
||||
if (snd_config_get_id(n, &id) < 0)
|
||||
continue;
|
||||
if (!parse_is_name_safe(id)) {
|
||||
err = -EINVAL;
|
||||
goto __error;
|
||||
goto __variant_error;
|
||||
}
|
||||
err = parse_variant(uc_mgr, n, &vfile, &vcomment);
|
||||
if (err < 0)
|
||||
|
|
@ -2270,7 +2307,14 @@ static int parse_master_section(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg,
|
|||
uc_mgr->parse_variant = NULL;
|
||||
free(vfile);
|
||||
free(vcomment);
|
||||
if (err < 0)
|
||||
break;
|
||||
}
|
||||
|
||||
__variant_error:
|
||||
uc_mgr_free_value(&orig_variable_list);
|
||||
if (orig_macros)
|
||||
snd_config_delete(orig_macros);
|
||||
}
|
||||
|
||||
__error:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue