summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/base_media_base.h1
-rw-r--r--src/music/dmusic.cpp6
-rw-r--r--src/music/win32_m.cpp6
-rw-r--r--src/music_gui.cpp1
4 files changed, 8 insertions, 6 deletions
diff --git a/src/base_media_base.h b/src/base_media_base.h
index 2974db5cb..891ce4fb9 100644
--- a/src/base_media_base.h
+++ b/src/base_media_base.h
@@ -301,6 +301,7 @@ struct MusicSongInfo {
const char *filename; ///< file on disk containing song (when used in MusicSet class, this pointer is owned by MD5File object for the file)
MusicTrackType filetype; ///< decoder required for song file
int cat_index; ///< entry index in CAT file, for filetype==MTT_MPSMIDI
+ bool loop; ///< song should play in a tight loop if possible, never ending
int override_start; ///< MIDI ticks to skip over in beginning
int override_end; ///< MIDI tick to end the song at (0 if no override)
};
diff --git a/src/music/dmusic.cpp b/src/music/dmusic.cpp
index 3f5ca2255..d48f51e85 100644
--- a/src/music/dmusic.cpp
+++ b/src/music/dmusic.cpp
@@ -832,8 +832,8 @@ static void MidiThreadProc(void *)
/* end? */
if (current_block == current_file.blocks.size()) {
if (current_segment.loop) {
- current_block = 0;
- clock->GetTime(&playback_start_time);
+ current_block = current_segment.start_block;
+ playback_start_time = block_time - current_file.blocks[current_block].realtime * MIDITIME_TO_REFTIME;
} else {
_playback.do_stop = true;
}
@@ -1237,7 +1237,7 @@ void MusicDriver_DMusic::PlaySong(const MusicSongInfo &song)
_playback.next_segment.start = song.override_start;
_playback.next_segment.end = song.override_end;
- _playback.next_segment.loop = false;
+ _playback.next_segment.loop = song.loop;
_playback.do_start = true;
SetEvent(_thread_event);
diff --git a/src/music/win32_m.cpp b/src/music/win32_m.cpp
index 3c059ebed..a32318db1 100644
--- a/src/music/win32_m.cpp
+++ b/src/music/win32_m.cpp
@@ -302,8 +302,8 @@ void CALLBACK TimerCallback(UINT uTimerID, UINT, DWORD_PTR dwUser, DWORD_PTR, DW
/* end? */
if (_midi.current_block == _midi.current_file.blocks.size()) {
if (_midi.current_segment.loop) {
- _midi.current_block = 0;
- _midi.playback_start_time = timeGetTime();
+ _midi.current_block = _midi.current_segment.start_block;
+ _midi.playback_start_time = timeGetTime() - _midi.current_file.blocks[_midi.current_block].realtime / 1000;
} else {
_midi.do_stop = true;
}
@@ -322,7 +322,7 @@ void MusicDriver_Win32::PlaySong(const MusicSongInfo &song)
_midi.next_segment.start = song.override_start;
_midi.next_segment.end = song.override_end;
- _midi.next_segment.loop = false;
+ _midi.next_segment.loop = song.loop;
DEBUG(driver, 2, "Win32-MIDI: PlaySong: setting flag");
_midi.do_stop = _midi.playing;
diff --git a/src/music_gui.cpp b/src/music_gui.cpp
index 4333e889c..c5cfb3bae 100644
--- a/src/music_gui.cpp
+++ b/src/music_gui.cpp
@@ -191,6 +191,7 @@ static void DoPlaySong()
FioFindFullPath(filename, lastof(filename), OLD_GM_DIR, songinfo.filename);
}
songinfo.filename = filename; // non-owned pointer
+ songinfo.loop = (_game_mode == GM_MENU) && (_music_wnd_cursong == 1);
MusicDriver::GetInstance()->PlaySong(songinfo);
SetWindowDirty(WC_MUSIC_WINDOW, 0);
}