Unless environment variables are set, then configuration_filename() when initially called by load_master_config() will first try to find the requested master-config under <prefix>/alsa/ucm2 and then under <prefix>/alsa/ucm.
Once a master-config is found this way, we should set conf_format to match, so that subsequent lookups only look under the same directory as where the master-config was found.
This fixes 2 problems: 1. uc_mgr_config_load() looking under <prefix>/alsa/ucm for includes for UCM2 profiles because it is called with uc_mgr->conf_format as format and before this commit that would stay 0 when autodetecion is used.
2. parse_verb_file() possibly loading an UCM2 verb-file for an UCM1 profile, the chance of this happening is small as this means that even though there is no UCM2 master-config there is an UCM2 profile dir matching uc_mgr->conf_file_name, which would be weird.
Fixes: aba2260ae7b5 ("ucm: switch to ucm2 directory and v2 format, keep backward compatibility") Signed-off-by: Hans de Goede hdegoede@redhat.com --- src/ucm/parser.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/ucm/parser.c b/src/ucm/parser.c index a7e80de3..319e3c1a 100644 --- a/src/ucm/parser.c +++ b/src/ucm/parser.c @@ -107,12 +107,18 @@ static void configuration_filename(snd_use_case_mgr_t *uc_mgr, }
configuration_filename2(fn, fn_len, 2, dir, file, suffix); - if (access(fn, R_OK) == 0) + if (access(fn, R_OK) == 0) { + /* Found an ucm2 file, only look in the ucm2 dir from now on */ + uc_mgr->conf_format = 2; return; + }
configuration_filename2(fn, fn_len, 0, dir, file, suffix); - if (access(fn, R_OK) == 0) + if (access(fn, R_OK) == 0) { + /* Found an ucm1 file, only look in the ucm dir from now on */ + uc_mgr->conf_format = 1; return; + }
/* make sure that the error message refers to the new path */ configuration_filename2(fn, fn_len, 2, dir, file, suffix);