mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
spa: add spa_ratelimit
This commit is contained in:
parent
17bc9d520e
commit
dc07c2321b
8 changed files with 76 additions and 69 deletions
|
|
@ -52,7 +52,7 @@ struct impl {
|
|||
struct pw_properties *props;
|
||||
void *dbus_name;
|
||||
|
||||
struct ratelimit rate_limit;
|
||||
struct spa_ratelimit rate_limit;
|
||||
|
||||
struct spa_hook_list hooks;
|
||||
struct spa_list servers;
|
||||
|
|
|
|||
|
|
@ -216,10 +216,11 @@ int stream_send_underflow(struct stream *stream, int64_t offset)
|
|||
struct client *client = stream->client;
|
||||
struct impl *impl = client->impl;
|
||||
struct message *reply;
|
||||
int missed;
|
||||
|
||||
if (ratelimit_test(&impl->rate_limit, stream->timestamp, SPA_LOG_LEVEL_INFO)) {
|
||||
pw_log_info("[%s]: UNDERFLOW channel:%u offset:%" PRIi64,
|
||||
client->name, stream->channel, offset);
|
||||
if ((missed = spa_ratelimit_test(&impl->rate_limit, stream->timestamp)) >= 0) {
|
||||
pw_log_info("[%s]: UNDERFLOW channel:%u offset:%" PRIi64" (%d missed)",
|
||||
client->name, stream->channel, offset, missed);
|
||||
}
|
||||
|
||||
reply = message_alloc(impl, -1, 0);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#include <spa/utils/json.h>
|
||||
#include <spa/utils/ringbuffer.h>
|
||||
#include <spa/utils/dll.h>
|
||||
#include <spa/utils/ratelimit.h>
|
||||
#include <spa/debug/types.h>
|
||||
#include <spa/pod/builder.h>
|
||||
#include <spa/param/audio/format-utils.h>
|
||||
|
|
@ -170,7 +171,7 @@ struct impl {
|
|||
pa_stream *pa_stream;
|
||||
uint32_t pa_index;
|
||||
|
||||
struct ratelimit rate_limit;
|
||||
struct spa_ratelimit rate_limit;
|
||||
|
||||
uint32_t target_latency;
|
||||
uint32_t current_latency;
|
||||
|
|
@ -669,19 +670,22 @@ static void stream_underflow_cb(pa_stream *s, void *userdata)
|
|||
{
|
||||
struct impl *impl = userdata;
|
||||
struct timespec ts;
|
||||
int missed;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
if (ratelimit_test(&impl->rate_limit, SPA_TIMESPEC_TO_NSEC(&ts), SPA_LOG_LEVEL_WARN))
|
||||
pw_log_warn("underflow");
|
||||
if ((missed = spa_ratelimit_test(&impl->rate_limit, SPA_TIMESPEC_TO_NSEC(&ts))) >= 0)
|
||||
pw_log_warn("underflow (%d missed)", missed);
|
||||
impl->resync = true;
|
||||
}
|
||||
static void stream_overflow_cb(pa_stream *s, void *userdata)
|
||||
{
|
||||
struct impl *impl = userdata;
|
||||
struct timespec ts;
|
||||
int missed;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
if (ratelimit_test(&impl->rate_limit, SPA_TIMESPEC_TO_NSEC(&ts), SPA_LOG_LEVEL_WARN))
|
||||
pw_log_warn("overflow");
|
||||
if ((missed = spa_ratelimit_test(&impl->rate_limit, SPA_TIMESPEC_TO_NSEC(&ts))) >= 0)
|
||||
pw_log_warn("overflow (%d missed)", missed);
|
||||
impl->resync = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue