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: 73073eb33f ("alsa: redirect alsa output to log file")
This commit is contained in:
Barnabás Pőcze 2026-05-06 21:58:11 +02:00 committed by Wim Taymans
parent 5ea19f5fca
commit 892d2cb54e

View file

@ -716,12 +716,13 @@ static ssize_t log_write(void *cookie, const char *buf, size_t size)
struct state *state = cookie; struct state *state = cookie;
int len; int len;
while (size > 0) { for (size_t left = size; left > 0; ) {
len = strcspn(buf, "\n"); len = strcspn(buf, "\n");
if (len > 0) if (len > 0)
spa_log_debug(state->log, "%.*s", (int)len, buf); spa_log_debug(state->log, "%.*s", (int)len, buf);
buf += len + 1; buf += len + 1;
size -= len + 1; left -= len + 1;
} }
return size; return size;
} }