From 5bf32c47e582ec18ac166367fd86bb1e4b512b16 Mon Sep 17 00:00:00 2001 From: David Reid Date: Mon, 13 Jul 2026 07:45:59 +1000 Subject: [PATCH] Fix a bug where the end of a sound is cutoff. Public issue https://github.com/mackron/miniaudio/issues/1125 --- miniaudio.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/miniaudio.h b/miniaudio.h index 6463425c..20130fb4 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -77123,6 +77123,15 @@ static void ma_engine_node_process_pcm_frames__sound(ma_node* pNode, const float } framesJustRead = totalFramesConverted; + + /* + When the last iteration of the loop above returns MA_AT_END, we can be in a situation where `result` is MA_AT_END and + framesJustRead is >0. This is never valid in miniaudio so we need to normalize this (MA_AT_END should only be used + when the number of frames read is exactly 0, everywhere in miniaudio). + */ + if (result == MA_AT_END && framesJustRead > 0) { + result = MA_SUCCESS; + } } MA_ASSERT(framesJustRead <= pSound->processingCacheCap);