]> code.delx.au - pulseaudio/blob - src/pulsecore/ratelimit.h
remap: Change remapping function argument type from void to int16_t / float as approp...
[pulseaudio] / src / pulsecore / ratelimit.h
1 #ifndef foopulsecoreratelimithfoo
2 #define foopulsecoreratelimithfoo
3
4 /***
5 This file is part of PulseAudio.
6
7 Copyright 2009 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 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 <pulse/sample.h>
26 #include <pulsecore/log.h>
27 #include <pulsecore/macro.h>
28
29 typedef struct pa_ratelimit {
30 pa_usec_t interval;
31 unsigned burst;
32 unsigned n_printed, n_missed;
33 pa_usec_t begin;
34 } pa_ratelimit;
35
36 #define PA_DEFINE_RATELIMIT(_name, _interval, _burst) \
37 pa_ratelimit _name = { \
38 .interval = (_interval), \
39 .burst = (_burst), \
40 .n_printed = 0, \
41 .n_missed = 0, \
42 .begin = 0 \
43 }
44
45 #define PA_INIT_RATELIMIT(v, _interval, _burst) \
46 do { \
47 pa_ratelimit *r = &(v); \
48 r->interval = (_interval); \
49 r->burst = (_burst); \
50 r->n_printed = 0; \
51 r->n_missed = 0; \
52 r->begin = 0; \
53 } while (false);
54
55 bool pa_ratelimit_test(pa_ratelimit *r, pa_log_level_t t);
56
57 #endif