PulseAudio  3.0
volume.h
Go to the documentation of this file.
1 #ifndef foovolumehfoo
2 #define foovolumehfoo
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 <limits.h>
28 
29 #include <pulse/cdecl.h>
30 #include <pulse/gccmacro.h>
31 #include <pulse/sample.h>
32 #include <pulse/channelmap.h>
33 #include <pulse/version.h>
34 
100 PA_C_DECL_BEGIN
101 
107 typedef uint32_t pa_volume_t;
108 
110 #define PA_VOLUME_NORM ((pa_volume_t) 0x10000U)
111 
113 #define PA_VOLUME_MUTED ((pa_volume_t) 0U)
114 
116 #define PA_VOLUME_MAX ((pa_volume_t) UINT32_MAX/2)
117 
123 #define PA_VOLUME_UI_MAX (pa_sw_volume_from_dB(+11.0))
124 
126 #define PA_VOLUME_INVALID ((pa_volume_t) UINT32_MAX)
127 
129 #define PA_VOLUME_IS_VALID(v) ((v) <= PA_VOLUME_MAX)
130 
132 #define PA_CLAMP_VOLUME(v) (PA_CLAMP_UNLIKELY((v), PA_VOLUME_MUTED, PA_VOLUME_MAX))
133 
135 typedef struct pa_cvolume {
136  uint8_t channels;
138 } pa_cvolume;
139 
141 int pa_cvolume_equal(const pa_cvolume *a, const pa_cvolume *b) PA_GCC_PURE;
142 
147 
149 #define pa_cvolume_reset(a, n) pa_cvolume_set((a), (n), PA_VOLUME_NORM)
150 
152 #define pa_cvolume_mute(a, n) pa_cvolume_set((a), (n), PA_VOLUME_MUTED)
153 
155 pa_cvolume* pa_cvolume_set(pa_cvolume *a, unsigned channels, pa_volume_t v);
156 
162 #define PA_CVOLUME_SNPRINT_MAX 320
163 
165 char *pa_cvolume_snprint(char *s, size_t l, const pa_cvolume *c);
166 
172 #define PA_SW_CVOLUME_SNPRINT_DB_MAX 448
173 
175 char *pa_sw_cvolume_snprint_dB(char *s, size_t l, const pa_cvolume *c);
176 
182 #define PA_VOLUME_SNPRINT_MAX 10
183 
185 char *pa_volume_snprint(char *s, size_t l, pa_volume_t v);
186 
192 #define PA_SW_VOLUME_SNPRINT_DB_MAX 10
193 
195 char *pa_sw_volume_snprint_dB(char *s, size_t l, pa_volume_t v);
196 
199 
206 
209 
216 
219 
226 
229 
232 
234 #define pa_cvolume_is_muted(a) pa_cvolume_channels_equal_to((a), PA_VOLUME_MUTED)
235 
237 #define pa_cvolume_is_norm(a) pa_cvolume_channels_equal_to((a), PA_VOLUME_NORM)
238 
243 
248 
254 
260 
265 
271 
274 
277 
281 
284 
285 #ifdef INFINITY
286 #define PA_DECIBEL_MININFTY ((double) -INFINITY)
287 #else
288 
289 #define PA_DECIBEL_MININFTY ((double) -200.0)
290 #endif
291 
294 
298 
302 
308 float pa_cvolume_get_balance(const pa_cvolume *v, const pa_channel_map *map) PA_GCC_PURE;
309 
319 pa_cvolume* pa_cvolume_set_balance(pa_cvolume *v, const pa_channel_map *map, float new_balance);
320 
326 float pa_cvolume_get_fade(const pa_cvolume *v, const pa_channel_map *map) PA_GCC_PURE;
327 
337 pa_cvolume* pa_cvolume_set_fade(pa_cvolume *v, const pa_channel_map *map, float new_fade);
338 
343 
349 
356 
362 
366 pa_cvolume* pa_cvolume_merge(pa_cvolume *dest, const pa_cvolume *a, const pa_cvolume *b);
367 
371 
375 
379 
380 PA_C_DECL_END
381 
382 #endif