]> code.delx.au - pulseaudio/blob - polyp/sample.h
add mainloop test utility
[pulseaudio] / polyp / sample.h
1 #ifndef foosamplehfoo
2 #define foosamplehfoo
3
4 /* $Id$ */
5
6 /***
7 This file is part of polypaudio.
8
9 polypaudio is free software; you can redistribute it and/or modify
10 it under the terms of the GNU 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.
13
14 polypaudio 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.
18
19 You should have received a copy of the GNU General Public License
20 along with polypaudio; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 USA.
23 ***/
24
25 #include <inttypes.h>
26 #include <sys/types.h>
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 enum pa_sample_format {
33 PA_SAMPLE_U8,
34 PA_SAMPLE_ALAW,
35 PA_SAMPLE_ULAW,
36 PA_SAMPLE_S16LE,
37 PA_SAMPLE_S16BE,
38 PA_SAMPLE_FLOAT32LE,
39 PA_SAMPLE_FLOAT32BE,
40 PA_SAMPLE_MAX
41 };
42
43 #ifdef WORDS_BIGENDIAN
44 #define PA_SAMPLE_S16NE PA_SAMPLE_S16BE
45 #define PA_SAMPLE_FLOAT32NE PA_SAMPLE_FLOAT32BE
46 #else
47 #define PA_SAMPLE_S16NE PA_SAMPLE_S16LE
48 #define PA_SAMPLE_FLOAT32NE PA_SAMPLE_FLOAT32LE
49 #endif
50 #define PA_SAMPLE_FLOAT32 PA_SAMPLE_FLOAT32NE
51
52 struct pa_sample_spec {
53 enum pa_sample_format format;
54 uint32_t rate;
55 uint8_t channels;
56 };
57
58 size_t pa_bytes_per_second(const struct pa_sample_spec *spec);
59 size_t pa_frame_size(const struct pa_sample_spec *spec);
60 uint32_t pa_bytes_to_usec(size_t length, const struct pa_sample_spec *spec);
61 int pa_sample_spec_valid(const struct pa_sample_spec *spec);
62 int pa_sample_spec_equal(const struct pa_sample_spec*a, const struct pa_sample_spec*b);
63
64 #define PA_SAMPLE_SNPRINT_MAX_LENGTH 32
65 void pa_sample_snprint(char *s, size_t l, const struct pa_sample_spec *spec);
66
67 #ifdef __cplusplus
68 }
69 #endif
70
71 #endif