From f31dab9fb860156163dd03e806960391f72ea1d6 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Mon, 1 May 2023 11:55:10 +0300
Subject: [PATCH] music_drflac: fix crash when playing a looped track
Patch from Michael Day
Fixes https://github.com/libsdl-org/SDL_mixer/issues/511
---
src/codecs/music_drflac.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/codecs/music_drflac.c b/src/codecs/music_drflac.c
index ae0cffac..7ce2a89b 100644
--- a/src/codecs/music_drflac.c
+++ b/src/codecs/music_drflac.c
@@ -281,7 +281,7 @@ static int DRFLAC_GetSome(void *context, void *data, int bytes, SDL_bool *done)
if (amount > 0) {
if (music->loop && (music->play_count != 1) &&
((Sint64)music->dec->currentPCMFrame >= music->loop_end)) {
- amount -= (music->dec->currentPCMFrame - music->loop_end) * sizeof(drflac_int16) * music->channels;
+ amount -= (music->dec->currentPCMFrame - music->loop_end);
music->loop_flag = SDL_TRUE;
}
if (SDL_PutAudioStreamData(music->stream, music->buffer, (int)amount * sizeof(drflac_int16) * music->channels) < 0) {