]> git.alsa-project.org Git - alsa-utils.git/commit
topology: pre-process-object: Expand definitions within strings
authorJyri Sarha <jyri.sarha@intel.com>
Mon, 16 Jan 2023 21:17:23 +0000 (23:17 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 6 Feb 2023 14:49:14 +0000 (15:49 +0100)
commitcf25cf67675235cc35529c717ed89f397aa3f171
treeeeb3d3e95d17a86b19c2656481805897ecca49a8
parent4d7275d7f86bf5fd14750a160512ec75de8bedad
topology: pre-process-object: Expand definitions within strings

Expand the pre-processor to allow for expanding the definitions,
object attribute references and arithmetic expressions within strings.

With this extension its possible to embedded definitions or attribute
references into topology string objects. For example:

Define {
       PCM_NUMBER 1
}

Object.Pipeline {
pcm-playback.0 {

Object.Widget {
copier.1 {
copier_type "host"
}
gain.1 {
Object.Control.mixer.1 {
name 'hw:$[$PCM_NUMBER - 1] Playback Volume'
}
}

Object.Base {
route.1 {
source copier.host.$index.1
sink gain.$index.1
}
}
}

In the example the $[$PCM_NUMBER - 1] would be replaced with the
result of arithmetic expression '1 - 1' in other words '0' , and
$index in all occurrences with index attribute found from pipeline
object. Any non alpha numeric or '_' character are treated as
delimiters for variable names if $[]-notation is not used.

Fixes: https://github.com/alsa-project/alsa-utils/pull/189
Signed-off-by: Jyri Sarha <jyri.sarha@intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
topology/pre-process-object.c