From 34b1ecc24488334146e7ada94272f34dcc520842 Mon Sep 17 00:00:00 2001 From: Julian Bouzas Date: Wed, 25 Aug 2021 14:13:03 -0400 Subject: [PATCH] pw-cat: calculate number of samples properly with io_rate_match Fixes wrong buffer sizes when adapter is configured in passthrough mode. --- src/tools/pw-cat.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/tools/pw-cat.c b/src/tools/pw-cat.c index 7c5033acd..bb39cfd73 100644 --- a/src/tools/pw-cat.c +++ b/src/tools/pw-cat.c @@ -153,6 +153,7 @@ struct data { int sync; struct spa_io_position *position; + struct spa_io_rate_match *rate_match; bool drained; uint64_t clock_time; @@ -849,6 +850,9 @@ on_io_changed(void *userdata, uint32_t id, void *data, uint32_t size) case SPA_IO_Position: d->position = data; break; + case SPA_IO_RateMatch: + d->rate_match = data; + break; default: break; } @@ -887,6 +891,8 @@ static void on_process(void *userdata) if (data->mode == mode_playback) { n_frames = d->maxsize / data->stride; + if (data->rate_match && data->rate_match->size > 0) + n_frames = SPA_MIN((uint32_t)n_frames, data->rate_match->size); n_fill_frames = data->fill(data, p, n_frames);