Skip to content

Commit

Permalink
Do manual looping with Modplug
Browse files Browse the repository at this point in the history
This is not gapless, but still better than silence, when the Modplug
library has not been patched.

Closes #32.
  • Loading branch information
carstene1ns committed Oct 22, 2017
1 parent 17aca62 commit d30517d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/io/sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit d30517d

Please sign in to comment.