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.
This commit is contained in:
jbosh 2020-01-12 20:12:56 -08:00 committed by GitHub
parent 22b7713287
commit 79d9bc5b45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -324,6 +324,12 @@ static void OnSendAudioDataToDevice(ma_device *pDevice, void *pFramesOut, const
framesToRead -= framesJustRead; framesToRead -= framesJustRead;
framesRead += framesJustRead; framesRead += framesJustRead;
} }
if (!audioBuffer->playing)
{
framesRead = frameCount;
break;
}
// If we weren't able to read all the frames we requested, break // If we weren't able to read all the frames we requested, break
if (framesJustRead < framesToReadRightNow) if (framesJustRead < framesToReadRightNow)