summaryrefslogtreecommitdiff
path: root/src/music/dmusic.cpp
diff options
context:
space:
mode:
authorNiels Martin Hansen <nielsm@indvikleren.dk>2018-03-04 23:34:02 +0100
committerMichael Lutz <michi@icosahedron.de>2018-06-15 23:09:17 +0200
commit276192f714d6816088791435c1b70dfa7122cdbd (patch)
tree98ca1f899d2769c7538333617ee01db1bd2c68b7 /src/music/dmusic.cpp
parent836d25e738b78d1c8820ecab1f7bd90b0833ca17 (diff)
downloadopenttd-276192f714d6816088791435c1b70dfa7122cdbd.tar.xz
Change #6684: Cutting point overrides for music base sets
This improves bad looping of title screen song from Windows TTD, and fixes a long silence at the end of "Can't get there from here" from Windows TTD.
Diffstat (limited to 'src/music/dmusic.cpp')
-rw-r--r--src/music/dmusic.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/music/dmusic.cpp b/src/music/dmusic.cpp
index ce76d22ef..3b6ae3454 100644
--- a/src/music/dmusic.cpp
+++ b/src/music/dmusic.cpp
@@ -723,14 +723,6 @@ static void MidiThreadProc(void *)
while (current_block < current_file.blocks.size()) {
MidiFile::DataBlock &block = current_file.blocks[current_block];
- /* check that block is not in the future */
- REFERENCE_TIME playback_time = current_time - playback_start_time;
- if (block.realtime * MIDITIME_TO_REFTIME > playback_time + 3 *_playback.preload_time * MS_TO_REFTIME) {
- /* Stop the thread loop until we are at the preload time of the next block. */
- next_timeout = Clamp(((int64)block.realtime * MIDITIME_TO_REFTIME - playback_time) / MS_TO_REFTIME - _playback.preload_time, 0, 1000);
- DEBUG(driver, 9, "DMusic thread: Next event in %u ms (music %u, ref %lld)", next_timeout, block.realtime * MIDITIME_TO_REFTIME, playback_time);
- break;
- }
/* check that block isn't at end-of-song override */
if (current_segment.end > 0 && block.ticktime >= current_segment.end) {
if (current_segment.loop) {
@@ -743,6 +735,14 @@ static void MidiThreadProc(void *)
next_timeout = 0;
break;
}
+ /* check that block is not in the future */
+ REFERENCE_TIME playback_time = current_time - playback_start_time;
+ if (block.realtime * MIDITIME_TO_REFTIME > playback_time + 3 *_playback.preload_time * MS_TO_REFTIME) {
+ /* Stop the thread loop until we are at the preload time of the next block. */
+ next_timeout = Clamp(((int64)block.realtime * MIDITIME_TO_REFTIME - playback_time) / MS_TO_REFTIME - _playback.preload_time, 0, 1000);
+ DEBUG(driver, 9, "DMusic thread: Next event in %u ms (music %u, ref %lld)", next_timeout, block.realtime * MIDITIME_TO_REFTIME, playback_time);
+ break;
+ }
/* Timestamp of the current block. */
block_time = playback_start_time + block.realtime * MIDITIME_TO_REFTIME;
@@ -1232,8 +1232,8 @@ void MusicDriver_DMusic::PlaySong(const MusicSongInfo &song)
if (!_playback.next_file.LoadSong(song)) return;
- _playback.next_segment.start = 0;
- _playback.next_segment.end = 0;
+ _playback.next_segment.start = song.override_start;
+ _playback.next_segment.end = song.override_end;
_playback.next_segment.loop = false;
_playback.do_start = true;