ref: a4ff8b18d8c02b566ec1e203f983fc111408a752
parent: d706f9693ee6bfd3976fcb232c1563c32b1cff88
author: Simon Howard <[email protected]>
date: Mon Mar 28 17:36:00 EDT 2011
Fix OPL MIDI playback when using an empty .mus / .mid file (thanks Alexandre Xavier). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2313
--- a/NEWS
+++ b/NEWS
@@ -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
--- a/src/i_oplmusic.c
+++ b/src/i_oplmusic.c
@@ -1080,7 +1080,7 @@
// Restart a song from the beginning.
-static void RestartSong(void)
+static void RestartSong(void *unused)
{
unsigned int i;
@@ -1118,10 +1118,15 @@
--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;