From 94f898ddc55e90f70279316020aa04d1b915bea0 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 30 Nov 2023 11:10:47 +0100 Subject: [PATCH] stream: check requested before use It can be 0 and so we should fill the complete buffer. Fixes #3683 --- src/examples/audio-src.c | 4 +++- src/tools/pw-cat.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/examples/audio-src.c b/src/examples/audio-src.c index f6120b345..22b6a581a 100644 --- a/src/examples/audio-src.c +++ b/src/examples/audio-src.c @@ -73,7 +73,9 @@ static void on_process(void *userdata) return; stride = sizeof(float) * DEFAULT_CHANNELS; - n_frames = SPA_MIN(b->requested, buf->datas[0].maxsize / stride); + n_frames = buf->datas[0].maxsize / stride; + if (b->requested) + n_frames = SPA_MIN((int)b->requested, n_frames); fill_f32(data, p, n_frames); diff --git a/src/tools/pw-cat.c b/src/tools/pw-cat.c index db6d61743..2ed7529fd 100644 --- a/src/tools/pw-cat.c +++ b/src/tools/pw-cat.c @@ -845,7 +845,8 @@ static void on_process(void *userdata) bool null_frame = false; n_frames = d->maxsize / data->stride; - n_frames = SPA_MIN(n_frames, (int)b->requested); + if (b->requested) + n_frames = SPA_MIN(n_frames, (int)b->requested); /* Note that when playing encoded audio, the encoded_playback_fill() * fill callback actually returns number of bytes, not frames, since