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 ff7b996596
commit bba43d4433

View file

@ -718,12 +718,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;
}