]> code.delx.au - pulseaudio/blob - polyp/sample.h
sample cache work
[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 enum pa_sample_format {
29 PA_SAMPLE_U8,
30 PA_SAMPLE_ALAW,
31 PA_SAMPLE_ULAW,
32 PA_SAMPLE_S16LE,
33 PA_SAMPLE_S16BE,
34 PA_SAMPLE_FLOAT32LE,
35 PA_SAMPLE_FLOAT32BE,
36 PA_SAMPLE_MAX
37 };
38
39 #ifdef WORDS_BIGENDIAN
40 #define PA_SAMPLE_S16NE PA_SAMPLE_S16BE
41 #define PA_SAMPLE_FLOAT32NE PA_SAMPLE_FLOAT32BE
42 #else
43 #define PA_SAMPLE_S16NE PA_SAMPLE_S16LE
44 #define PA_SAMPLE_FLOAT32NE PA_SAMPLE_FLOAT32LE
45 #endif
46 #define PA_SAMPLE_FLOAT32 PA_SAMPLE_FLOAT32NE
47
48 struct pa_sample_spec {
49 enum pa_sample_format format;
50 uint32_t rate;
51 uint8_t channels;
52 };
53
54 size_t pa_bytes_per_second(const struct pa_sample_spec *spec);
55 size_t pa_frame_size(const struct pa_sample_spec *spec);
56 uint32_t pa_bytes_to_usec(size_t length, const struct pa_sample_spec *spec);
57 int pa_sample_spec_valid(const struct pa_sample_spec *spec);
58 int pa_sample_spec_equal(const struct pa_sample_spec*a, const struct pa_sample_spec*b);
59
60 #define PA_SAMPLE_SNPRINT_MAX_LENGTH 32
61 void pa_sample_snprint(char *s, size_t l, const struct pa_sample_spec *spec);
62
63 #endif