From 019434a37e02aa3ae319d5c7254c97a8bae42227 Mon Sep 17 00:00:00 2001 From: jbosh Date: Tue, 14 Jan 2020 00:15:52 -0800 Subject: [PATCH] Fix for short non-looping sounds (#1067) Short non-looping sounds can sometimes think they need to keep playing and will output their first few frames again. This helps to break out of all the loops instead of just this one. --- src/raudio.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/raudio.c b/src/raudio.c index b94f0e655..9fde6e952 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -324,6 +324,12 @@ static void OnSendAudioDataToDevice(ma_device *pDevice, void *pFramesOut, const framesToRead -= framesJustRead; framesRead += framesJustRead; } + + if (!audioBuffer->playing) + { + framesRead = frameCount; + break; + } // If we weren't able to read all the frames we requested, break if (framesJustRead < framesToReadRightNow)