ucm: implement MacroDefine and Macro subtree evaluation

The arguments are set as temporary variables as /MACRO_NAME/_/ARGUMENT_NAME/.

Example:

  # define new macro MyMacro with arguments ctl_name and ctl_value
  DefineMacro.MyMacro {
    BootSequence [
      cset "name='${var:MyMacro_ctl_name}' ${var:MyMacro_ctl_value}"
    ]
  }

  # instantiate macro for Speaker control (short version)
  Macro.headphone.MyMacro "ctl_name='Speaker Switch',ctl_value=off"

  # instantiate macro for Mic control (second version)
  Macro.mic.MyMacro {
	ctl_name "Mic Switch"
	ctl_value "off"
  }

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2022-05-13 16:07:38 +02:00
parent 3e5a894378
commit d7d5c724ed
6 changed files with 252 additions and 9 deletions

View file

@ -262,6 +262,9 @@ struct snd_use_case_mgr {
/* list of opened control devices */
struct list_head ctl_list;
/* tree with macros */
snd_config_t *macros;
/* local library configuration */
snd_config_t *local_config;
@ -334,6 +337,8 @@ int uc_mgr_set_variable(snd_use_case_mgr_t *uc_mgr,
const char *name,
const char *val);
int uc_mgr_delete_variable(snd_use_case_mgr_t *uc_mgr, const char *name);
int uc_mgr_get_substituted_value(snd_use_case_mgr_t *uc_mgr,
char **_rvalue,
const char *value);