]> code.delx.au - pulseaudio/blob - src/sample.h
partial implementation of native protocol
[pulseaudio] / src / sample.h
1 #ifndef foosamplehfoo
2 #define foosamplehfoo
3
4 #include <inttypes.h>
5
6 #include "memblock.h"
7
8 enum sample_format {
9 SAMPLE_U8,
10 SAMPLE_ALAW,
11 SAMPLE_ULAW,
12 SAMPLE_S16LE,
13 SAMPLE_S16BE,
14 SAMPLE_FLOAT32
15 };
16
17 #define SAMPLE_S16NE SAMPLE_S16LE
18
19 struct sample_spec {
20 enum sample_format format;
21 uint32_t rate;
22 uint8_t channels;
23 };
24
25 #define DEFAULT_SAMPLE_SPEC default_sample_spec
26
27 extern struct sample_spec default_sample_spec;
28
29 struct memblock *silence_memblock(struct memblock* b, struct sample_spec *spec);
30 void silence_memchunk(struct memchunk *c, struct sample_spec *spec);
31 void silence_memory(void *p, size_t length, struct sample_spec *spec);
32
33 struct mix_info {
34 struct memchunk chunk;
35 uint8_t volume;
36 void *userdata;
37 };
38
39 size_t mix_chunks(struct mix_info channels[], unsigned nchannels, void *data, size_t length, struct sample_spec *spec, uint8_t volume);
40
41 size_t bytes_per_second(struct sample_spec *spec);
42 size_t sample_size(struct sample_spec *spec);
43 uint32_t samples_usec(size_t length, struct sample_spec *spec);
44
45 #endif