PulseAudio  3.0.0-7.mga3
sample.h
Go to the documentation of this file.
1 #ifndef foosamplehfoo
2 #define foosamplehfoo
3 
4 /***
5  This file is part of PulseAudio.
6 
7  Copyright 2004-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.1 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 <inttypes.h>
27 #include <sys/types.h>
28 #include <sys/param.h>
29 
30 #include <pulse/gccmacro.h>
31 #include <pulse/cdecl.h>
32 #include <pulse/version.h>
33 
112 PA_C_DECL_BEGIN
113 
114 #if !defined(WORDS_BIGENDIAN)
115 #if defined(__BYTE_ORDER)
116 #if __BYTE_ORDER == __BIG_ENDIAN
117 #define WORDS_BIGENDIAN
118 #endif
119 #endif
120 #endif
121 
123 #define PA_CHANNELS_MAX 32U
124 
126 #define PA_RATE_MAX (48000U*4U)
127 
129 typedef enum pa_sample_format {
175 
176 #ifdef WORDS_BIGENDIAN
177 
178 #define PA_SAMPLE_S16NE PA_SAMPLE_S16BE
179 
180 #define PA_SAMPLE_FLOAT32NE PA_SAMPLE_FLOAT32BE
181 
182 #define PA_SAMPLE_S32NE PA_SAMPLE_S32BE
183 
184 #define PA_SAMPLE_S24NE PA_SAMPLE_S24BE
185 
186 #define PA_SAMPLE_S24_32NE PA_SAMPLE_S24_32BE
187 
189 #define PA_SAMPLE_S16RE PA_SAMPLE_S16LE
190 
191 #define PA_SAMPLE_FLOAT32RE PA_SAMPLE_FLOAT32LE
192 
193 #define PA_SAMPLE_S32RE PA_SAMPLE_S32LE
194 
195 #define PA_SAMPLE_S24RE PA_SAMPLE_S24LE
196 
197 #define PA_SAMPLE_S24_32RE PA_SAMPLE_S24_32LE
198 #else
199 
200 #define PA_SAMPLE_S16NE PA_SAMPLE_S16LE
201 
202 #define PA_SAMPLE_FLOAT32NE PA_SAMPLE_FLOAT32LE
203 
204 #define PA_SAMPLE_S32NE PA_SAMPLE_S32LE
205 
206 #define PA_SAMPLE_S24NE PA_SAMPLE_S24LE
207 
208 #define PA_SAMPLE_S24_32NE PA_SAMPLE_S24_32LE
209 
211 #define PA_SAMPLE_S16RE PA_SAMPLE_S16BE
212 
213 #define PA_SAMPLE_FLOAT32RE PA_SAMPLE_FLOAT32BE
214 
215 #define PA_SAMPLE_S32RE PA_SAMPLE_S32BE
216 
217 #define PA_SAMPLE_S24RE PA_SAMPLE_S24BE
218 
219 #define PA_SAMPLE_S24_32RE PA_SAMPLE_S24_32BE
220 #endif
221 
223 #define PA_SAMPLE_FLOAT32 PA_SAMPLE_FLOAT32NE
224 
226 /* Allow clients to check with #ifdef for these sample formats */
227 #define PA_SAMPLE_U8 PA_SAMPLE_U8
228 #define PA_SAMPLE_ALAW PA_SAMPLE_ALAW
229 #define PA_SAMPLE_ULAW PA_SAMPLE_ULAW
230 #define PA_SAMPLE_S16LE PA_SAMPLE_S16LE
231 #define PA_SAMPLE_S16BE PA_SAMPLE_S16BE
232 #define PA_SAMPLE_FLOAT32LE PA_SAMPLE_FLOAT32LE
233 #define PA_SAMPLE_FLOAT32BE PA_SAMPLE_FLOAT32BE
234 #define PA_SAMPLE_S32LE PA_SAMPLE_S32LE
235 #define PA_SAMPLE_S32BE PA_SAMPLE_S32BE
236 #define PA_SAMPLE_S24LE PA_SAMPLE_S24LE
237 #define PA_SAMPLE_S24BE PA_SAMPLE_S24BE
238 #define PA_SAMPLE_S24_32LE PA_SAMPLE_S24_32LE
239 #define PA_SAMPLE_S24_32BE PA_SAMPLE_S24_32BE
240 
243 typedef struct pa_sample_spec {
247  uint32_t rate;
250  uint8_t channels;
253 
255 typedef uint64_t pa_usec_t;
256 
259 
261 size_t pa_frame_size(const pa_sample_spec *spec) PA_GCC_PURE;
262 
264 size_t pa_sample_size(const pa_sample_spec *spec) PA_GCC_PURE;
265 
269 
273 pa_usec_t pa_bytes_to_usec(uint64_t length, const pa_sample_spec *spec) PA_GCC_PURE;
274 
279 
284 
287 
290 
293 
296 
302 #define PA_SAMPLE_SPEC_SNPRINT_MAX 32
303 
305 char* pa_sample_spec_snprint(char *s, size_t l, const pa_sample_spec *spec);
306 
312 #define PA_BYTES_SNPRINT_MAX 11
313 
315 char* pa_bytes_snprint(char *s, size_t l, unsigned v);
316 
320 
324 
325 #ifdef WORDS_BIGENDIAN
326 #define pa_sample_format_is_ne(f) pa_sample_format_is_be(f)
327 #define pa_sample_format_is_re(f) pa_sample_format_is_le(f)
328 #else
329 
331 #define pa_sample_format_is_ne(f) pa_sample_format_is_le(f)
332 
334 #define pa_sample_format_is_re(f) pa_sample_format_is_be(f)
335 #endif
336 
337 PA_C_DECL_END
338 
339 #endif