ucm: configuration - implement in-place Include

An example:

	Include {
		File "Inc.conf"
		Before.SectionDevice "Mic"
	}

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2020-05-16 15:47:19 +02:00
parent 14636be4a8
commit 3edfebc522
6 changed files with 375 additions and 168 deletions

View file

@ -246,12 +246,28 @@ __nomem:
return -ENOMEM;
}
const char *uc_mgr_config_dir(int format)
{
const char *path;
if (format >= 2) {
path = getenv(ALSA_CONFIG_UCM2_VAR);
if (!path || path[0] == '\0')
path = ALSA_CONFIG_DIR "/ucm2";
} else {
path = getenv(ALSA_CONFIG_UCM_VAR);
if (!path || path[0] == '\0')
path = ALSA_CONFIG_DIR "/ucm";
}
return path;
}
int uc_mgr_config_load(int format, const char *file, snd_config_t **cfg)
{
FILE *fp;
snd_input_t *in;
snd_config_t *top;
const char *path, *default_paths[2];
const char *default_paths[2];
int err;
fp = fopen(file, "r");
@ -268,17 +284,7 @@ int uc_mgr_config_load(int format, const char *file, snd_config_t **cfg)
if (err < 0)
goto __err1;
if (format >= 2) {
path = getenv(ALSA_CONFIG_UCM2_VAR);
if (!path || path[0] == '\0')
path = ALSA_CONFIG_DIR "/ucm2";
} else {
path = getenv(ALSA_CONFIG_UCM_VAR);
if (!path || path[0] == '\0')
path = ALSA_CONFIG_DIR "/ucm";
}
default_paths[0] = path;
default_paths[0] = uc_mgr_config_dir(format);
default_paths[1] = NULL;
err = _snd_config_load_with_include(top, in, 0, default_paths);
if (err < 0) {