7 This file is part of polypaudio.
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.
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.
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
26 #include <sys/types.h>
32 enum pa_sample_format {
43 #ifdef WORDS_BIGENDIAN
44 #define PA_SAMPLE_S16NE PA_SAMPLE_S16BE
45 #define PA_SAMPLE_FLOAT32NE PA_SAMPLE_FLOAT32BE
47 #define PA_SAMPLE_S16NE PA_SAMPLE_S16LE
48 #define PA_SAMPLE_FLOAT32NE PA_SAMPLE_FLOAT32LE
50 #define PA_SAMPLE_FLOAT32 PA_SAMPLE_FLOAT32NE
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, ...) */
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);
65 #define PA_SAMPLE_SNPRINT_MAX_LENGTH 32
66 void pa_sample_snprint(char *s, size_t l, const struct pa_sample_spec *spec);
68 /** Normal volume (100%) */
69 #define PA_VOLUME_NORM (0x100)
71 /** Muted volume (0%) */
72 #define PA_VOLUME_MUTE (0)
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);