From: Holger Schemel Date: Mon, 3 Jun 2019 20:10:25 +0000 (+0200) Subject: fixed sporadic problems when playing MP3 files on Windows X-Git-Tag: 4.1.4.0~26 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=d7c2e950f49481d2cff5657a53519535c24d1c24;p=rocksndiamonds.git fixed sporadic problems when playing MP3 files on Windows This change (hopefully) fixes a problem that may sporadically occur when playing MP3 files on Windows, in which case audio output is either completely silent or music is stuttering instead of playing normally. The problem seems to be fixed by stopping the music channel before playing the next track. --- diff --git a/src/libgame/sound.c b/src/libgame/sound.c index ed50734b..0434b553 100644 --- a/src/libgame/sound.c +++ b/src/libgame/sound.c @@ -131,6 +131,7 @@ static void ReloadCustomMusic(void); static void FreeSound(void *); static void FreeMusic(void *); static void FreeAllMusic_NoConf(void); +static void Mixer_StopMusicChannel(void); static SoundInfo *getSoundInfoEntryFromSoundID(int); static MusicInfo *getMusicInfoEntryFromMusicID(int); @@ -223,6 +224,10 @@ static void Mixer_PlayMusicChannel(void) { int loops = (IS_LOOP(mixer[audio.music_channel]) ? -1 : 1); + // stopping music channel before playing next track seems to be needed to + // prevent audio problems that may occur when playing MP3 files on Windows + Mixer_StopMusicChannel(); + // use short fade-in to prevent "plop" sound for certain music files // (this may happen when switching on music while playing the game) Mix_VolumeMusic(mixer[audio.music_channel].volume);