A workaround for XM looping

I’ve been able to get around the looping problem without modifying
MikMod; I simply needed to add 2 lines of code to Mix_PlayMusic().
Since my fix would interfere with loop counting, I have set it to only
interfere if it’s supposed to loop infinitely.

/* Play a music chunk. Returns 0, or -1 if there was an error.
*/
int Mix_PlayMusic(Mix_Music music, int loops)
{
/
Don’t play null pointers :slight_smile: /
if ( music == NULL ) {
return(-1);
}
/
If the current music is fading out, wait for the fade to complete */

while ( music_playing && !music_stopped &&
music_playing->fading==MIX_FADING_OUT ) {
SDL_Delay(100);
}

//Special case for MODs: If looping infinitely, have them
//loop properly.
if((music->type==MUS_MOD)&&(loops==-1))
music->data.module->wrap=1;
else music->data.module->wrap=0;

if ( lowlevel_play(music) < 0 ) {
return(-1);
}

music_active = 1;
music_stopped = 0;
music_loops = loops;
music_playing = music;
music_playing->fading = MIX_NO_FADING;
return(0);
}