1 /**
2 * \file control/control_empty.c
3 * \ingroup Control_Plugins
4 * \brief Control Empty Plugin Interface
5 * \author Jaroslav Kysela <perex@perex.cz>
6 * \date 2021
7 */
8 /*
9 * Control - Empty plugin
10 * Copyright (c) 2021 by Jaroslav Kysela <perex@perex.cz>
11 *
12 *
13 * This library is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU Lesser General Public License as
15 * published by the Free Software Foundation; either version 2.1 of
16 * the License, or (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License for more details.
22 *
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this library; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 *
27 */
28
29 #include "control_local.h"
30
31 #ifndef PIC
32 /* entry for static linking */
33 const char *_snd_module_control_empty = "";
34 #endif
35
36 /*! \page control_plugins
37
38 \section control_plugins_empty Plugin: Empty
39
40 This plugin just redirects the control device to another plugin.
41
42 \code
43 ctl.name {
44 type empty # Empty Control
45 child STR # Slave name
46 # or
47 child { # Child definition
48 ...
49 }
50 }
51 \endcode
52
53 \subsection control_plugins_empty_funcref Function reference
54
55 <UL>
56 <LI>_snd_ctl_empty_open()
57 </UL>
58
59 */
60
61 /**
62 * \brief Creates a new Empty Control
63 * \param handlep Returns created Control handle
64 * \param name Name of Control
65 * \param root Root configuration node
66 * \param conf Configuration node with empty Control description
67 * \param mode Control mode
68 * \retval zero on success otherwise a negative error code
69 * \warning Using of this function might be dangerous in the sense
70 * of compatibility reasons. The prototype might be freely
71 * changed in future.
72 */
_snd_ctl_empty_open(snd_ctl_t ** handlep,const char * name ATTRIBUTE_UNUSED,snd_config_t * root,snd_config_t * conf,int mode)73 int _snd_ctl_empty_open(snd_ctl_t **handlep, const char *name ATTRIBUTE_UNUSED,
74 snd_config_t *root, snd_config_t *conf, int mode)
75 {
76 snd_config_t *child = NULL;
77 snd_config_iterator_t i, next;
78
79 snd_config_for_each(i, next, conf) {
80 snd_config_t *n = snd_config_iterator_entry(i);
81 const char *id;
82 if (snd_config_get_id(n, &id) < 0)
83 continue;
84 if (_snd_conf_generic_id(id))
85 continue;
86 if (strcmp(id, "child") == 0) {
87 child = n;
88 continue;
89 }
90 SNDERR("Unknown field %s", id);
91 return -EINVAL;
92 }
93 if (!child) {
94 SNDERR("child is not defined");
95 return -EINVAL;
96 }
97 return _snd_ctl_open_named_child(handlep, name, root, child, mode, conf);
98 }
99 #ifndef DOC_HIDDEN
100 SND_DLSYM_BUILD_VERSION(_snd_ctl_empty_open, SND_CONTROL_DLSYM_VERSION);
101 #endif
102