Sending translation for Portuguese
[platform/upstream/pulseaudio.git] / src / pulsecore / sample-util.h
1 #ifndef foosampleutilhfoo
2 #define foosampleutilhfoo
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 <pulse/sample.h>
27 #include <pulse/volume.h>
28 #include <pulsecore/memblock.h>
29 #include <pulsecore/memchunk.h>
30
31 typedef struct pa_silence_cache {
32     pa_memblock* blocks[PA_SAMPLE_MAX];
33 } pa_silence_cache;
34
35 void pa_silence_cache_init(pa_silence_cache *cache);
36 void pa_silence_cache_done(pa_silence_cache *cache);
37
38 void *pa_silence_memory(void *p, size_t length, const pa_sample_spec *spec);
39 pa_memchunk* pa_silence_memchunk(pa_memchunk *c, const pa_sample_spec *spec);
40 pa_memblock* pa_silence_memblock(pa_memblock *b, const pa_sample_spec *spec);
41
42 pa_memchunk* pa_silence_memchunk_get(pa_silence_cache *cache, pa_mempool *pool, pa_memchunk* ret, const pa_sample_spec *spec, size_t length);
43
44 typedef struct pa_mix_info {
45     pa_memchunk chunk;
46     pa_cvolume volume;
47     void *userdata;
48
49     /* The following fields are used internally by pa_mix(), should
50      * not be initialised by the caller of pa_mix(). */
51     void *ptr;
52     union {
53         int32_t i;
54         float f;
55     } linear[PA_CHANNELS_MAX];
56 } pa_mix_info;
57
58 size_t pa_mix(
59     pa_mix_info channels[],
60     unsigned nchannels,
61     void *data,
62     size_t length,
63     const pa_sample_spec *spec,
64     const pa_cvolume *volume,
65     pa_bool_t mute);
66
67 void pa_volume_memchunk(
68     pa_memchunk*c,
69     const pa_sample_spec *spec,
70     const pa_cvolume *volume);
71
72 size_t pa_frame_align(size_t l, const pa_sample_spec *ss) PA_GCC_PURE;
73
74 pa_bool_t pa_frame_aligned(size_t l, const pa_sample_spec *ss) PA_GCC_PURE;
75
76 void pa_interleave(const void *src[], unsigned channels, void *dst, size_t ss, unsigned n);
77 void pa_deinterleave(const void *src, void *dst[], unsigned channels, size_t ss, unsigned n);
78
79 void pa_sample_clamp(pa_sample_format_t format, void *dst, size_t dstr, const void *src, size_t sstr, unsigned n);
80
81 pa_usec_t pa_bytes_to_usec_round_up(uint64_t length, const pa_sample_spec *spec);
82 size_t pa_usec_to_bytes_round_up(pa_usec_t t, const pa_sample_spec *spec);
83
84 void pa_memchunk_dump_to_file(pa_memchunk *c, const char *fn);
85
86 void pa_memchunk_sine(pa_memchunk *c, pa_mempool *pool, unsigned rate, unsigned freq);
87
88 #endif