From bf57911b83156d8eb506778f9188f68f740848a2 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 61a1a4b26..04abd7fcd 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -715,6 +715,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;