volume ramp: additions to the low level infra
[platform/upstream/pulseaudio.git] / src / pulsecore / mix.h
1 #ifndef foomixhfoo
2 #define foomixhfoo
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   Copyright 2013 Peter Meerwald <pmeerw@pmeerw.net>
10
11   PulseAudio is free software; you can redistribute it and/or modify
12   it under the terms of the GNU Lesser General Public License as published
13   by the Free Software Foundation; either version 2.1 of the License,
14   or (at your option) any later version.
15
16   PulseAudio is distributed in the hope that it will be useful, but
17   WITHOUT ANY WARRANTY; without even the implied warranty of
18   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19   General Public License for more details.
20
21   You should have received a copy of the GNU Lesser General Public License
22   along with PulseAudio; if not, write to the Free Software
23   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24   USA.
25 ***/
26
27 #include <pulse/sample.h>
28 #include <pulse/volume.h>
29 #include <pulsecore/memchunk.h>
30
31 typedef struct pa_mix_info {
32     pa_memchunk chunk;
33     pa_cvolume volume;
34     void *userdata;
35
36     /* The following fields are used internally by pa_mix(), should
37      * not be initialised by the caller of pa_mix(). */
38     void *ptr;
39     union {
40         int32_t i;
41         float f;
42     } linear[PA_CHANNELS_MAX];
43 } pa_mix_info;
44
45 size_t pa_mix(
46     pa_mix_info channels[],
47     unsigned nchannels,
48     void *data,
49     size_t length,
50     const pa_sample_spec *spec,
51     const pa_cvolume *volume,
52     bool mute);
53
54 typedef void (*pa_do_mix_func_t) (pa_mix_info streams[], unsigned nstreams, unsigned channels, void *data, unsigned length);
55
56 pa_do_mix_func_t pa_get_mix_func(pa_sample_format_t f);
57 void pa_set_mix_func(pa_sample_format_t f, pa_do_mix_func_t func);
58
59 void pa_volume_memchunk(
60     pa_memchunk*c,
61     const pa_sample_spec *spec,
62     const pa_cvolume *volume);
63
64 typedef struct pa_volume_ramp_int_t {
65     pa_volume_ramp_type_t type;
66     long length;
67     long left;
68     float start;
69     float end;
70     float curr;
71     pa_volume_t target;
72 } pa_volume_ramp_int_t;
73
74 typedef struct pa_cvolume_ramp_int {
75     uint8_t channels;
76     pa_volume_ramp_int_t ramps[PA_CHANNELS_MAX];
77 } pa_cvolume_ramp_int;
78
79 pa_cvolume_ramp_int* pa_cvolume_ramp_convert(const pa_cvolume_ramp *src, pa_cvolume_ramp_int *dst, int sample_rate);
80 bool pa_cvolume_ramp_active(pa_cvolume_ramp_int *ramp);
81 bool pa_cvolume_ramp_target_active(pa_cvolume_ramp_int *ramp);
82 pa_cvolume_ramp_int* pa_cvolume_ramp_start_from(pa_cvolume_ramp_int *src, pa_cvolume_ramp_int *dst);
83 pa_cvolume_ramp_int* pa_cvolume_ramp_int_init(pa_cvolume_ramp_int *src, pa_volume_t vol, int channels);
84 pa_cvolume * pa_cvolume_ramp_get_targets(pa_cvolume_ramp_int *ramp, pa_cvolume *volume);
85
86 void pa_volume_ramp_memchunk(
87         pa_memchunk *c,
88         const pa_sample_spec *spec,
89         pa_cvolume_ramp_int *ramp);
90
91 #endif