OSDN Git Service

Changed Jaroslav Kysela's e-mail from perex@suse.cz to perex@perex.cz
[android-x86/external-alsa-lib.git] / src / pcm / pcm_empty.c
1 /**
2  * \file pcm/pcm_empty.c
3  * \ingroup PCM_Plugins
4  * \brief PCM Null Plugin Interface
5  * \author Jaroslav Kysela <perex@perex.cz>
6  * \date 2006
7  */
8 /*
9  *  PCM - Null plugin
10  *  Copyright (c) 2006 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
26  *
27  */
28   
29 #include "pcm_local.h"
30 #include "pcm_plugin.h"
31
32 #ifndef PIC
33 /* entry for static linking */
34 const char *_snd_module_pcm_empty = "";
35 #endif
36
37 /*! \page pcm_plugins
38
39 \section pcm_plugins_null Plugin: Null
40
41 This plugin discards contents of a PCM stream or creates a stream with zero
42 samples.
43
44 Note: This implementation uses devices /dev/null (playback, must be writable)
45 and /dev/full (capture, must be readable).
46
47 \code
48 pcm.name {
49         type null               # Null PCM
50 }
51 \endcode
52
53 \subsection pcm_plugins_null_funcref Function reference
54
55 <UL>
56   <LI>_snd_pcm_empty_open()
57 </UL>
58
59 */
60
61 /**
62  * \brief Creates a new Empty PCM
63  * \param pcmp Returns created PCM handle
64  * \param name Name of PCM
65  * \param root Root configuration node
66  * \param conf Configuration node with empty PCM description
67  * \param stream Stream type
68  * \param mode Stream mode
69  * \retval zero on success otherwise a negative error code
70  * \warning Using of this function might be dangerous in the sense
71  *          of compatibility reasons. The prototype might be freely
72  *          changed in future.
73  */
74 int _snd_pcm_empty_open(snd_pcm_t **pcmp, const char *name ATTRIBUTE_UNUSED,
75                         snd_config_t *root, snd_config_t *conf, 
76                         snd_pcm_stream_t stream, int mode)
77 {
78         snd_config_t *slave = NULL, *sconf;
79         snd_config_iterator_t i, next;
80         int err;
81
82         snd_config_for_each(i, next, conf) {
83                 snd_config_t *n = snd_config_iterator_entry(i);
84                 const char *id;
85                 if (snd_config_get_id(n, &id) < 0)
86                         continue;
87                 if (snd_pcm_conf_generic_id(id))
88                         continue;
89                 if (strcmp(id, "slave") == 0) {
90                         slave = n;
91                         continue;
92                 }
93                 SNDERR("Unknown field %s", id);
94                 return -EINVAL;
95         }
96         if (!slave) {
97                 SNDERR("slave is not defined");
98                 return -EINVAL;
99         }
100         err = snd_pcm_slave_conf(root, slave, &sconf, 0);
101         if (err < 0)
102                 return err;
103         err = snd_pcm_open_slave(pcmp, root, sconf, stream, mode, conf);
104         snd_config_delete(sconf);
105         return err;
106 }
107 #ifndef DOC_HIDDEN
108 SND_DLSYM_BUILD_VERSION(_snd_pcm_empty_open, SND_PCM_DLSYM_VERSION);
109 #endif