summaryrefslogtreecommitdiff
path: root/src/control
diff options
context:
space:
mode:
authorJaroslav Kysela <perex@perex.cz>2021-04-06 20:34:18 +0200
committerJaroslav Kysela <perex@perex.cz>2021-04-07 16:24:20 +0200
commitadce5f7b65fadd1636c3e3392ea54cde4a9a3586 (patch)
tree218e17498ecc1413553cdb0abf73f0b6773ee137 /src/control
parent493a41bcad9fc9ba3ecd0c5b4dafa0a46e3fd3ee (diff)
downloadalsa-lib-adce5f7b65fadd1636c3e3392ea54cde4a9a3586.tar.gz
control: add empty plugin
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'src/control')
-rw-r--r--src/control/Makefile.am3
-rw-r--r--src/control/control.c2
-rw-r--r--src/control/control_empty.c101
-rw-r--r--src/control/control_symbols.c2
4 files changed, 106 insertions, 2 deletions
diff --git a/src/control/Makefile.am b/src/control/Makefile.am
index 50802699..eb66fa50 100644
--- a/src/control/Makefile.am
+++ b/src/control/Makefile.am
@@ -1,7 +1,8 @@
EXTRA_LTLIBRARIES = libcontrol.la
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
if BUILD_CTL_PLUGIN_REMAP
libcontrol_la_SOURCES += control_remap.c
diff --git a/src/control/control.c b/src/control/control.c
index 1968d5a8..602735db 100644
--- a/src/control/control.c
+++ b/src/control/control.c
@@ -1345,7 +1345,7 @@ snd_ctl_t *snd_async_handler_get_ctl(snd_async_handler_t *handler)
}
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,
diff --git a/src/control/control_empty.c b/src/control/control_empty.c
new file mode 100644
index 00000000..49d1026c
--- /dev/null
+++ b/src/control/control_empty.c
@@ -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
diff --git a/src/control/control_symbols.c b/src/control/control_symbols.c
index 10d4689a..5e6c4e9f 100644
--- a/src/control/control_symbols.c
+++ b/src/control/control_symbols.c
@@ -21,12 +21,14 @@
#ifndef PIC
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_shm;
extern const char *_snd_module_control_ext;
static const char **snd_control_open_objects[] = {
&_snd_module_control_hw,
+ &_snd_module_control_empty,
#include "ctl_symbols_list.c"
};