PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2 of the
+ published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
#include <config.h>
#endif
-#include <pulsecore/rtclock.h>
+#include <pulse/rtclock.h>
+
#include <pulsecore/log.h>
#include <pulsecore/mutex.h>
#include "ratelimit.h"
-static pa_static_mutex mutex;
+static pa_static_mutex mutex = PA_STATIC_MUTEX_INIT;
/* Modelled after Linux' lib/ratelimit.c by Dave Young
* <hidave.darkstar@gmail.com>, which is licensed GPLv2. */
-pa_bool_t pa_ratelimit_test(pa_ratelimit *r) {
+bool pa_ratelimit_test(pa_ratelimit *r, pa_log_level_t t) {
pa_usec_t now;
pa_mutex *m;
- now = pa_rtclock_usec();
+ now = pa_rtclock_now();
- m = pa_static_mutex_get(&mutex, FALSE, FALSE);
+ m = pa_static_mutex_get(&mutex, false, false);
pa_mutex_lock(m);
pa_assert(r);
r->begin + r->interval < now) {
if (r->n_missed > 0)
- pa_log_warn("%u events suppressed", r->n_missed);
+ pa_logl(t, "%u events suppressed", r->n_missed);
r->begin = now;
r->n_missed++;
pa_mutex_unlock(m);
- return FALSE;
+ return false;
good:
r->n_printed++;
pa_mutex_unlock(m);
- return TRUE;
+ return true;
}