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, see <http://www.gnu.org/licenses/>. 21 ***/ 22 23 #include <pulse/sample.h> 24 #include <pulsecore/log.h> 25 #include <pulsecore/macro.h> 26 27 typedef struct pa_ratelimit { 28 pa_usec_t interval; 29 unsigned burst; 30 unsigned n_printed, n_missed; 31 pa_usec_t begin; 32 } pa_ratelimit; 33 34 #define PA_DEFINE_RATELIMIT(_name, _interval, _burst) \ 35 pa_ratelimit _name = { \ 36 .interval = (_interval), \ 37 .burst = (_burst), \ 38 .n_printed = 0, \ 39 .n_missed = 0, \ 40 .begin = 0 \ 41 } 42 43 #define PA_INIT_RATELIMIT(v, _interval, _burst) \ 44 do { \ 45 pa_ratelimit *r = &(v); \ 46 r->interval = (_interval); \ 47 r->burst = (_burst); \ 48 r->n_printed = 0; \ 49 r->n_missed = 0; \ 50 r->begin = 0; \ 51 } while (false); 52 53 bool pa_ratelimit_test(pa_ratelimit *r, pa_log_level_t t); 54 55 #endif 56