control: add empty plugin

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2021-04-06 20:34:18 +02:00
parent 493a41bcad
commit adce5f7b65
4 changed files with 106 additions and 2 deletions

View file

@ -1,7 +1,8 @@
EXTRA_LTLIBRARIES = libcontrol.la EXTRA_LTLIBRARIES = libcontrol.la
libcontrol_la_SOURCES = cards.c tlv.c namehint.c hcontrol.c \ libcontrol_la_SOURCES = cards.c tlv.c namehint.c hcontrol.c \
control.c control_hw.c setup.c ctlparse.c \ control.c control_hw.c control_empty.c \
setup.c ctlparse.c \
control_plugin.c control_symbols.c control_plugin.c control_symbols.c
if BUILD_CTL_PLUGIN_REMAP if BUILD_CTL_PLUGIN_REMAP
libcontrol_la_SOURCES += control_remap.c libcontrol_la_SOURCES += control_remap.c

View file

@ -1345,7 +1345,7 @@ snd_ctl_t *snd_async_handler_get_ctl(snd_async_handler_t *handler)
} }
static const char *const build_in_ctls[] = { static const char *const build_in_ctls[] = {
"hw", "remap", "shm", NULL "hw", "empty", "remap", "shm", NULL
}; };
static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name, static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,

101
src/control/control_empty.c Normal file
View file

@ -0,0 +1,101 @@
/**
* \file control/control_empty.c
* \ingroup Control_Plugins
* \brief Control Empty Plugin Interface
* \author Jaroslav Kysela <perex@perex.cz>
* \date 2021
*/
/*
* Control - Empty plugin
* Copyright (c) 2021 by Jaroslav Kysela <perex@perex.cz>
*
*
* 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
*
*/
#include "control_local.h"
#ifndef PIC
/* entry for static linking */
const char *_snd_module_ctl_empty = "";
#endif
/*! \page control_plugins
\section control_plugins_empty Plugin: Empty
This plugin just redirects the control device to another plugin.
\code
ctl.name {
type empty # Empty Control
child STR # Slave name
# or
child { # Child definition
...
}
}
\endcode
\subsection control_plugins_empty_funcref Function reference
<UL>
<LI>_snd_ctl_empty_open()
</UL>
*/
/**
* \brief Creates a new Empty Control
* \param handlep Returns created Control handle
* \param name Name of Control
* \param root Root configuration node
* \param conf Configuration node with empty Control description
* \param mode Control 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_empty_open(snd_ctl_t **handlep, const char *name ATTRIBUTE_UNUSED,
snd_config_t *root, snd_config_t *conf, int mode)
{
snd_config_t *child = NULL;
snd_config_iterator_t i, next;
snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id;
if (snd_config_get_id(n, &id) < 0)
continue;
if (_snd_conf_generic_id(id))
continue;
if (strcmp(id, "child") == 0) {
child = n;
continue;
}
SNDERR("Unknown field %s", id);
return -EINVAL;
}
if (!child) {
SNDERR("child is not defined");
return -EINVAL;
}
return _snd_ctl_open_named_child(handlep, name, root, child, mode, conf);
}
#ifndef DOC_HIDDEN
SND_DLSYM_BUILD_VERSION(_snd_ctl_empty_open, SND_CONTROL_DLSYM_VERSION);
#endif

View file

@ -21,12 +21,14 @@
#ifndef PIC #ifndef PIC
extern const char *_snd_module_control_hw; extern const char *_snd_module_control_hw;
extern const char *_snd_module_control_empty;
extern const char *_snd_module_control_remap; extern const char *_snd_module_control_remap;
extern const char *_snd_module_control_shm; extern const char *_snd_module_control_shm;
extern const char *_snd_module_control_ext; extern const char *_snd_module_control_ext;
static const char **snd_control_open_objects[] = { static const char **snd_control_open_objects[] = {
&_snd_module_control_hw, &_snd_module_control_hw,
&_snd_module_control_empty,
#include "ctl_symbols_list.c" #include "ctl_symbols_list.c"
}; };