From cd3f8577c1c75fba1b8aabf7d7c8447f945e5d65 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 22 Aug 2007 15:28:31 +0000 Subject: Mutexes are now used in the MIDI music playing code svn-id: r28697 --- engines/saga/music.cpp | 4 ++++ engines/saga/music.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp index 61d0438d2b..11c3fa3f58 100644 --- a/engines/saga/music.cpp +++ b/engines/saga/music.cpp @@ -320,6 +320,8 @@ void MusicPlayer::metaEvent(byte type, byte *data, uint16 length) { void MusicPlayer::onTimer(void *refCon) { MusicPlayer *music = (MusicPlayer *)refCon; + Common::StackLock lock(music->_mutex); + if (music->_isPlaying) music->_parser->onTimer(); } @@ -329,6 +331,8 @@ void MusicPlayer::playMusic() { } void MusicPlayer::stopMusic() { + Common::StackLock lock(_mutex); + _isPlaying = false; if (_parser) { _parser->unloadMusic(); diff --git a/engines/saga/music.h b/engines/saga/music.h index b038a25a11..036fcbf897 100644 --- a/engines/saga/music.h +++ b/engines/saga/music.h @@ -34,6 +34,7 @@ #include "sound/mp3.h" #include "sound/vorbis.h" #include "sound/flac.h" +#include "common/mutex.h" namespace Saga { @@ -77,6 +78,7 @@ public: MidiChannel *getPercussionChannel() { return 0; } MidiParser *_parser; + Common::Mutex _mutex; protected: -- cgit v1.2.3