From c8462edf4b2d44f9d0f90710848b71a853f96051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Wed, 6 May 2026 22:00:04 +0200 Subject: [PATCH] spa: alsa: pcm: log_write(): return early if log level is disabled If the "debug" log level is not enabled for the "spa.alsa" log topic, then there is no point in going into the loop and splitting the data into lines, so skip that. --- spa/plugins/alsa/alsa-pcm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index 1b6d74824..458c40ec9 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -717,6 +717,9 @@ static ssize_t log_write(void *cookie, const char *buf, size_t size) { struct state *state = cookie; + if (!spa_log_level_topic_enabled(state->log, SPA_LOG_TOPIC_DEFAULT, SPA_LOG_LEVEL_DEBUG)) + return size; + for (size_t left = size; left > 0; ) { const char *end = memchr(buf, '\n', left); size_t len = end ? end - buf : left;