diff --git a/include/Makefile.am b/include/Makefile.am index 665704a3..d5a421fb 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -7,6 +7,9 @@ alsainclude_HEADERS = asoundlib.h asoundef.h \ version.h global.h input.h output.h error.h \ conf.h control.h +if BUILD_CTL_PLUGIN +alsainclude_HEADERS += control_plugin.h +endif if BUILD_CTL_PLUGIN_EXT alsainclude_HEADERS += control_external.h endif diff --git a/include/control_plugin.h b/include/control_plugin.h index 3c0c8ae4..65146869 100644 --- a/include/control_plugin.h +++ b/include/control_plugin.h @@ -42,7 +42,14 @@ * Control HW */ int snd_ctl_hw_open(snd_ctl_t **handle, const char *name, int card, int mode); -int _snd_ctl_hw_open(snd_ctl_t **handlep, char *name, snd_config_t *root ATTRIBUTE_UNUSED, snd_config_t *conf, int mode); +int _snd_ctl_hw_open(snd_ctl_t **handlep, char *name, snd_config_t *root, snd_config_t *conf, int mode); + +/* + * Control Remap & Map + */ +int snd_ctl_remap_open(snd_ctl_t **handlep, const char *name, snd_config_t *remap, + snd_config_t *map, snd_ctl_t *child, int mode); +int _snd_ctl_remap_open(snd_ctl_t **handlep, char *name, snd_config_t *root, snd_config_t *conf, int mode); /** \} */ diff --git a/src/control/control_remap.c b/src/control/control_remap.c index 097009ea..3c970cb8 100644 --- a/src/control/control_remap.c +++ b/src/control/control_remap.c @@ -1,3 +1,9 @@ +/** + * \file control/control_remap.c + * \brief CTL Remap Plugin Interface + * \author Jaroslav Kysela + * \date 2021 + */ /* * Control - Remap Controls * Copyright (c) 2021 by Jaroslav Kysela @@ -1127,6 +1133,18 @@ static int parse_map(snd_ctl_remap_t *priv, snd_config_t *conf) return 0; } +/** + * \brief Creates a new remap & map control handle + * \param handlep Returns created control handle + * \param name Name of control device + * \param remap Remap configuration + * \param map Map configuration + * \param mode Control handle mode + * \retval zero on success otherwise a negative error code + * \warning Using of this function might be dangerous in the sense + * of compatibility reasons. The prototype might be freely + * changed in future. + */ int snd_ctl_remap_open(snd_ctl_t **handlep, const char *name, snd_config_t *remap, snd_config_t *map, snd_ctl_t *child, int mode ATTRIBUTE_UNUSED) { @@ -1176,6 +1194,77 @@ int snd_ctl_remap_open(snd_ctl_t **handlep, const char *name, snd_config_t *rema return result; } +/*! \page control_plugins + +\section control_plugins_remap Plugin: Remap & map + +This plugin can remap (rename) identifiers (except the numid part) for +a child control to another. The plugin can also merge the multiple +child controls to one or split one control to more. + +\code +ctl.name { + type remap # Route & Volume conversion PCM + child STR # Slave name + # or + child { # Slave definition + type STR + ... + } + remap { + # the ID strings are parsed in the amixer style like 'name="Headphone Playback Switch",index=2' + SRC_ID1_STR DST_ID1_STR + SRC_ID2_STR DST_ID2_STR + ... + } + map { + # join two stereo controls to one + CREATE_ID1_STR { + SRC_ID1_STR { + vindex.0 0 # source channel 0 to merged channel 0 + vindex.1 1 + } + SRC_ID2_STR { + vindex.2 0 + vindex.3 1 # source channel 1 to merged channel 3 + } + } + # split stereo to mono + CREATE_ID2_STR { + SRC_ID3_STR { + vindex.0 0 # stereo to mono (first channel) + } + } + CREATE_ID3_STR { + SRC_ID4_STR { + vindex.0 1 # stereo to mono (second channel) + } + } + } +} +\endcode + +\subsection control_plugins_route_funcref Function reference + + + +*/ + +/** + * \brief Creates a new remap & map control plugin + * \param handlep Returns created control handle + * \param name Name of control + * \param root Root configuration node + * \param conf Configuration node with Route & Volume PCM description + * \param mode Control handle mode + * \retval zero on success otherwise a negative error code + * \warning Using of this function might be dangerous in the sense + * of compatibility reasons. The prototype might be freely + * changed in future. + */ int _snd_ctl_remap_open(snd_ctl_t **handlep, char *name, snd_config_t *root, snd_config_t *conf, int mode) { snd_config_iterator_t i, next;