1 | diff --git a/engines/agos/midi.cpp b/engines/agos/midi.cpp
|
---|
2 | index c26fbe3..045fd9d 100644
|
---|
3 | --- a/engines/agos/midi.cpp
|
---|
4 | +++ b/engines/agos/midi.cpp
|
---|
5 | @@ -52,7 +52,7 @@ MidiPlayer::MidiPlayer() {
|
---|
6 | _paused = false;
|
---|
7 |
|
---|
8 | _currentTrack = 255;
|
---|
9 | - _loopTrack = 0;
|
---|
10 | + _loopTrackDefault = false;
|
---|
11 | _queuedTrack = 255;
|
---|
12 | _loopQueuedTrack = 0;
|
---|
13 | }
|
---|
14 | @@ -166,13 +166,13 @@ void MidiPlayer::metaEvent(byte type, byte *data, uint16 length) {
|
---|
15 | return;
|
---|
16 | } else if (_current == &_sfx) {
|
---|
17 | clearConstructs(_sfx);
|
---|
18 | - } else if (_loopTrack) {
|
---|
19 | + } else if (_current->loopTrack) {
|
---|
20 | _current->parser->jumpToTick(0);
|
---|
21 | } else if (_queuedTrack != 255) {
|
---|
22 | _currentTrack = 255;
|
---|
23 | byte destination = _queuedTrack;
|
---|
24 | _queuedTrack = 255;
|
---|
25 | - _loopTrack = _loopQueuedTrack;
|
---|
26 | + _current->loopTrack = _loopQueuedTrack;
|
---|
27 | _loopQueuedTrack = false;
|
---|
28 |
|
---|
29 | // Remember, we're still inside the locked mutex.
|
---|
30 | @@ -300,7 +300,7 @@ void MidiPlayer::setVolume(int musicVol, int sfxVol) {
|
---|
31 | void MidiPlayer::setLoop(bool loop) {
|
---|
32 | Common::StackLock lock(_mutex);
|
---|
33 |
|
---|
34 | - _loopTrack = loop;
|
---|
35 | + _loopTrackDefault = loop;
|
---|
36 | }
|
---|
37 |
|
---|
38 | void MidiPlayer::queueTrack(int track, bool loop) {
|
---|
39 | @@ -405,7 +405,7 @@ void MidiPlayer::loadSMF(Common::File *in, int song, bool sfx) {
|
---|
40 |
|
---|
41 | uint32 timerRate = _driver->getBaseTempo();
|
---|
42 |
|
---|
43 | - if (!memcmp(p->data, "GMF\x1", 4)) {
|
---|
44 | + if (isGMF) {
|
---|
45 | // The GMF header
|
---|
46 | // 3 BYTES: 'GMF'
|
---|
47 | // 1 BYTE : Major version
|
---|
48 | @@ -426,11 +426,9 @@ void MidiPlayer::loadSMF(Common::File *in, int song, bool sfx) {
|
---|
49 | // It seems that 4 corresponds to our base tempo, so
|
---|
50 | // this should be the right way to calculate it.
|
---|
51 | timerRate = (4 * _driver->getBaseTempo()) / p->data[5];
|
---|
52 | -
|
---|
53 | - // According to bug #1004919 calling setLoop() from
|
---|
54 | - // within a lock causes a lockup, though I have no
|
---|
55 | - // idea when this actually happens.
|
---|
56 | - _loopTrack = (p->data[6] != 0);
|
---|
57 | + p->loopTrack = (p->data[6] != 0);
|
---|
58 | + } else {
|
---|
59 | + p->loopTrack = _loopTrackDefault;
|
---|
60 | }
|
---|
61 |
|
---|
62 | MidiParser *parser = MidiParser::createParser_SMF();
|
---|
63 | @@ -500,6 +498,8 @@ void MidiPlayer::loadMultipleSMF(Common::File *in, bool sfx) {
|
---|
64 | p->song_sizes[i] = size;
|
---|
65 | }
|
---|
66 |
|
---|
67 | + p->loopTrack = _loopTrackDefault;
|
---|
68 | +
|
---|
69 | if (!sfx) {
|
---|
70 | _currentTrack = 255;
|
---|
71 | resetVolumeTable();
|
---|
72 | @@ -531,6 +531,7 @@ void MidiPlayer::loadXMIDI(Common::File *in, bool sfx) {
|
---|
73 | in->seek(pos, 0);
|
---|
74 | p->data = (byte *)calloc(size, 1);
|
---|
75 | in->read(p->data, size);
|
---|
76 | + p->loopTrack = _loopTrackDefault;
|
---|
77 | } else {
|
---|
78 | error("Expected 'FORM' tag but found '%c%c%c%c' instead", buf[0], buf[1], buf[2], buf[3]);
|
---|
79 | }
|
---|
80 | @@ -575,6 +576,7 @@ void MidiPlayer::loadS1D(Common::File *in, bool sfx) {
|
---|
81 | _currentTrack = 255;
|
---|
82 | resetVolumeTable();
|
---|
83 | }
|
---|
84 | + p->loopTrack = _loopTrackDefault;
|
---|
85 | p->parser = parser; // That plugs the power cord into the wall
|
---|
86 | }
|
---|
87 |
|
---|
88 | diff --git a/engines/agos/midi.h b/engines/agos/midi.h
|
---|
89 | index 3efaddd..398e445 100644
|
---|
90 | --- a/engines/agos/midi.h
|
---|
91 | +++ b/engines/agos/midi.h
|
---|
92 | @@ -36,6 +36,7 @@ namespace AGOS {
|
---|
93 | struct MusicInfo {
|
---|
94 | MidiParser *parser;
|
---|
95 | byte *data;
|
---|
96 | + bool loopTrack;
|
---|
97 | byte num_songs; // For Type 1 SMF resources
|
---|
98 | byte *songs[16]; // For Type 1 SMF resources
|
---|
99 | uint32 song_sizes[16]; // For Type 1 SMF resources
|
---|
100 | @@ -46,6 +47,7 @@ struct MusicInfo {
|
---|
101 | MusicInfo() { clear(); }
|
---|
102 | void clear() {
|
---|
103 | parser = 0; data = 0; num_songs = 0;
|
---|
104 | + loopTrack = false;
|
---|
105 | memset(songs, 0, sizeof(songs));
|
---|
106 | memset(song_sizes, 0, sizeof(song_sizes));
|
---|
107 | memset(channel, 0, sizeof(channel));
|
---|
108 | @@ -71,7 +73,7 @@ protected:
|
---|
109 |
|
---|
110 | // These are only used for music.
|
---|
111 | byte _currentTrack;
|
---|
112 | - bool _loopTrack;
|
---|
113 | + bool _loopTrackDefault;
|
---|
114 | byte _queuedTrack;
|
---|
115 | bool _loopQueuedTrack;
|
---|
116 |
|
---|