diff options
author | Max Horn | 2011-03-23 11:50:37 +0100 |
---|---|---|
committer | Max Horn | 2011-03-23 15:25:46 +0100 |
commit | 2bc842dcee9552b302ac1acc927e6305ab6fad19 (patch) | |
tree | 9a10c1075d7f25da952f760d8156f022a2922a39 /engines | |
parent | 7b02dac3c5678bb47216495fc97130b98ff2bfe4 (diff) | |
download | scummvm-rg350-2bc842dcee9552b302ac1acc927e6305ab6fad19.tar.gz scummvm-rg350-2bc842dcee9552b302ac1acc927e6305ab6fad19.tar.bz2 scummvm-rg350-2bc842dcee9552b302ac1acc927e6305ab6fad19.zip |
AGOS: Sanitize the mutex locking in MidiPlayer::startTrack
Diffstat (limited to 'engines')
-rw-r--r-- | engines/agos/midi.cpp | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/engines/agos/midi.cpp b/engines/agos/midi.cpp index e80b89d43c..bbc0181b11 100644 --- a/engines/agos/midi.cpp +++ b/engines/agos/midi.cpp @@ -62,9 +62,8 @@ MidiPlayer::MidiPlayer() { } MidiPlayer::~MidiPlayer() { - _mutex.lock(); + Common::StackLock lock(_mutex); close(); - _mutex.unlock(); } int MidiPlayer::open() { @@ -211,6 +210,8 @@ void MidiPlayer::onTimer(void *data) { } void MidiPlayer::startTrack(int track) { + Common::StackLock lock(_mutex); + if (track == _currentTrack) return; @@ -218,8 +219,6 @@ void MidiPlayer::startTrack(int track) { if (track >= _music.num_songs) return; - _mutex.lock(); - if (_music.parser) { _current = &_music; delete _music.parser; @@ -240,9 +239,7 @@ void MidiPlayer::startTrack(int track) { _currentTrack = (byte)track; _music.parser = parser; // That plugs the power cord into the wall } else if (_music.parser) { - _mutex.lock(); if (!_music.parser->setTrack(track)) { - _mutex.unlock(); return; } _currentTrack = (byte)track; @@ -250,8 +247,6 @@ void MidiPlayer::startTrack(int track) { _music.parser->jumpToTick(0); _current = 0; } - - _mutex.unlock(); } void MidiPlayer::stop() { |