mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2026-03-20 05:33:44 -04:00
ucm: substitute define IDs and macro arguments (Syntax 9)
It is useful to substitute the variable names and string
macro arguments. It may simplify the UCM configurations.
E.g.:
Define."${var:Name} Suffix" "Value"
Macro.a.DoIt "Channels=${var:PlaybackChannels}"
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
5414277612
commit
e02e9dc6cf
2 changed files with 22 additions and 4 deletions
|
|
@ -391,7 +391,7 @@ static int evaluate_define(snd_use_case_mgr_t *uc_mgr,
|
||||||
snd_config_iterator_t i, next;
|
snd_config_iterator_t i, next;
|
||||||
snd_config_t *d, *n;
|
snd_config_t *d, *n;
|
||||||
const char *id;
|
const char *id;
|
||||||
char *var, *s;
|
char *var, *s, *sid;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = snd_config_search(cfg, "Define", &d);
|
err = snd_config_search(cfg, "Define", &d);
|
||||||
|
|
@ -427,8 +427,18 @@ static int evaluate_define(snd_use_case_mgr_t *uc_mgr,
|
||||||
snd_error(UCM, "value names starting with '@' are reserved for application variables");
|
snd_error(UCM, "value names starting with '@' are reserved for application variables");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
err = uc_mgr_set_variable(uc_mgr, id, s);
|
sid = (char *)id;
|
||||||
|
if (uc_mgr->conf_format >= 9) {
|
||||||
|
err = uc_mgr_get_substituted_value(uc_mgr, &sid, id);
|
||||||
|
if (err < 0) {
|
||||||
|
free(s);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
err = uc_mgr_set_variable(uc_mgr, sid, s);
|
||||||
free(s);
|
free(s);
|
||||||
|
if (id != sid)
|
||||||
|
free(sid);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
@ -495,7 +505,15 @@ static int evaluate_macro1(snd_use_case_mgr_t *uc_mgr,
|
||||||
err = snd_config_get_string(args, &s);
|
err = snd_config_get_string(args, &s);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
err = snd_config_load_string(&a, s, 0);
|
if (uc_mgr->conf_format < 9) {
|
||||||
|
err = snd_config_load_string(&a, s, 0);
|
||||||
|
} else {
|
||||||
|
err = uc_mgr_get_substituted_value(uc_mgr, &var2, s);
|
||||||
|
if (err >= 0) {
|
||||||
|
err = snd_config_load_string(&a, var2, 0);
|
||||||
|
free(var2);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
} else if (snd_config_get_type(args) != SND_CONFIG_TYPE_COMPOUND) {
|
} else if (snd_config_get_type(args) != SND_CONFIG_TYPE_COMPOUND) {
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "use-case.h"
|
#include "use-case.h"
|
||||||
|
|
||||||
#define SYNTAX_VERSION_MAX 8
|
#define SYNTAX_VERSION_MAX 9
|
||||||
|
|
||||||
#define MAX_CARD_SHORT_NAME 32
|
#define MAX_CARD_SHORT_NAME 32
|
||||||
#define MAX_CARD_LONG_NAME 80
|
#define MAX_CARD_LONG_NAME 80
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue