]> code.delx.au - pulseaudio/blob - polyp/sample.h
e397a1dfe1f378adbf6331ff652fe41483b435fa
[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 #include "cdecl.h"
29
30 PA_C_DECL_BEGIN
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 /** A sample format and attribute specification */
53 struct pa_sample_spec {
54 enum pa_sample_format format; /**< The sample format */
55 uint32_t rate; /**< The sample rate. (e.g. 44100) */
56 uint8_t channels; /**< Audio channels. (1 for mono, 2 for stereo, ...) */
57 };
58
59 size_t pa_bytes_per_second(const struct pa_sample_spec *spec);
60 size_t pa_frame_size(const struct pa_sample_spec *spec);
61 uint32_t pa_bytes_to_usec(size_t length, const struct pa_sample_spec *spec);
62 int pa_sample_spec_valid(const struct pa_sample_spec *spec);
63 int pa_sample_spec_equal(const struct pa_sample_spec*a, const struct pa_sample_spec*b);
64
65 #define PA_SAMPLE_SNPRINT_MAX_LENGTH 32
66 void pa_sample_snprint(char *s, size_t l, const struct pa_sample_spec *spec);
67
68 /** Normal volume (100%) */
69 #define PA_VOLUME_NORM (0x100)
70
71 /** Muted volume (0%) */
72 #define PA_VOLUME_MUTE (0)
73
74 /** Multiply two volumes specifications, return the result. This uses PA_VOLUME_NORM as neutral element of multiplication. */
75 uint32_t pa_volume_multiply(uint32_t a, uint32_t b);
76
77 PA_C_DECL_END
78
79 #endif