From 79d9bc5b45c3bd669814bac2e2f780f353a802dc Mon Sep 17 00:00:00 2001 From: jbosh Date: Sun, 12 Jan 2020 20:12:56 -0800 Subject: [PATCH] Fix for short non-looping sounds 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)