alsa-utils/topology/pre-process-external.h
Jaska Uimonen 44d3e8aa44 topology: add simple topology plugin mechanism
Add a simple plugin interface for processing the topology tree. There
can be cases where parts of the topology need to be translated from the
original format into something else. For example one could calculate
some kind of filter coefficients from filter parameters or some other
binary interface parameters from plain text topology tokens.

Mechanism is similar as in alsa-plugins and in the plugin there should
be only 1 function exported of the form:

int _snd_topology_##pluginname##_process (snd_config_t *input, snd_config_t *output)

Input and output parameters are snd_config tree before and after topology2
pre-processing. So the plugin can modify both if needed. There are cases
where the plugin may need to get information from input tree, but make
modifications to the output.

The plugins to be used can be defined in command line with:

alsatplg -DPREPROCESS_PLUGINS="foobar" -c topology.conf -p -o topology.tplg

Multiple plugins should be separated by ":".

Plugins to be used can also be defined with "Define" clause inside the
topology file (but command line takes precedence):

Define {
       PREPROCESS_PLUGINS "foobar"
}

Link: https://github.com/alsa-project/alsa-utils/pull/129
Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-05-03 13:23:36 +02:00

40 lines
1.4 KiB
C

/*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef __PRE_PROCESS_EXTERNAL_H
#define __PRE_PROCESS_EXTERNAL_H
#define PROCESS_FUNC_PREFIX "_snd_topology_"
#define PROCESS_FUNC_POSTFIX "_process"
#define PROCESS_LIB_PREFIX "libalsatplg_module_"
#define PROCESS_LIB_POSTFIX ".so"
/**
* Define the object entry for external pre-process plugins
*/
#define SND_TOPOLOGY_PLUGIN_ENTRY(name) _snd_topology_##name##_process
/**
* Define the plugin
*/
#define SND_TOPOLOGY_PLUGIN_DEFINE_FUNC(plugin) \
__attribute__ ((visibility ("default"))) \
int SND_TOPOLOGY_PLUGIN_ENTRY(plugin) (snd_config_t *input, snd_config_t *output)
typedef int (*plugin_pre_process)(snd_config_t *input, snd_config_t *output);
#endif /* __PRE_PROCESS_EXTERNAL_H */