mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-03 09:01:52 -05:00
conf: load the card specific configurations to the config sub-tree
The /var/lib/alsa/card<CARDNO>.conf.d configurations are loaded to the cards.<CARDNO> tree only (overwrite mode). Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
1aef5a8f8a
commit
ffb401ba22
2 changed files with 77 additions and 26 deletions
86
src/conf.c
86
src/conf.c
|
|
@ -4056,6 +4056,70 @@ static int config_file_load_user(snd_config_t *root, const char *fn, int errors)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int config_file_load_user_all(snd_config_t *_root, snd_config_t *_file, int errors)
|
||||||
|
{
|
||||||
|
snd_config_t *file = _file, *root = _root, *n;
|
||||||
|
char *name, *name2, *remain, *rname = NULL;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
if (snd_config_get_type(_file) == SND_CONFIG_TYPE_COMPOUND) {
|
||||||
|
if ((err = snd_config_search(_file, "file", &file)) < 0) {
|
||||||
|
SNDERR("Field file not found");
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
if ((err = snd_config_search(_file, "root", &root)) >= 0) {
|
||||||
|
err = snd_config_get_ascii(root, &rname);
|
||||||
|
if (err < 0) {
|
||||||
|
SNDERR("Field root is bad");
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
err = snd_config_make_compound(&root, rname, 0);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((err = snd_config_get_ascii(file, &name)) < 0)
|
||||||
|
goto _err;
|
||||||
|
name2 = name;
|
||||||
|
remain = strstr(name, "|||");
|
||||||
|
while (1) {
|
||||||
|
if (remain) {
|
||||||
|
*remain = '\0';
|
||||||
|
remain += 3;
|
||||||
|
}
|
||||||
|
err = config_file_load_user(root, name2, errors);
|
||||||
|
if (err < 0)
|
||||||
|
goto _err;
|
||||||
|
if (err == 0) /* first hit wins */
|
||||||
|
break;
|
||||||
|
if (!remain)
|
||||||
|
break;
|
||||||
|
name2 = remain;
|
||||||
|
remain = strstr(remain, "|||");
|
||||||
|
}
|
||||||
|
_err:
|
||||||
|
if (root != _root) {
|
||||||
|
if (err == 0) {
|
||||||
|
if (snd_config_get_type(root) == SND_CONFIG_TYPE_COMPOUND) {
|
||||||
|
if (snd_config_is_empty(root))
|
||||||
|
goto _del;
|
||||||
|
}
|
||||||
|
err = snd_config_make_path(&n, _root, rname, 0, 1);
|
||||||
|
if (err < 0)
|
||||||
|
goto _del;
|
||||||
|
err = snd_config_substitute(n, root);
|
||||||
|
if (err == 0)
|
||||||
|
goto _fin;
|
||||||
|
}
|
||||||
|
_del:
|
||||||
|
snd_config_delete(root);
|
||||||
|
}
|
||||||
|
_fin:
|
||||||
|
free(name);
|
||||||
|
free(rname);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Loads and parses the given configurations files.
|
* \brief Loads and parses the given configurations files.
|
||||||
* \param[in] root Handle to the root configuration node.
|
* \param[in] root Handle to the root configuration node.
|
||||||
|
|
@ -4107,27 +4171,9 @@ int snd_config_hook_load(snd_config_t *root, snd_config_t *config, snd_config_t
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
if (i == idx) {
|
if (i == idx) {
|
||||||
char *name, *name2, *remain;
|
err = config_file_load_user_all(root, n, errors);
|
||||||
if ((err = snd_config_get_ascii(n, &name)) < 0)
|
if (err < 0)
|
||||||
goto _err;
|
goto _err;
|
||||||
name2 = name;
|
|
||||||
remain = strstr(name, "|||");
|
|
||||||
while (1) {
|
|
||||||
if (remain) {
|
|
||||||
*remain = '\0';
|
|
||||||
remain += 3;
|
|
||||||
}
|
|
||||||
err = config_file_load_user(root, name2, errors);
|
|
||||||
if (err < 0)
|
|
||||||
goto _err;
|
|
||||||
if (err == 0) /* first hit wins */
|
|
||||||
break;
|
|
||||||
if (!remain)
|
|
||||||
break;
|
|
||||||
name2 = remain;
|
|
||||||
remain = strstr(remain, "|||");
|
|
||||||
}
|
|
||||||
free(name);
|
|
||||||
idx++;
|
idx++;
|
||||||
hit = 1;
|
hit = 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,12 +59,17 @@ cards.@hooks [
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@func concat
|
root {
|
||||||
strings [
|
@func private_integer
|
||||||
"/var/lib/alsa/card"
|
}
|
||||||
{ @func private_integer }
|
file {
|
||||||
".conf.d"
|
@func concat
|
||||||
]
|
strings [
|
||||||
|
"/var/lib/alsa/card"
|
||||||
|
{ @func private_integer }
|
||||||
|
".conf.d"
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
table {
|
table {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue