summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2011-03-28 21:36:00 +0000
committerSimon Howard2011-03-28 21:36:00 +0000
commita4ff8b18d8c02b566ec1e203f983fc111408a752 (patch)
tree2a1ff055e17b29f0b10862b5949e79cd83612d8c
parentd706f9693ee6bfd3976fcb232c1563c32b1cff88 (diff)
downloadchocolate-doom-a4ff8b18d8c02b566ec1e203f983fc111408a752.tar.gz
chocolate-doom-a4ff8b18d8c02b566ec1e203f983fc111408a752.tar.bz2
chocolate-doom-a4ff8b18d8c02b566ec1e203f983fc111408a752.zip
Fix OPL MIDI playback when using an empty .mus / .mid file (thanks
Alexandre Xavier). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2313
-rw-r--r--NEWS2
-rw-r--r--src/i_oplmusic.c9
2 files changed, 9 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index b76917f2..c0163f8c 100644
--- 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
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;