mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2026-02-12 04:27:45 -05:00
ucm: Set default include path
Many UCM profiles include the UCM profile components under ucm/* subdirectories and thusly put <searchdir:ucm> at each place. This is rather cumbersome. This patch makes the UCM parser to set the default include path, so that each profile no longer needs to set searchdir. All the <searchdir:ucm> lines currently found in the profiles are removed gracefully, too. For the needed implementation, a new helper, _snd_config_load_with_include() is introduced. It's not exported, only for the use inside alsa-lib. Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
d48adc2a20
commit
c9fcf98369
23 changed files with 41 additions and 25 deletions
32
src/conf.c
32
src/conf.c
|
|
@ -1832,7 +1832,8 @@ int snd_config_top(snd_config_t **config)
|
|||
return _snd_config_make(config, 0, SND_CONFIG_TYPE_COMPOUND);
|
||||
}
|
||||
|
||||
static int snd_config_load1(snd_config_t *config, snd_input_t *in, int override)
|
||||
static int snd_config_load1(snd_config_t *config, snd_input_t *in, int override,
|
||||
char *default_include_path)
|
||||
{
|
||||
int err;
|
||||
input_t input;
|
||||
|
|
@ -1847,6 +1848,11 @@ static int snd_config_load1(snd_config_t *config, snd_input_t *in, int override)
|
|||
fd->column = 0;
|
||||
fd->next = NULL;
|
||||
INIT_LIST_HEAD(&fd->include_paths);
|
||||
if (default_include_path) {
|
||||
err = add_include_path(fd, default_include_path);
|
||||
if (err < 0)
|
||||
goto _end;
|
||||
}
|
||||
input.current = fd;
|
||||
input.unget = 0;
|
||||
err = parse_defs(config, &input, 0, override);
|
||||
|
|
@ -1915,9 +1921,29 @@ static int snd_config_load1(snd_config_t *config, snd_input_t *in, int override)
|
|||
*/
|
||||
int snd_config_load(snd_config_t *config, snd_input_t *in)
|
||||
{
|
||||
return snd_config_load1(config, in, 0);
|
||||
return snd_config_load1(config, in, 0, NULL);
|
||||
}
|
||||
|
||||
#ifndef DOC_HIDDEN
|
||||
/* load config with the default include path; used internally for UCM parser */
|
||||
int _snd_config_load_with_include(snd_config_t *config, snd_input_t *in,
|
||||
const char *default_include_path)
|
||||
{
|
||||
int err;
|
||||
char *s = NULL;
|
||||
|
||||
if (default_include_path) {
|
||||
s = strdup(default_include_path);
|
||||
if (!s)
|
||||
return -ENOMEM;
|
||||
}
|
||||
err = snd_config_load1(config, in, 0, s);
|
||||
if (err < 0)
|
||||
free(s);
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Loads a configuration tree and overrides existing configuration nodes.
|
||||
* \param config Handle to a top level configuration node.
|
||||
|
|
@ -1930,7 +1956,7 @@ int snd_config_load(snd_config_t *config, snd_input_t *in)
|
|||
*/
|
||||
int snd_config_load_override(snd_config_t *config, snd_input_t *in)
|
||||
{
|
||||
return snd_config_load1(config, in, 1);
|
||||
return snd_config_load1(config, in, 1, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue