extend documentation for pa_channel_map_init()
[profile/ivi/pulseaudio-panda.git] / src / pulse / channelmap.h
1 #ifndef foochannelmaphfoo
2 #define foochannelmaphfoo
3
4 /***
5   This file is part of PulseAudio.
6
7   Copyright 2005-2006 Lennart Poettering
8   Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
9
10   PulseAudio is free software; you can redistribute it and/or modify
11   it under the terms of the GNU Lesser General Public License as published
12   by the Free Software Foundation; either version 2 of the License,
13   or (at your option) any later version.
14
15   PulseAudio is distributed in the hope that it will be useful, but
16   WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18   General Public License for more details.
19
20   You should have received a copy of the GNU Lesser General Public License
21   along with PulseAudio; if not, write to the Free Software
22   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23   USA.
24 ***/
25
26 #include <pulse/sample.h>
27 #include <pulse/cdecl.h>
28 #include <pulse/gccmacro.h>
29
30 /** \page channelmap Channel Maps
31  *
32  * \section overv_sec Overview
33  *
34  * Channel maps provide a way to associate channels in a stream with a
35  * specific speaker position. This relieves applications of having to
36  * make sure their channel order is identical to the final output.
37  *
38  * \section init_sec Initialisation
39  *
40  * A channel map consists of an array of \ref pa_channel_position values,
41  * one for each channel. This array is stored together with a channel count
42  * in a pa_channel_map structure.
43  *
44  * Before filling the structure, the application must initialise it using
45  * pa_channel_map_init(). There are also a number of convenience functions
46  * for standard channel mappings:
47  *
48  * \li pa_channel_map_init_mono() - Create a channel map with only mono audio.
49  * \li pa_channel_map_init_stereo() - Create a standard stereo mapping.
50  * \li pa_channel_map_init_auto() - Create a standard channel map for a specific number of channels
51  * \li pa_channel_map_init_extend() - Similar to
52  * pa_channel_map_init_auto() but synthesize a channel map if noone
53  * predefined one is known for the specified number of channels.
54  *
55  * \section conv_sec Convenience Functions
56  *
57  * The library contains a number of convenience functions for dealing with
58  * channel maps:
59  *
60  * \li pa_channel_map_valid() - Tests if a channel map is valid.
61  * \li pa_channel_map_equal() - Tests if two channel maps are identical.
62  * \li pa_channel_map_snprint() - Creates a textual description of a channel
63  *                                map.
64  */
65
66 /** \file
67  * Constants and routines for channel mapping handling */
68
69 PA_C_DECL_BEGIN
70
71 /** A list of channel labels */
72 typedef enum pa_channel_position {
73     PA_CHANNEL_POSITION_INVALID = -1,
74     PA_CHANNEL_POSITION_MONO = 0,
75
76     PA_CHANNEL_POSITION_LEFT,
77     PA_CHANNEL_POSITION_RIGHT,
78     PA_CHANNEL_POSITION_CENTER,
79
80     PA_CHANNEL_POSITION_FRONT_LEFT = PA_CHANNEL_POSITION_LEFT,
81     PA_CHANNEL_POSITION_FRONT_RIGHT = PA_CHANNEL_POSITION_RIGHT,
82     PA_CHANNEL_POSITION_FRONT_CENTER = PA_CHANNEL_POSITION_CENTER,
83
84     PA_CHANNEL_POSITION_REAR_CENTER,
85     PA_CHANNEL_POSITION_REAR_LEFT,
86     PA_CHANNEL_POSITION_REAR_RIGHT,
87
88     PA_CHANNEL_POSITION_LFE,
89     PA_CHANNEL_POSITION_SUBWOOFER = PA_CHANNEL_POSITION_LFE,
90
91     PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER,
92     PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER,
93
94     PA_CHANNEL_POSITION_SIDE_LEFT,
95     PA_CHANNEL_POSITION_SIDE_RIGHT,
96
97     PA_CHANNEL_POSITION_AUX0,
98     PA_CHANNEL_POSITION_AUX1,
99     PA_CHANNEL_POSITION_AUX2,
100     PA_CHANNEL_POSITION_AUX3,
101     PA_CHANNEL_POSITION_AUX4,
102     PA_CHANNEL_POSITION_AUX5,
103     PA_CHANNEL_POSITION_AUX6,
104     PA_CHANNEL_POSITION_AUX7,
105     PA_CHANNEL_POSITION_AUX8,
106     PA_CHANNEL_POSITION_AUX9,
107     PA_CHANNEL_POSITION_AUX10,
108     PA_CHANNEL_POSITION_AUX11,
109     PA_CHANNEL_POSITION_AUX12,
110     PA_CHANNEL_POSITION_AUX13,
111     PA_CHANNEL_POSITION_AUX14,
112     PA_CHANNEL_POSITION_AUX15,
113     PA_CHANNEL_POSITION_AUX16,
114     PA_CHANNEL_POSITION_AUX17,
115     PA_CHANNEL_POSITION_AUX18,
116     PA_CHANNEL_POSITION_AUX19,
117     PA_CHANNEL_POSITION_AUX20,
118     PA_CHANNEL_POSITION_AUX21,
119     PA_CHANNEL_POSITION_AUX22,
120     PA_CHANNEL_POSITION_AUX23,
121     PA_CHANNEL_POSITION_AUX24,
122     PA_CHANNEL_POSITION_AUX25,
123     PA_CHANNEL_POSITION_AUX26,
124     PA_CHANNEL_POSITION_AUX27,
125     PA_CHANNEL_POSITION_AUX28,
126     PA_CHANNEL_POSITION_AUX29,
127     PA_CHANNEL_POSITION_AUX30,
128     PA_CHANNEL_POSITION_AUX31,
129
130     PA_CHANNEL_POSITION_TOP_CENTER,
131
132     PA_CHANNEL_POSITION_TOP_FRONT_LEFT,
133     PA_CHANNEL_POSITION_TOP_FRONT_RIGHT,
134     PA_CHANNEL_POSITION_TOP_FRONT_CENTER,
135
136     PA_CHANNEL_POSITION_TOP_REAR_LEFT,
137     PA_CHANNEL_POSITION_TOP_REAR_RIGHT,
138     PA_CHANNEL_POSITION_TOP_REAR_CENTER,
139
140     PA_CHANNEL_POSITION_MAX
141 } pa_channel_position_t;
142
143 /** A list of channel mapping definitions for pa_channel_map_init_auto() */
144 typedef enum pa_channel_map_def {
145     PA_CHANNEL_MAP_AIFF,
146     /**< The mapping from RFC3551, which is based on AIFF-C */
147
148     PA_CHANNEL_MAP_ALSA,
149     /**< The default mapping used by ALSA */
150
151     PA_CHANNEL_MAP_AUX,
152     /**< Only aux channels */
153
154     PA_CHANNEL_MAP_WAVEEX,
155     /**< Microsoft's WAVEFORMATEXTENSIBLE mapping */
156
157     PA_CHANNEL_MAP_OSS,
158     /**< The default channel mapping used by OSS as defined in the OSS 4.0 API specs */
159
160     /**< Upper limit of valid channel mapping definitions */
161     PA_CHANNEL_MAP_DEF_MAX,
162
163     PA_CHANNEL_MAP_DEFAULT = PA_CHANNEL_MAP_AIFF
164     /**< The default channel map */
165 } pa_channel_map_def_t;
166
167 /** A channel map which can be used to attach labels to specific
168  * channels of a stream. These values are relevant for conversion and
169  * mixing of streams */
170 typedef struct pa_channel_map {
171     uint8_t channels;
172     /**< Number of channels */
173
174     pa_channel_position_t map[PA_CHANNELS_MAX];
175     /**< Channel labels */
176 } pa_channel_map;
177
178 /** Initialize the specified channel map and return a pointer to
179  * it. The channel map will have a defined state but
180  * pa_channel_map_valid() will fail for it. */
181 pa_channel_map* pa_channel_map_init(pa_channel_map *m);
182
183 /** Initialize the specified channel map for monoaural audio and return a pointer to it */
184 pa_channel_map* pa_channel_map_init_mono(pa_channel_map *m);
185
186 /** Initialize the specified channel map for stereophonic audio and return a pointer to it */
187 pa_channel_map* pa_channel_map_init_stereo(pa_channel_map *m);
188
189 /** Initialize the specified channel map for the specified number of
190  * channels using default labels and return a pointer to it. This call
191  * will fail (return NULL) if there is no default channel map known for this
192  * specific number of channels and mapping. */
193 pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, pa_channel_map_def_t def);
194
195 /** Similar to pa_channel_map_init_auto() but instead of failing if no
196  * default mapping is known with the specified parameters it will
197  * synthesize a mapping based on a known mapping with fewer channels
198  * and fill up the rest with AUX0...AUX31 channels  \since 0.9.11 */
199 pa_channel_map* pa_channel_map_init_extend(pa_channel_map *m, unsigned channels, pa_channel_map_def_t def);
200
201 /** Return a text label for the specified channel position */
202 const char* pa_channel_position_to_string(pa_channel_position_t pos) PA_GCC_PURE;
203
204 /** Return a human readable text label for the specified channel position. \since 0.9.7 */
205 const char* pa_channel_position_to_pretty_string(pa_channel_position_t pos);
206
207 /** The maximum length of strings returned by pa_channel_map_snprint() */
208 #define PA_CHANNEL_MAP_SNPRINT_MAX 336
209
210 /** Make a humand readable string from the specified channel map */
211 char* pa_channel_map_snprint(char *s, size_t l, const pa_channel_map *map);
212
213 /** Parse a channel position list into a channel map structure. */
214 pa_channel_map *pa_channel_map_parse(pa_channel_map *map, const char *s);
215
216 /** Compare two channel maps. Return 1 if both match. */
217 int pa_channel_map_equal(const pa_channel_map *a, const pa_channel_map *b) PA_GCC_PURE;
218
219 /** Return non-zero if the specified channel map is considered valid */
220 int pa_channel_map_valid(const pa_channel_map *map) PA_GCC_PURE;
221
222 /** Return non-zero if the specified channel map is compatible with
223  * the specified sample spec. \since 0.9.12 */
224 int pa_channel_map_compatible(const pa_channel_map *map, const pa_sample_spec *ss) PA_GCC_PURE;
225
226 PA_C_DECL_END
227
228 #endif