mirror of
				https://github.com/alsa-project/alsa-lib.git
				synced 2025-11-03 09:01:52 -05:00 
			
		
		
		
	ucm: Fix opening of master-configs by the card's longname
Prior to commitaba2260ae7("ucm: switch to ucm2 directory and v2 format, keep backward compatibility"). The filename build in parse_verb_file() was build like this: <prefix>/<uc_mgr->conf_file_name>/<file> Where uc_mgr->conf_file_name would contain either the card_name or the card's longname depending on the detection of a longname based config in uc_mgr_import_master_config(). While the filename used in load_master_config() was build like this: <prefix>/<card_name>/<card_name>.conf And uc_mgr_import_master_config() first calls load_master_config() with the card's longname and if that succeeds it overwrites uc_mgr->conf_file_name with the longname so that the subsequent uses of uc_mgr->conf_file_name in parse_verb_file() correctly use the longname. But the new configuration_filename() helper added in commitaba2260ae7_always_ builds the filename like this: <prefix>/<uc_mgr->conf_file_name>/<file><suffix> This breaks the loading of the master-config by its longname, as when the longname is tried uc_mgr->conf_file_name still contains the card_name. This commit fixes this by adding a dir parameter to configuration_filename() and restoring the old behavior by passing card_name as dir in load_master_config(). 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:
		
							parent
							
								
									c28618353b
								
							
						
					
					
						commit
						86c449d231
					
				
					 1 changed files with 7 additions and 7 deletions
				
			
		| 
						 | 
					@ -76,9 +76,10 @@ static void configuration_filename2(char *fn, size_t fn_len, int format,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void configuration_filename(snd_use_case_mgr_t *uc_mgr,
 | 
					static void configuration_filename(snd_use_case_mgr_t *uc_mgr,
 | 
				
			||||||
				   char *fn, size_t fn_len,
 | 
									   char *fn, size_t fn_len,
 | 
				
			||||||
				   const char *file, const char *suffix)
 | 
									   const char *dir, const char *file,
 | 
				
			||||||
 | 
									   const char *suffix)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	const char *env, *dir;
 | 
						const char *env;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (uc_mgr->conf_format > 0) {
 | 
						if (uc_mgr->conf_format > 0) {
 | 
				
			||||||
		/* known format */
 | 
							/* known format */
 | 
				
			||||||
| 
						 | 
					@ -94,13 +95,11 @@ static void configuration_filename(snd_use_case_mgr_t *uc_mgr,
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (env) {
 | 
						if (env) {
 | 
				
			||||||
		snprintf(fn, fn_len, "%s/%s/%s%s",
 | 
							snprintf(fn, fn_len, "%s/%s/%s%s", env, dir, file, suffix);
 | 
				
			||||||
			env, uc_mgr->conf_file_name, file, suffix);
 | 
					 | 
				
			||||||
		fn[fn_len-1] = '\0';
 | 
							fn[fn_len-1] = '\0';
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	dir = uc_mgr->conf_file_name;
 | 
					 | 
				
			||||||
	if (uc_mgr->conf_format > 0) {
 | 
						if (uc_mgr->conf_format > 0) {
 | 
				
			||||||
__format:
 | 
					__format:
 | 
				
			||||||
		configuration_filename2(fn, fn_len, uc_mgr->conf_format,
 | 
							configuration_filename2(fn, fn_len, uc_mgr->conf_format,
 | 
				
			||||||
| 
						 | 
					@ -1181,7 +1180,8 @@ static int parse_verb_file(snd_use_case_mgr_t *uc_mgr,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* open Verb file for reading */
 | 
						/* open Verb file for reading */
 | 
				
			||||||
	configuration_filename(uc_mgr, filename, sizeof(filename), file, "");
 | 
						configuration_filename(uc_mgr, filename, sizeof(filename),
 | 
				
			||||||
 | 
								       uc_mgr->conf_file_name, file, "");
 | 
				
			||||||
	err = uc_mgr_config_load(uc_mgr->conf_format, filename, &cfg);
 | 
						err = uc_mgr_config_load(uc_mgr->conf_format, filename, &cfg);
 | 
				
			||||||
	if (err < 0) {
 | 
						if (err < 0) {
 | 
				
			||||||
		uc_error("error: failed to open verb file %s : %d",
 | 
							uc_error("error: failed to open verb file %s : %d",
 | 
				
			||||||
| 
						 | 
					@ -1576,7 +1576,7 @@ static int load_master_config(snd_use_case_mgr_t *uc_mgr,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	configuration_filename(uc_mgr, filename, sizeof(filename),
 | 
						configuration_filename(uc_mgr, filename, sizeof(filename),
 | 
				
			||||||
			       card_name, ".conf");
 | 
								       card_name, card_name, ".conf");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* if the configuration file does not exist, silently return */
 | 
						/* if the configuration file does not exist, silently return */
 | 
				
			||||||
	if (fcheck && access(filename, R_OK) != 0)
 | 
						if (fcheck && access(filename, R_OK) != 0)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue