From 8c334fa3abddc8b6cf797fc5dbeb71282a3a60fe Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 24 Mar 2021 11:48:32 +0100 Subject: [PATCH] alsa: never queue buffers when rate matching When we are following the resampler requested size in capture, never keep queued buffers around or we might get out of sync with the requested size and cause cracks and pops in the resampler. See #805 --- spa/plugins/alsa/alsa-pcm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index 911f12ba2..00d554070 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -1147,6 +1147,9 @@ push_frames(struct state *state, snd_pcm_readi(state->hndl, bufs[0], total_frames); } } + spa_log_trace_fp(state->log, NAME" %p: wrote %ld frames into buffer %d", + state, total_frames, b->id); + spa_list_append(&state->ready, &b->link); } return total_frames; @@ -1307,7 +1310,8 @@ static int handle_capture(struct state *state, uint64_t nsec, return 0; io = state->io; - if (io != NULL && io->status != SPA_STATUS_HAVE_DATA) { + if (io != NULL && + (io->status != SPA_STATUS_HAVE_DATA || state->rate_match != NULL)) { struct buffer *b; if (io->buffer_id < state->n_buffers)