mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-09 18:05:42 +01:00
topology: pre-processor: support to include conf block with IncludeByKey
Currently, The IncludeByKey mechanism only supports conditionally including a topology conf file. Even if we only want to conditionally include a small conf block, we have to use a conf file and in the end we will have a lot of trivial conf files that only contain a single conf blocks. This patch extends the use of IncludeByKey ito support including conf blocks conditionally. For example, the block below will include the route conditionally based on the variable definition COPIER_ROUTE. Define { COPIER_ROUTE 1 } IncludeByKey.COPIER_ROUTE { "1" { Object.Base.route.11 { source copier.module.8.2 sink copier.module.17.2 } } } Fixes: https://github.com/alsa-project/alsa-utils/pull/187 Signed-off-by: Chao Song <chao.song@linux.intel.com> Co-authored-by: Jaroslav Kysela <perex@perex.cz> Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
df3da091cc
commit
1350900246
1 changed files with 32 additions and 21 deletions
|
@ -504,7 +504,15 @@ static int pre_process_include_conf(struct tplg_pre_processor *tplg_pp, snd_conf
|
|||
if (ret)
|
||||
continue;
|
||||
|
||||
/* regex matched. now include the conf file */
|
||||
/* regex matched. now include or use the configuration */
|
||||
if (snd_config_get_type(n) == SND_CONFIG_TYPE_COMPOUND) {
|
||||
/* configuration block */
|
||||
ret = snd_config_merge(*new, n, 0);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Unable to merge key '%s'\n", value);
|
||||
goto err;
|
||||
}
|
||||
} else {
|
||||
ret = snd_config_get_string(n, &filename);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
@ -529,6 +537,7 @@ static int pre_process_include_conf(struct tplg_pre_processor *tplg_pp, snd_conf
|
|||
fprintf(stderr, "Unable to load included configuration\n");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
/* forcefully overwrite with defines from the command line */
|
||||
ret = pre_process_add_defines(tplg_pp, *new);
|
||||
|
@ -538,7 +547,9 @@ static int pre_process_include_conf(struct tplg_pre_processor *tplg_pp, snd_conf
|
|||
}
|
||||
|
||||
/* recursively process any nested includes */
|
||||
return pre_process_includes(tplg_pp, *new);
|
||||
ret = pre_process_includes(tplg_pp, *new);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
}
|
||||
|
||||
err:
|
||||
|
|
Loading…
Reference in a new issue