From 9c761921abb22ec043d4053b83b076c80dcd4dd0 Mon Sep 17 00:00:00 2001 From: David Reid Date: Tue, 9 Mar 2021 19:28:13 +1000 Subject: [PATCH] Try fixing an infinite loop. --- research/miniaudio_engine.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/research/miniaudio_engine.h b/research/miniaudio_engine.h index b5a8fb5c..112f8d57 100644 --- a/research/miniaudio_engine.h +++ b/research/miniaudio_engine.h @@ -9968,7 +9968,7 @@ static void ma_engine_node_process_pcm_frames__general(ma_engine_node* pEngineNo isPanningEnabled = pEngineNode->panner.pan != 0 && channelsOut != 1; /* Keep going while we've still got data available for processing. */ - while (totalFramesProcessedIn < frameCountIn && totalFramesProcessedOut < frameCountOut) { + while (totalFramesProcessedOut < frameCountOut) { /* We need to process in a specific order. We always do resampling first because it's likely we're going to be increasing the channel count after spatialization. Also, I want to do @@ -10082,9 +10082,14 @@ static void ma_engine_node_process_pcm_frames__general(ma_engine_node* pEngineNo ma_panner_process_pcm_frames(&pEngineNode->panner, pRunningFramesOut, pRunningFramesOut, framesJustProcessedOut); /* In-place processing. */ } - /* We're done. */ + /* We're done for this chunk. */ totalFramesProcessedIn += framesJustProcessedIn; totalFramesProcessedOut += framesJustProcessedOut; + + /* If we didn't process any output frames this iteration it means we've either run out of input data, or run out of room in the output buffer. */ + if (framesJustProcessedOut == 0) { + break; + } } /* At this point we're done processing. */