From 651f4af0ae2a507b85508e4eb1638b9dfa2dc131 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 5 Jul 2022 17:54:44 +0200 Subject: [PATCH] audioadapter: ask more data when converter empty When we are actively driving the stream and the converter needs more data, call the stream process function again to get it so that we don't underrun. Fixes #2494 --- spa/plugins/audioconvert/audioadapter.c | 17 +++++++++++++++-- spa/plugins/audioconvert/audioconvert.c | 3 +++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/spa/plugins/audioconvert/audioadapter.c b/spa/plugins/audioconvert/audioadapter.c index 9071164f1..dcaed9ad3 100644 --- a/spa/plugins/audioconvert/audioadapter.c +++ b/spa/plugins/audioconvert/audioadapter.c @@ -1153,8 +1153,21 @@ static int follower_ready(void *data, int status) if (this->target != this->follower) { this->driver = true; - if (this->direction == SPA_DIRECTION_OUTPUT) - status = spa_node_process(this->convert); + if (this->direction == SPA_DIRECTION_OUTPUT) { + int retry = 8; + while (retry--) { + status = spa_node_process(this->convert); + if (status & SPA_STATUS_HAVE_DATA) + break; + + if (status & SPA_STATUS_NEED_DATA) { + status = spa_node_process(this->follower); + if (!(status & SPA_STATUS_HAVE_DATA)) + break; + } + } + + } } return spa_node_call_ready(&this->callbacks, status); diff --git a/spa/plugins/audioconvert/audioconvert.c b/spa/plugins/audioconvert/audioconvert.c index b8d9c6dc5..9f8097b01 100644 --- a/spa/plugins/audioconvert/audioconvert.c +++ b/spa/plugins/audioconvert/audioconvert.c @@ -2273,6 +2273,9 @@ static int impl_node_process(void *object) io->status = -EINVAL; buf = NULL; } else { + spa_log_trace_fp(this->log, "%p: input buffer port %d io:%p status:%d id:%d n:%d", + this, port->id, io, io->status, io->buffer_id, + port->n_buffers); buf = &port->buffers[io->buffer_id]; }