diff options
-rw-r--r-- | engines/agos/midi.cpp | 20 | ||||
-rw-r--r-- | engines/agos/midi.h | 3 |
2 files changed, 10 insertions, 13 deletions
diff --git a/engines/agos/midi.cpp b/engines/agos/midi.cpp index 9563d7d329..552b27ac0c 100644 --- a/engines/agos/midi.cpp +++ b/engines/agos/midi.cpp @@ -64,7 +64,7 @@ MidiPlayer::MidiPlayer() { _paused = false; _currentTrack = 255; - _loopTrackDefault = false; + _loopTrack = 0; _queuedTrack = 255; _loopQueuedTrack = 0; @@ -350,13 +350,13 @@ void MidiPlayer::metaEvent(byte type, byte *data, uint16 length) { return; } else if (_current == &_sfx) { clearConstructs(_sfx); - } else if (_current->loopTrack) { + } else if (_loopTrack) { _current->parser->jumpToTick(0); } else if (_queuedTrack != 255) { _currentTrack = 255; byte destination = _queuedTrack; _queuedTrack = 255; - _current->loopTrack = _loopQueuedTrack; + _loopTrack = _loopQueuedTrack; _loopQueuedTrack = false; // Remember, we're still inside the locked mutex. @@ -484,7 +484,7 @@ void MidiPlayer::setVolume(int musicVol, int sfxVol) { void MidiPlayer::setLoop(bool loop) { Common::StackLock lock(_mutex); - _loopTrackDefault = loop; + _loopTrack = loop; } void MidiPlayer::queueTrack(int track, bool loop) { @@ -651,9 +651,11 @@ void MidiPlayer::loadSMF(Common::File *in, int song, bool sfx) { // It seems that 4 corresponds to our base tempo, so // this should be the right way to calculate it. timerRate = (4 * _driver->getBaseTempo()) / p->data[5]; - p->loopTrack = (p->data[6] != 0); - } else { - p->loopTrack = _loopTrackDefault; + + // According to bug #1004919 calling setLoop() from + // within a lock causes a lockup, though I have no + // idea when this actually happens. + _loopTrack = (p->data[6] != 0); } MidiParser *parser = MidiParser::createParser_SMF(); @@ -723,8 +725,6 @@ void MidiPlayer::loadMultipleSMF(Common::File *in, bool sfx) { p->song_sizes[i] = size; } - p->loopTrack = _loopTrackDefault; - if (!sfx) { _currentTrack = 255; resetVolumeTable(); @@ -756,7 +756,6 @@ void MidiPlayer::loadXMIDI(Common::File *in, bool sfx) { in->seek(pos, 0); p->data = (byte *)calloc(size, 1); in->read(p->data, size); - p->loopTrack = _loopTrackDefault; } else { error("Expected 'FORM' tag but found '%c%c%c%c' instead", buf[0], buf[1], buf[2], buf[3]); } @@ -801,7 +800,6 @@ void MidiPlayer::loadS1D(Common::File *in, bool sfx) { _currentTrack = 255; resetVolumeTable(); } - p->loopTrack = _loopTrackDefault; p->parser = parser; // That plugs the power cord into the wall } diff --git a/engines/agos/midi.h b/engines/agos/midi.h index d0a7d77971..25ebd476c5 100644 --- a/engines/agos/midi.h +++ b/engines/agos/midi.h @@ -53,7 +53,6 @@ struct MusicInfo { MusicInfo() { clear(); } void clear() { parser = 0; data = 0; num_songs = 0; - loopTrack = false; memset(songs, 0, sizeof(songs)); memset(song_sizes, 0, sizeof(song_sizes)); memset(channel, 0, sizeof(channel)); @@ -79,7 +78,7 @@ protected: // These are only used for music. byte _currentTrack; - bool _loopTrackDefault; + bool _loopTrack; byte _queuedTrack; bool _loopQueuedTrack; |