]> git.alsa-project.org Git - alsa-utils.git/commit
topology: pre-processor: Introduce a new feature for subtree
authorRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Wed, 22 May 2024 23:29:34 +0000 (16:29 -0700)
committerJaroslav Kysela <perex@perex.cz>
Tue, 6 Aug 2024 16:32:52 +0000 (18:32 +0200)
commit6e3fc0433e7eddf16e8c7766c0b578c7659e8d9c
tree160677e59722db509beebc9fa868a1da2904c5ab
parent21e0adfa3bd737669cc31bb6a1426c2f27ce20f0
topology: pre-processor: Introduce a new feature for subtree

Introduce a new kyword "SubTreeCopy" for extneding existing conf nodes
with additional nodes. This feature is useful for extending previous
pipeline class definitions with the addition of one or more widgets
without having to duplicate everything in the new class definition.

For example: Consider a pipeline class definition as below. Note that
only the widgets & routes are shown here.

Class.Pipeline.mixout-gain-dai-copier-playback {
Object.Widget {
mixout."1" {}
dai-copier."1" {}
gain."1" {}
pipeline."1" {}
}

Object.Base {
!route [
{
source mixout.$index.1
sink gain.$index.1
}
]
}
}

If we want to extend this pipeline with the addition of an eqiir/eqfir,
we can create a SubTreeCopy node with type extend as follows:

Class.Pipeline.mixout-gain-eqiir-eqfir-dai-copier-playback {
SubTreeCopy.baseclass {
source "Class.Pipeline.mixout-gain-dai-copier-playback"
type extend

                tree {
Object.Widget {
eqiir.1 {}
eqfir.1 {}
}

Object.Base {
!route [
{
source gain.$index.1
sink   eqiir.$index.1
}
{
source eqiir.$index.1
sink   eqfir.$index.1
}
]
}
}
}
}

Note that the target is left undefined, which means that the newly
created subtree will be merged to the parent node that contains the
"SubTreeCopy" node i.e. in this case
Class.Pipeline.mixout-gain-eqiir-eqfir-dai-copier-playback".

But if we want to modify an existing pipeline class while modifying the
order of widgets and/or inserting new widgets, we should use the type
"override" instead. This allows for adding new widgets to the list of
widgets in the base class definition while also allowing overriding the
routes to allow inserting the new widgets and reordering the widgets in
the base class. For example, if we want to add a drc widget between the
gain and the eqiir modules in the above class, we can do the following:

Class.Pipeline.mixout-efx-dai-copier-playback {
# This copy will override all widgets/routes in the base class
SubTreeCopy.baseclass {
source "Class.Pipeline.mixout-gain-eqiir-eqfir-dai-copier-playback"
target "Class.Pipeline"
type override

tree {
Object.Widget {
drc.1 {}
}

Object.Base {
!route [
{
source mixout.$index.1
sink gain.$index.1
}
{
source gain.$index.1
sink drc.$index.1
}
{
source drc.$index.1
sink eqiir.$index.1
}
{
source eqiir.$index.1
sink eqfir.$index.1
}
]
}
}
}

# Explicitly copy the widgets from the base class now
SubTreeCopy.widgets {
source "Class.Pipeline.mixout-gain-eqiir-eqfir-dai-copier-playback.Object.Widget"
target "Class.Pipeline.mixout-efx-dai-copier-playback.Object.Widget"
}
}

Closes: https://github.com/alsa-project/alsa-utils/pull/268
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
topology/pre-processor.c