1 #ifndef foochannelmaphfoo
2 #define foochannelmaphfoo
7 This file is part of PulseAudio.
9 PulseAudio is free software; you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published
11 by the Free Software Foundation; either version 2 of the License,
12 or (at your option) any later version.
14 PulseAudio is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
19 You should have received a copy of the GNU Lesser General Public License
20 along with PulseAudio; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
25 #include <pulse/sample.h>
26 #include <pulse/cdecl.h>
28 /** \page channelmap Channel Maps
30 * \section overv_sec Overview
32 * Channel maps provide a way to associate channels in a stream with a
33 * specific speaker position. This relieves applications of having to
34 * make sure their channel order is identical to the final output.
36 * \section init_sec Initialisation
38 * A channel map consists of an array of \ref pa_channel_position values,
39 * one for each channel. This array is stored together with a channel count
40 * in a pa_channel_map structure.
42 * Before filling the structure, the application must initialise it using
43 * pa_channel_map_init(). There are also a number of convenience functions
44 * for standard channel mappings:
46 * \li pa_channel_map_init_mono() - Create a channel map with only mono audio.
47 * \li pa_channel_map_init_stereo() - Create a standard stereo mapping.
48 * \li pa_channel_map_init_auto() - Create a standard channel map for up to
51 * \section conv_sec Convenience Functions
53 * The library contains a number of convenience functions for dealing with
56 * \li pa_channel_map_valid() - Tests if a channel map is valid.
57 * \li pa_channel_map_equal() - Tests if two channel maps are identical.
58 * \li pa_channel_map_snprint() - Creates a textual description of a channel
63 * Constants and routines for channel mapping handling */
67 /** A list of channel labels */
68 typedef enum pa_channel_position
{
69 PA_CHANNEL_POSITION_INVALID
= -1,
70 PA_CHANNEL_POSITION_MONO
= 0,
72 PA_CHANNEL_POSITION_LEFT
,
73 PA_CHANNEL_POSITION_RIGHT
,
74 PA_CHANNEL_POSITION_CENTER
,
76 PA_CHANNEL_POSITION_FRONT_LEFT
= PA_CHANNEL_POSITION_LEFT
,
77 PA_CHANNEL_POSITION_FRONT_RIGHT
= PA_CHANNEL_POSITION_RIGHT
,
78 PA_CHANNEL_POSITION_FRONT_CENTER
= PA_CHANNEL_POSITION_CENTER
,
80 PA_CHANNEL_POSITION_REAR_CENTER
,
81 PA_CHANNEL_POSITION_REAR_LEFT
,
82 PA_CHANNEL_POSITION_REAR_RIGHT
,
84 PA_CHANNEL_POSITION_LFE
,
85 PA_CHANNEL_POSITION_SUBWOOFER
= PA_CHANNEL_POSITION_LFE
,
87 PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER
,
88 PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER
,
90 PA_CHANNEL_POSITION_SIDE_LEFT
,
91 PA_CHANNEL_POSITION_SIDE_RIGHT
,
93 PA_CHANNEL_POSITION_AUX0
,
94 PA_CHANNEL_POSITION_AUX1
,
95 PA_CHANNEL_POSITION_AUX2
,
96 PA_CHANNEL_POSITION_AUX3
,
97 PA_CHANNEL_POSITION_AUX4
,
98 PA_CHANNEL_POSITION_AUX5
,
99 PA_CHANNEL_POSITION_AUX6
,
100 PA_CHANNEL_POSITION_AUX7
,
101 PA_CHANNEL_POSITION_AUX8
,
102 PA_CHANNEL_POSITION_AUX9
,
103 PA_CHANNEL_POSITION_AUX10
,
104 PA_CHANNEL_POSITION_AUX11
,
105 PA_CHANNEL_POSITION_AUX12
,
106 PA_CHANNEL_POSITION_AUX13
,
107 PA_CHANNEL_POSITION_AUX14
,
108 PA_CHANNEL_POSITION_AUX15
,
109 PA_CHANNEL_POSITION_AUX16
,
110 PA_CHANNEL_POSITION_AUX17
,
111 PA_CHANNEL_POSITION_AUX18
,
112 PA_CHANNEL_POSITION_AUX19
,
113 PA_CHANNEL_POSITION_AUX20
,
114 PA_CHANNEL_POSITION_AUX21
,
115 PA_CHANNEL_POSITION_AUX22
,
116 PA_CHANNEL_POSITION_AUX23
,
117 PA_CHANNEL_POSITION_AUX24
,
118 PA_CHANNEL_POSITION_AUX25
,
119 PA_CHANNEL_POSITION_AUX26
,
120 PA_CHANNEL_POSITION_AUX27
,
121 PA_CHANNEL_POSITION_AUX28
,
122 PA_CHANNEL_POSITION_AUX29
,
123 PA_CHANNEL_POSITION_AUX30
,
124 PA_CHANNEL_POSITION_AUX31
,
126 PA_CHANNEL_POSITION_TOP_CENTER
,
128 PA_CHANNEL_POSITION_TOP_FRONT_LEFT
,
129 PA_CHANNEL_POSITION_TOP_FRONT_RIGHT
,
130 PA_CHANNEL_POSITION_TOP_FRONT_CENTER
,
132 PA_CHANNEL_POSITION_TOP_REAR_LEFT
,
133 PA_CHANNEL_POSITION_TOP_REAR_RIGHT
,
134 PA_CHANNEL_POSITION_TOP_REAR_CENTER
,
136 PA_CHANNEL_POSITION_MAX
137 } pa_channel_position_t
;
139 /** A list of channel mapping definitions for pa_channel_map_init_auto() */
140 typedef enum pa_channel_map_def
{
141 PA_CHANNEL_MAP_AIFF
, /**< The mapping from RFC3551, which is based on AIFF-C */
142 PA_CHANNEL_MAP_ALSA
, /**< The default mapping used by ALSA */
143 PA_CHANNEL_MAP_AUX
, /**< Only aux channels */
144 PA_CHANNEL_MAP_WAVEEX
, /**< Microsoft's WAVEFORMATEXTENSIBLE mapping */
145 PA_CHANNEL_MAP_OSS
, /**< The default channel mapping used by OSS as defined in the OSS 4.0 API specs */
147 PA_CHANNEL_MAP_DEFAULT
= PA_CHANNEL_MAP_AIFF
/**< The default channel map */
148 } pa_channel_map_def_t
;
150 /** A channel map which can be used to attach labels to specific
151 * channels of a stream. These values are relevant for conversion and
152 * mixing of streams */
153 typedef struct pa_channel_map
{
154 uint8_t channels
; /**< Number of channels */
155 pa_channel_position_t map
[PA_CHANNELS_MAX
]; /**< Channel labels */
158 /** Initialize the specified channel map and return a pointer to it */
159 pa_channel_map
* pa_channel_map_init(pa_channel_map
*m
);
161 /** Initialize the specified channel map for monoaural audio and return a pointer to it */
162 pa_channel_map
* pa_channel_map_init_mono(pa_channel_map
*m
);
164 /** Initialize the specified channel map for stereophonic audio and return a pointer to it */
165 pa_channel_map
* pa_channel_map_init_stereo(pa_channel_map
*m
);
167 /** Initialize the specified channel map for the specified number
168 * of channels using default labels and return a pointer to it. */
169 pa_channel_map
* pa_channel_map_init_auto(pa_channel_map
*m
, unsigned channels
, pa_channel_map_def_t def
);
171 /** Return a text label for the specified channel position */
172 const char* pa_channel_position_to_string(pa_channel_position_t pos
);
174 /** The maximum length of strings returned by pa_channel_map_snprint() */
175 #define PA_CHANNEL_MAP_SNPRINT_MAX 336
177 /** Make a humand readable string from the specified channel map */
178 char* pa_channel_map_snprint(char *s
, size_t l
, const pa_channel_map
*map
);
180 /** Parse a channel position list into a channel map structure. \since 0.8.1 */
181 pa_channel_map
*pa_channel_map_parse(pa_channel_map
*map
, const char *s
);
183 /** Compare two channel maps. Return 1 if both match. */
184 int pa_channel_map_equal(const pa_channel_map
*a
, const pa_channel_map
*b
);
186 /** Return non-zero of the specified channel map is considered valid */
187 int pa_channel_map_valid(const pa_channel_map
*map
);