OSDN Git Service

Added snd_config_imake_* functions.
[android-x86/external-alsa-lib.git] / include / conf.h
1 /**
2  * \file <alsa/conf.h>
3  * \brief Application interface library for the ALSA driver
4  * \author Jaroslav Kysela <perex@suse.cz>
5  * \author Abramo Bagnara <abramo@alsa-project.org>
6  * \author Takashi Iwai <tiwai@suse.de>
7  * \date 1998-2001
8  *
9  * Application interface library for the ALSA driver
10  *
11  *
12  *   This library is free software; you can redistribute it and/or modify
13  *   it under the terms of the GNU Library General Public License as
14  *   published by the Free Software Foundation; either version 2 of
15  *   the License, or (at your option) any later version.
16  *
17  *   This program is distributed in the hope that it will be useful,
18  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
19  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  *   GNU Library General Public License for more details.
21  *
22  *   You should have received a copy of the GNU Library General Public
23  *   License along with this library; if not, write to the Free Software
24  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25  *
26  */
27
28 #ifndef __ALSA_CONF_H
29 #define __ALSA_CONF_H
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 /**
36  *  \defgroup Config Configuration Interface
37  *  Configuration Interface
38  *  \{
39  */
40
41 /** dlsym version for config evaluate callback */
42 #define SND_CONFIG_DLSYM_VERSION_EVALUATE       _dlsym_config_evaluate_001
43 /** dlsym version for config hook callback */
44 #define SND_CONFIG_DLSYM_VERSION_HOOK           _dlsym_config_hook_001
45
46 /** Config node type */
47 typedef enum _snd_config_type {
48         /** Integer number */
49         SND_CONFIG_TYPE_INTEGER,
50         /** Real number */
51         SND_CONFIG_TYPE_REAL,
52         /** Character string */
53         SND_CONFIG_TYPE_STRING,
54         /** Pointer - runtime only - cannot be saved */
55         SND_CONFIG_TYPE_POINTER,
56         /** Compound */
57         SND_CONFIG_TYPE_COMPOUND = 1024,
58 } snd_config_type_t;
59
60 /** Config node handle */
61 typedef struct _snd_config snd_config_t;
62 /** Config compound iterator */
63 typedef struct _snd_config_iterator *snd_config_iterator_t;
64
65 extern snd_config_t *snd_config;
66
67 int snd_config_top(snd_config_t **config);
68
69 int snd_config_load(snd_config_t *config, snd_input_t *in);
70 int snd_config_save(snd_config_t *config, snd_output_t *out);
71 int snd_config_update(void);
72
73 int snd_config_search(snd_config_t *config, const char *key,
74                       snd_config_t **result);
75 int snd_config_searchv(snd_config_t *config, 
76                        snd_config_t **result, ...);
77 int snd_config_search_definition(snd_config_t *config,
78                                  const char *base, const char *key,
79                                  snd_config_t **result);
80
81 int snd_config_expand(snd_config_t *config, snd_config_t *root,
82                       const char *args, snd_config_t *private_data,
83                       snd_config_t **result);
84 int snd_config_evaluate(snd_config_t *config, snd_config_t *root,
85                         snd_config_t *private_data, snd_config_t **result);
86
87 int snd_config_add(snd_config_t *config, snd_config_t *leaf);
88 int snd_config_delete(snd_config_t *config);
89 int snd_config_copy(snd_config_t **dst, snd_config_t *src);
90
91 int snd_config_make(snd_config_t **config, const char *key,
92                     snd_config_type_t type);
93 int snd_config_make_integer(snd_config_t **config, const char *key);
94 int snd_config_make_real(snd_config_t **config, const char *key);
95 int snd_config_make_string(snd_config_t **config, const char *key);
96 int snd_config_make_pointer(snd_config_t **config, const char *key);
97 int snd_config_make_compound(snd_config_t **config, const char *key, int join);
98
99 int snd_config_imake_integer(snd_config_t **config, const char *key, const long value);
100 int snd_config_imake_real(snd_config_t **config, const char *key, const double value);
101 int snd_config_imake_string(snd_config_t **config, const char *key, const char *ascii);
102 int snd_config_imake_pointer(snd_config_t **config, const char *key, const void *ptr);
103
104 snd_config_type_t snd_config_get_type(snd_config_t *config);
105
106 int snd_config_set_id(snd_config_t *config, const char *id);
107 int snd_config_set_integer(snd_config_t *config, long value);
108 int snd_config_set_real(snd_config_t *config, double value);
109 int snd_config_set_string(snd_config_t *config, const char *value);
110 int snd_config_set_ascii(snd_config_t *config, const char *ascii);
111 int snd_config_set_pointer(snd_config_t *config, const void *ptr);
112 int snd_config_get_id(snd_config_t *config, const char **value);
113 int snd_config_get_integer(snd_config_t *config, long *value);
114 int snd_config_get_real(snd_config_t *config, double *value);
115 int snd_config_get_string(snd_config_t *config, const char **value);
116 int snd_config_get_ascii(snd_config_t *config, char **value);
117 int snd_config_get_pointer(snd_config_t *config, const void **value);
118 int snd_config_test_id(snd_config_t *config, const char *id);
119
120 snd_config_iterator_t snd_config_iterator_first(snd_config_t *node);
121 snd_config_iterator_t snd_config_iterator_next(snd_config_iterator_t iterator);
122 snd_config_iterator_t snd_config_iterator_end(snd_config_t *node);
123 snd_config_t *snd_config_iterator_entry(snd_config_iterator_t iterator);
124
125 /** Helper for compound config node leaves traversal
126  * \param pos Current node iterator
127  * \param next Next node iterator
128  * \param node Compound config node
129  *
130  * This macro is designed to permit the removal of current node.
131  */
132 #define snd_config_for_each(pos, next, node) \
133         for (pos = snd_config_iterator_first(node), next = snd_config_iterator_next(pos); pos != snd_config_iterator_end(node); pos = next, next = snd_config_iterator_next(pos))
134
135 /* Misc functions */
136
137 int snd_config_get_bool_ascii(const char *ascii);
138 int snd_config_get_bool(snd_config_t *conf);
139 int snd_config_get_ctl_iface_ascii(const char *ascii);
140 int snd_config_get_ctl_iface(snd_config_t *conf);
141
142 /** \} */
143
144 #ifdef __cplusplus
145 }
146 #endif
147
148 #endif /* __ALSA_CONF_H */
149