From d30517d6f3442ecd61644780471029996624b0a1 Mon Sep 17 00:00:00 2001 From: Carsten Teibes Date: Sun, 22 Oct 2017 18:35:00 +0200 Subject: [PATCH] Do manual looping with Modplug This is not gapless, but still better than silence, when the Modplug library has not been patched. Closes #32. --- src/io/sound.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/io/sound.cpp b/src/io/sound.cpp index 00bacdab..8a58e5ab 100644 --- a/src/io/sound.cpp +++ b/src/io/sound.cpp @@ -114,7 +114,15 @@ void audioCallback (void * userdata, unsigned char * stream, int len) { // Read the next portion of music into the audio stream #if defined(USE_MODPLUG) - if (musicFile) ModPlug_Read(musicFile, stream, len); + if (musicFile) { + int bytes_read = ModPlug_Read(musicFile, stream, len); + + // poor mans loop (so modplug needs no patching) + if (bytes_read < len) { + ModPlug_Seek(musicFile, 0); + ModPlug_Read(musicFile, stream + bytes_read, len - bytes_read); + } + } #elif defined(USE_XMP)