mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-03 09:01:52 -05:00
ucm: allow passing variables through ucm open string
It is useful to pass information like application capabilities
to the UCM configuration parser. Those variables are prefixed
with '@' for the configuration files.
An example:
"<<<v1='a b c',x=12>>>hw:1"
Variables can substituted in the configuration:
"${var:@v1}" -> "a b c"
"${var:@x}" -> 12
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
46e991c9ce
commit
11ec9e497e
2 changed files with 63 additions and 0 deletions
|
|
@ -278,6 +278,10 @@ static int evaluate_regex(snd_use_case_mgr_t *uc_mgr,
|
|||
err = snd_config_get_id(n, &id);
|
||||
if (err < 0)
|
||||
return err;
|
||||
if (id[0] == '@') {
|
||||
uc_error("error: value names starting with '@' are reserved for application variables");
|
||||
return -EINVAL;
|
||||
}
|
||||
err = uc_mgr_define_regex(uc_mgr, id, n);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
|
@ -327,6 +331,11 @@ static int evaluate_define(snd_use_case_mgr_t *uc_mgr,
|
|||
free(var);
|
||||
if (err < 0)
|
||||
return err;
|
||||
if (id[0] == '@') {
|
||||
free(s);
|
||||
uc_error("error: value names starting with '@' are reserved for application variables");
|
||||
return -EINVAL;
|
||||
}
|
||||
err = uc_mgr_set_variable(uc_mgr, id, s);
|
||||
free(s);
|
||||
if (err < 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue