OSDN Git Service

ucm: Only look in ucm[1] or ucm2 dir once we've found a config file in one
authorHans de Goede <hdegoede@redhat.com>
Tue, 19 Nov 2019 10:48:21 +0000 (11:48 +0100)
committerJaroslav Kysela <perex@perex.cz>
Tue, 19 Nov 2019 11:45:38 +0000 (12:45 +0100)
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>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/ucm/parser.c

index a7e80de..319e3c1 100644 (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);
-       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);