pw-cat: calculate number of samples properly with io_rate_match

Fixes wrong buffer sizes when adapter is configured in passthrough mode.
This commit is contained in:
Julian Bouzas 2021-08-25 14:13:03 -04:00 committed by Wim Taymans
parent a701a500af
commit 34b1ecc244

View file

@ -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);