From 24ab22db124a354f0346b21664ab0c2b6ec74f66 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 18 Dec 2019 12:58:42 +0100 Subject: [PATCH] audioadapter: avoid infinite loop Rewrite the slave/converter loop a little to avoid infinite loops. --- spa/plugins/audioconvert/audioadapter.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/spa/plugins/audioconvert/audioadapter.c b/spa/plugins/audioconvert/audioadapter.c index 696d5f3bb..c64838b97 100644 --- a/spa/plugins/audioconvert/audioadapter.c +++ b/spa/plugins/audioconvert/audioadapter.c @@ -875,16 +875,21 @@ static int impl_node_process(void *object) status = spa_node_process(this->convert); } -again: status = spa_node_process(this->slave); if (this->direction == SPA_DIRECTION_OUTPUT && !this->master && this->use_converter) { - status = spa_node_process(this->convert); + while (true) { + status = spa_node_process(this->convert); + if (status & SPA_STATUS_HAVE_DATA) + break; - if (!(status & SPA_STATUS_HAVE_DATA) && - (status & SPA_STATUS_NEED_DATA)) - goto again; + if (status & SPA_STATUS_NEED_DATA) { + status = spa_node_process(this->slave); + if (!(status & SPA_STATUS_HAVE_DATA)) + break; + } + } } spa_log_trace_fp(this->log, "%p: process status:%d", this, status);