volume ramp: additions to the low level infra
[platform/upstream/pulseaudio.git] / src / pulsecore / time-smoother.h
1 #ifndef foopulsetimesmootherhfoo
2 #define foopulsetimesmootherhfoo
3
4 /***
5   This file is part of PulseAudio.
6
7   Copyright 2007 Lennart Poettering
8
9   PulseAudio is free software; you can redistribute it and/or modify
10   it under the terms of the GNU Lesser General Public License as
11   published by the Free Software Foundation; either version 2.1 of the
12   License, or (at your option) any later version.
13
14   PulseAudio is distributed in the hope that it will be useful, but
15   WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17   Lesser General Public License for more details.
18
19   You should have received a copy of the GNU Lesser General Public
20   License along with PulseAudio; if not, write to the Free Software
21   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22   USA.
23 ***/
24
25 #include <pulsecore/macro.h>
26 #include <pulse/sample.h>
27
28 typedef struct pa_smoother pa_smoother;
29
30 pa_smoother* pa_smoother_new(
31         pa_usec_t x_adjust_time,
32         pa_usec_t x_history_time,
33         bool monotonic,
34         bool smoothing,
35         unsigned min_history,
36         pa_usec_t x_offset,
37         bool paused);
38
39 void pa_smoother_free(pa_smoother* s);
40
41 /* Adds a new value to our dataset. x = local/system time, y = remote time */
42 void pa_smoother_put(pa_smoother *s, pa_usec_t x, pa_usec_t y);
43
44 /* Returns an interpolated value based on the dataset. x = local/system time, return value = remote time */
45 pa_usec_t pa_smoother_get(pa_smoother *s, pa_usec_t x);
46
47 /* Translates a time span from the remote time domain to the local one. x = local/system time when to estimate, y_delay = remote time span */
48 pa_usec_t pa_smoother_translate(pa_smoother *s, pa_usec_t x, pa_usec_t y_delay);
49
50 void pa_smoother_set_time_offset(pa_smoother *s, pa_usec_t x_offset);
51
52 void pa_smoother_pause(pa_smoother *s, pa_usec_t x);
53 void pa_smoother_resume(pa_smoother *s, pa_usec_t x, bool abrupt);
54
55 void pa_smoother_reset(pa_smoother *s, pa_usec_t time_offset, bool paused);
56
57 void pa_smoother_fix_now(pa_smoother *s);
58
59 #endif