default: esd is obsolete, hence don't load it anymore by default
[pulseaudio-mirror.git] / src / pulsecore / sample-util.h
blobcf79d433e457ffe8a9544c55bd9a18f00567a019
1 #ifndef foosampleutilhfoo
2 #define foosampleutilhfoo
4 /***
5 This file is part of PulseAudio.
7 Copyright 2004-2006 Lennart Poettering
8 Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
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.
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.
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 ***/
26 #include <pulse/gccmacro.h>
27 #include <pulse/sample.h>
28 #include <pulse/volume.h>
29 #include <pulse/channelmap.h>
31 #include <pulsecore/memblock.h>
32 #include <pulsecore/memchunk.h>
34 typedef struct pa_silence_cache {
35 pa_memblock* blocks[PA_SAMPLE_MAX];
36 } pa_silence_cache;
38 void pa_silence_cache_init(pa_silence_cache *cache);
39 void pa_silence_cache_done(pa_silence_cache *cache);
41 void *pa_silence_memory(void *p, size_t length, const pa_sample_spec *spec);
42 pa_memchunk* pa_silence_memchunk(pa_memchunk *c, const pa_sample_spec *spec);
43 pa_memblock* pa_silence_memblock(pa_memblock *b, const pa_sample_spec *spec);
45 pa_memchunk* pa_silence_memchunk_get(pa_silence_cache *cache, pa_mempool *pool, pa_memchunk* ret, const pa_sample_spec *spec, size_t length);
47 typedef struct pa_mix_info {
48 pa_memchunk chunk;
49 pa_cvolume volume;
50 void *userdata;
52 /* The following fields are used internally by pa_mix(), should
53 * not be initialised by the caller of pa_mix(). */
54 void *ptr;
55 union {
56 int32_t i;
57 float f;
58 } linear[PA_CHANNELS_MAX];
59 } pa_mix_info;
61 size_t pa_mix(
62 pa_mix_info channels[],
63 unsigned nchannels,
64 void *data,
65 size_t length,
66 const pa_sample_spec *spec,
67 const pa_cvolume *volume,
68 pa_bool_t mute);
70 void pa_volume_memchunk(
71 pa_memchunk*c,
72 const pa_sample_spec *spec,
73 const pa_cvolume *volume);
75 size_t pa_frame_align(size_t l, const pa_sample_spec *ss) PA_GCC_PURE;
77 pa_bool_t pa_frame_aligned(size_t l, const pa_sample_spec *ss) PA_GCC_PURE;
79 void pa_interleave(const void *src[], unsigned channels, void *dst, size_t ss, unsigned n);
80 void pa_deinterleave(const void *src, void *dst[], unsigned channels, size_t ss, unsigned n);
82 void pa_sample_clamp(pa_sample_format_t format, void *dst, size_t dstr, const void *src, size_t sstr, unsigned n);
84 pa_usec_t pa_bytes_to_usec_round_up(uint64_t length, const pa_sample_spec *spec);
85 size_t pa_usec_to_bytes_round_up(pa_usec_t t, const pa_sample_spec *spec);
87 void pa_memchunk_dump_to_file(pa_memchunk *c, const char *fn);
89 void pa_memchunk_sine(pa_memchunk *c, pa_mempool *pool, unsigned rate, unsigned freq);
91 typedef void (*pa_do_volume_func_t) (void *samples, void *volumes, unsigned channels, unsigned length);
93 pa_do_volume_func_t pa_get_volume_func(pa_sample_format_t f);
94 void pa_set_volume_func(pa_sample_format_t f, pa_do_volume_func_t func);
96 size_t pa_convert_size(size_t size, const pa_sample_spec *from, const pa_sample_spec *to);
98 #define PA_CHANNEL_POSITION_MASK_LEFT \
99 (PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_FRONT_LEFT) \
100 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_REAR_LEFT) \
101 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER) \
102 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_SIDE_LEFT) \
103 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_FRONT_LEFT) \
104 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_REAR_LEFT)) \
106 #define PA_CHANNEL_POSITION_MASK_RIGHT \
107 (PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_FRONT_RIGHT) \
108 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_REAR_RIGHT) \
109 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER) \
110 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_SIDE_RIGHT) \
111 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_FRONT_RIGHT) \
112 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_REAR_RIGHT))
114 #define PA_CHANNEL_POSITION_MASK_CENTER \
115 (PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_FRONT_CENTER) \
116 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_REAR_CENTER) \
117 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_CENTER) \
118 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_FRONT_CENTER) \
119 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_REAR_CENTER))
121 #define PA_CHANNEL_POSITION_MASK_FRONT \
122 (PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_FRONT_LEFT) \
123 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_FRONT_RIGHT) \
124 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_FRONT_CENTER) \
125 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER) \
126 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER) \
127 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_FRONT_LEFT) \
128 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_FRONT_RIGHT) \
129 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_FRONT_CENTER))
131 #define PA_CHANNEL_POSITION_MASK_REAR \
132 (PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_REAR_LEFT) \
133 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_REAR_RIGHT) \
134 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_REAR_CENTER) \
135 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_REAR_LEFT) \
136 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_REAR_RIGHT) \
137 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_REAR_CENTER))
139 #define PA_CHANNEL_POSITION_MASK_SIDE_OR_TOP_CENTER \
140 (PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_SIDE_LEFT) \
141 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_SIDE_RIGHT) \
142 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_CENTER))
144 #define PA_CHANNEL_POSITION_MASK_TOP \
145 (PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_CENTER) \
146 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_FRONT_LEFT) \
147 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_FRONT_RIGHT) \
148 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_FRONT_CENTER) \
149 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_REAR_LEFT) \
150 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_REAR_RIGHT) \
151 | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_REAR_CENTER))
153 #define PA_CHANNEL_POSITION_MASK_ALL \
154 ((pa_channel_position_mask_t) (PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_MAX)-1))
156 #endif