From eff67c3c03c9406b183d9ba8a01cbdbd973f4aa8 Mon Sep 17 00:00:00 2001 From: Torkel Niklasson Date: Thu, 12 Aug 2021 16:56:10 +0200 Subject: [PATCH] Add log level argument to ratelimit_test function If a log message is rate limited, we only need to know about it if we are actually interested in that log level. We therefore add an argument to the ratelimit_test function to set the log level of the message printed if a message is skipped Change-Id: I5ccd4a78bf7e972fe8b0e7133cd7e08c1e38835f --- src/modules/module-protocol-pulse/stream.c | 2 +- src/pipewire/impl-node.c | 4 ++-- src/pipewire/private.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modules/module-protocol-pulse/stream.c b/src/modules/module-protocol-pulse/stream.c index 87115bc71..2dae6ede3 100644 --- a/src/modules/module-protocol-pulse/stream.c +++ b/src/modules/module-protocol-pulse/stream.c @@ -140,7 +140,7 @@ int stream_send_underflow(struct stream *stream, int64_t offset, uint32_t underr struct impl *impl = client->impl; struct message *reply; - if (ratelimit_test(&impl->rate_limit, stream->timestamp)) { + if (ratelimit_test(&impl->rate_limit, stream->timestamp, SPA_LOG_LEVEL_INFO)) { pw_log_info("client %p [%s]: stream %p UNDERFLOW channel:%u offset:%" PRIi64 " underrun:%u", client, client->name, stream, stream->channel, offset, underrun_for); } diff --git a/src/pipewire/impl-node.c b/src/pipewire/impl-node.c index afdc34d0a..391575543 100644 --- a/src/pipewire/impl-node.c +++ b/src/pipewire/impl-node.c @@ -1533,7 +1533,7 @@ static int node_ready(void *data, int status) if (SPA_UNLIKELY(state->pending > 0)) { pw_context_driver_emit_incomplete(node->context, node); - if (ratelimit_test(&node->rt.rate_limit, a->signal_time)) { + if (ratelimit_test(&node->rt.rate_limit, a->signal_time, SPA_LOG_LEVEL_DEBUG)) { pw_log_debug("(%s-%u) graph not finished: state:%p quantum:%"PRIu64 " pending %d/%d", node->name, node->info.id, state, a->position.clock.duration, @@ -1631,7 +1631,7 @@ static int node_xrun(void *data, uint64_t trigger, uint64_t delay, struct spa_po if (da && da != a) update_xrun_stats(da, trigger, delay); - if (ratelimit_test(&this->rt.rate_limit, a->signal_time)) { + if (ratelimit_test(&this->rt.rate_limit, a->signal_time, SPA_LOG_LEVEL_INFO)) { struct spa_fraction rate; if (da) { struct spa_io_clock *cl = &da->position.clock; diff --git a/src/pipewire/private.h b/src/pipewire/private.h index 603869dc4..e7c9978fc 100644 --- a/src/pipewire/private.h +++ b/src/pipewire/private.h @@ -81,11 +81,11 @@ struct ratelimit { unsigned n_printed, n_missed; }; -static inline bool ratelimit_test(struct ratelimit *r, uint64_t now) +static inline bool ratelimit_test(struct ratelimit *r, uint64_t now, enum spa_log_level level) { if (r->begin + r->interval < now) { if (r->n_missed) - pw_log_warn("%u events suppressed", r->n_missed); + pw_log(level, "%u events suppressed", r->n_missed); r->begin = now; r->n_printed = 0; r->n_missed = 0;