diff options
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | src/i_oplmusic.c | 9 |
2 files changed, 9 insertions, 2 deletions
@@ -41,6 +41,8 @@ Xavier). * Weapon cycling from the shotgun to the chaingun in Doom 1 now works properly (thanks Alexandre Xavier). + * MIDI playback that locked up when using an empty MUS / MIDI + file (thanks Alexandre Xavier). libtextscreen: * It is now possible to type a '+' in input boxes (thanks diff --git a/src/i_oplmusic.c b/src/i_oplmusic.c index e8d65d6d..97ba0783 100644 --- a/src/i_oplmusic.c +++ b/src/i_oplmusic.c @@ -1080,7 +1080,7 @@ static void ScheduleTrack(opl_track_data_t *track); // Restart a song from the beginning. -static void RestartSong(void) +static void RestartSong(void *unused) { unsigned int i; @@ -1118,10 +1118,15 @@ static void TrackTimerCallback(void *arg) --running_tracks; // When all tracks have finished, restart the song. + // Don't restart the song immediately, but wait for 5ms + // before triggering a restart. Otherwise it is possible + // to construct an empty MIDI file that causes the game + // to lock up in an infinite loop. (5ms should be short + // enough not to be noticeable by the listener). if (running_tracks <= 0 && song_looping) { - RestartSong(); + OPL_SetCallback(5, RestartSong, NULL); } return; |