From b0ee669d79b46bef80861aedb7531d7567574b23 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Mon, 8 Dec 2025 13:59:02 -0500 Subject: [PATCH] Fix some music not looping because they supplied bad loop points Turns out mixer just goes to the start if this happens --- src/sdl/al_sound.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/sdl/al_sound.c b/src/sdl/al_sound.c index bc54f89e9..58a27557f 100644 --- a/src/sdl/al_sound.c +++ b/src/sdl/al_sound.c @@ -440,7 +440,15 @@ static boolean I_QueueNextSample(boolean unqueue) // Loop music otherwise stop. if (audio.looping) { - sf_count_t finalposition = SecondsToSamples(audio.loop_point, audio.musicinfo.samplerate); + float songlength = I_GetSongLength() / 1000; + float looppoint = audio.loop_point; + + // Bad Loop Point? + // Go back to the start. + if (audio.loop_point > songlength) + looppoint = 0.0f; + + sf_count_t finalposition = SecondsToSamples(looppoint, audio.musicinfo.samplerate); sf_seek(audio.musicstream, finalposition, SF_SEEK_SET); } } @@ -1475,6 +1483,7 @@ boolean I_LoadSong(char *data, size_t len) else // continue searching p++; } + return true; }