mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2026-02-28 01:40:08 -05:00
ucm: define and describe Syntax 7
- for new macro argument substitution - for new Path condition fields substitutions Link: https://github.com/alsa-project/alsa-ucm-conf/pull/411 Link: https://github.com/alsa-project/alsa-lib/issues/395 Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
c6cd83bd0a
commit
3864f7d95f
4 changed files with 41 additions and 16 deletions
|
|
@ -454,11 +454,16 @@ static int evaluate_macro1(snd_use_case_mgr_t *uc_mgr,
|
||||||
err = snd_config_get_ascii(n, &var);
|
err = snd_config_get_ascii(n, &var);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto __err_path;
|
goto __err_path;
|
||||||
err = uc_mgr_get_substituted_value(uc_mgr, &var2, var);
|
if (uc_mgr->conf_format < 7) {
|
||||||
free(var);
|
err = uc_mgr_set_variable(uc_mgr, name, var);
|
||||||
if (err >= 0) {
|
free(var);
|
||||||
err = uc_mgr_set_variable(uc_mgr, name, var2);
|
} else {
|
||||||
free(var2);
|
err = uc_mgr_get_substituted_value(uc_mgr, &var2, var);
|
||||||
|
free(var);
|
||||||
|
if (err >= 0) {
|
||||||
|
err = uc_mgr_set_variable(uc_mgr, name, var2);
|
||||||
|
free(var2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto __err_path;
|
goto __err_path;
|
||||||
|
|
|
||||||
|
|
@ -293,9 +293,13 @@ static int if_eval_path(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = uc_mgr_get_substituted_value(uc_mgr, &s, mode);
|
if (uc_mgr->conf_format < 7) {
|
||||||
if (err < 0)
|
s = (char *)mode;
|
||||||
return err;
|
} else {
|
||||||
|
err = uc_mgr_get_substituted_value(uc_mgr, &s, mode);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
}
|
||||||
if (strncasecmp(s, "exist", 5) == 0) {
|
if (strncasecmp(s, "exist", 5) == 0) {
|
||||||
amode = F_OK;
|
amode = F_OK;
|
||||||
} else if (strcasecmp(s, "read") == 0) {
|
} else if (strcasecmp(s, "read") == 0) {
|
||||||
|
|
@ -309,17 +313,23 @@ static int if_eval_path(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval)
|
||||||
free(s);
|
free(s);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
free(s);
|
if (s != mode)
|
||||||
|
free(s);
|
||||||
|
|
||||||
err = uc_mgr_get_substituted_value(uc_mgr, &s, path);
|
if (uc_mgr->conf_format < 7) {
|
||||||
if (err < 0)
|
s = (char *)path;
|
||||||
return err;
|
} else {
|
||||||
|
err = uc_mgr_get_substituted_value(uc_mgr, &s, path);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
}
|
||||||
#ifdef HAVE_EACCESS
|
#ifdef HAVE_EACCESS
|
||||||
err = eaccess(s, amode);
|
err = eaccess(s, amode);
|
||||||
#else
|
#else
|
||||||
err = access(s, amode);
|
err = access(s, amode);
|
||||||
#endif
|
#endif
|
||||||
free(s);
|
if (s != path)
|
||||||
|
free(s);
|
||||||
return err ? 0 : 1;
|
return err ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ use case verbs for that sound card. i.e.:
|
||||||
# Example master file for blah sound card
|
# Example master file for blah sound card
|
||||||
# By Joe Blogs <joe@bloggs.org>
|
# By Joe Blogs <joe@bloggs.org>
|
||||||
|
|
||||||
Syntax 6
|
Syntax 7
|
||||||
|
|
||||||
# Use Case name for user interface
|
# Use Case name for user interface
|
||||||
Comment "Nice Abstracted Soundcard"
|
Comment "Nice Abstracted Soundcard"
|
||||||
|
|
@ -489,7 +489,8 @@ DefineMacro.macro1 {
|
||||||
The arguments in the macro are refered as the variables with the double
|
The arguments in the macro are refered as the variables with the double
|
||||||
underscore name prefix (like *__variable*). The configuration block in
|
underscore name prefix (like *__variable*). The configuration block in
|
||||||
the DefineMacro subtree is always evaluated (including arguments and variables)
|
the DefineMacro subtree is always evaluated (including arguments and variables)
|
||||||
at the time of the instantiation.
|
at the time of the instantiation. Argument string substitutions
|
||||||
|
(for multiple macro call levels) were added in *Syntax* version *7*.
|
||||||
|
|
||||||
The macros can be instantiated (expanded) using:
|
The macros can be instantiated (expanded) using:
|
||||||
|
|
||||||
|
|
@ -563,6 +564,15 @@ Field | Description
|
||||||
String | string
|
String | string
|
||||||
Regex | regex expression (extended posix, ignore case)
|
Regex | regex expression (extended posix, ignore case)
|
||||||
|
|
||||||
|
#### Path is present (Type Path)
|
||||||
|
|
||||||
|
Field | Description
|
||||||
|
---------------------|-----------------------
|
||||||
|
Path | path (filename)
|
||||||
|
Mode | exist,read,write,exec
|
||||||
|
|
||||||
|
Note: Substitution for Path and Mode fields were added in *Syntax* version *7*.
|
||||||
|
|
||||||
#### ALSA control element exists (Type ControlExists)
|
#### ALSA control element exists (Type ControlExists)
|
||||||
|
|
||||||
Field | Description
|
Field | Description
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "use-case.h"
|
#include "use-case.h"
|
||||||
|
|
||||||
#define SYNTAX_VERSION_MAX 6
|
#define SYNTAX_VERSION_MAX 7
|
||||||
|
|
||||||
#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