ucm: Only look in ucm[1] or ucm2 dir once we've found a config file in one

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: aba2260ae7 ("ucm: switch to ucm2 directory and v2 format, keep backward compatibility")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Hans de Goede 2019-11-19 11:48:21 +01:00 committed by Jaroslav Kysela
parent 77119d83a1
commit b3a02322d4

View file

@ -107,12 +107,18 @@ static void configuration_filename(snd_use_case_mgr_t *uc_mgr,
} }
configuration_filename2(fn, fn_len, 2, dir, file, suffix); 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; return;
}
configuration_filename2(fn, fn_len, 0, dir, file, suffix); 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; return;
}
/* make sure that the error message refers to the new path */ /* make sure that the error message refers to the new path */
configuration_filename2(fn, fn_len, 2, dir, file, suffix); configuration_filename2(fn, fn_len, 2, dir, file, suffix);