From 892d2cb54e748203b437afe9080cfd3b9f14b739 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Wed, 6 May 2026 21:58:11 +0200 Subject: [PATCH] spa: alsa: pcm: log_write(): fix return value The `fopencookie()` write callback should return the number of consumed bytes, but it currently only ever returns 0, which signals an error condition according to the documentation. Fix that by not overwriting `size`. Fixes: 73073eb33fda ("alsa: redirect alsa output to log file") --- spa/plugins/alsa/alsa-pcm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index eb6304d8b..f99787828 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -716,12 +716,13 @@ static ssize_t log_write(void *cookie, const char *buf, size_t size) struct state *state = cookie; int len; - while (size > 0) { + for (size_t left = size; left > 0; ) { len = strcspn(buf, "\n"); + if (len > 0) spa_log_debug(state->log, "%.*s", (int)len, buf); buf += len + 1; - size -= len + 1; + left -= len + 1; } return size; }