aboutsummaryrefslogtreecommitdiff
path: root/engines/touche
diff options
context:
space:
mode:
Diffstat (limited to 'engines/touche')
-rw-r--r--engines/touche/midi.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/engines/touche/midi.cpp b/engines/touche/midi.cpp
index c420fb34ff..c1270dd2e2 100644
--- a/engines/touche/midi.cpp
+++ b/engines/touche/midi.cpp
@@ -48,32 +48,30 @@ void MidiPlayer::play(Common::ReadStream &stream, int size, bool loop) {
_midiData = (uint8 *)malloc(size);
if (_midiData) {
stream.read(_midiData, size);
- _mutex.lock();
+
+ Common::StackLock lock(_mutex);
_parser->loadMusic(_midiData, size);
_parser->setTrack(0);
_isLooping = loop;
_isPlaying = true;
- _mutex.unlock();
}
}
void MidiPlayer::stop() {
- _mutex.lock();
+ Common::StackLock lock(_mutex);
if (_isPlaying) {
_isPlaying = false;
_parser->unloadMusic();
free(_midiData);
_midiData = 0;
}
- _mutex.unlock();
}
void MidiPlayer::updateTimer() {
- _mutex.lock();
+ Common::StackLock lock(_mutex);
if (_isPlaying) {
_parser->onTimer();
}
- _mutex.unlock();
}
void MidiPlayer::adjustVolume(int diff) {
@@ -82,13 +80,12 @@ void MidiPlayer::adjustVolume(int diff) {
void MidiPlayer::setVolume(int volume) {
_masterVolume = CLIP(volume, 0, 255);
- _mutex.lock();
+ Common::StackLock lock(_mutex);
for (int i = 0; i < NUM_CHANNELS; ++i) {
if (_channelsTable[i]) {
_channelsTable[i]->volume(_channelsVolume[i] * _masterVolume / 255);
}
}
- _mutex.unlock();
}
int MidiPlayer::open() {
@@ -116,14 +113,14 @@ bool MidiPlayer::isOpen() const {
void MidiPlayer::close() {
stop();
- _mutex.lock();
+
+ Common::StackLock lock(_mutex);
_driver->setTimerCallback(NULL, NULL);
_driver->close();
delete _driver;
_driver = 0;
_parser->setMidiDriver(NULL);
delete _parser;
- _mutex.unlock();
}
void MidiPlayer::send(uint32 b) {