fixed audio file max length playback

This commit is contained in:
mrbesen 2021-12-14 17:22:33 +01:00
parent b9c1f7c463
commit c8220e2b8d
Signed by untrusted user: MrBesen
GPG Key ID: 596B2350DCD67504
1 changed files with 4 additions and 2 deletions

View File

@ -60,7 +60,7 @@ void SoundDevice::sound_callback(void* outbuffer, ma_uint32 frameCount) {
// if a end frame is set, make sure to not read over it
ma_uint32 shouldReadCount = frameCount;
if(pb->currentFrame + frameCount > pb->endFrame) {
if((pb->currentFrame + frameCount) > pb->endFrame) {
shouldReadCount = pb->endFrame - pb->currentFrame;
}
@ -70,10 +70,12 @@ void SoundDevice::sound_callback(void* outbuffer, ma_uint32 frameCount) {
read = readDecoderandAdd(pDecoder, volume, streamDivider, shouldReadCount, outbuffer);
//decoder fertig -> nicht mehr verwenden
if (read < shouldReadCount) {
if (read < frameCount) {
pb->isDone = true;
--data.decoderCount;
}
pb->currentFrame += read;
}
ma_mutex_unlock(data.mutex);