aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorbjörn Andersson2015-06-14 10:33:31 +0200
committerTorbjörn Andersson2015-06-14 10:33:31 +0200
commit870d0d23a31f7c3a4d0abc37923b9b7afb2fb8a9 (patch)
tree420aeca9fe8c8d4598c61a6eea7c0ae55d5cf880
parent8629feb410068c084741de1bc2126ed6cd53a4cd (diff)
downloadscummvm-rg350-870d0d23a31f7c3a4d0abc37923b9b7afb2fb8a9.tar.gz
scummvm-rg350-870d0d23a31f7c3a4d0abc37923b9b7afb2fb8a9.tar.bz2
scummvm-rg350-870d0d23a31f7c3a4d0abc37923b9b7afb2fb8a9.zip
SHERLOCK: Add mutex to Sherlock MIDI parser
Hopefully this will put a stop to random crashes when music starts and/or stops. I'm never quite sure just how much locking is necessary, though...
-rw-r--r--engines/sherlock/music.cpp6
-rw-r--r--engines/sherlock/music.h2
2 files changed, 8 insertions, 0 deletions
diff --git a/engines/sherlock/music.cpp b/engines/sherlock/music.cpp
index 1d4c6e08ee..470c6fafb3 100644
--- a/engines/sherlock/music.cpp
+++ b/engines/sherlock/music.cpp
@@ -21,6 +21,7 @@
*/
#include "common/config-manager.h"
+#include "common/mutex.h"
#include "sherlock/sherlock.h"
#include "sherlock/music.h"
#include "sherlock/scalpel/drivers/mididriver.h"
@@ -62,11 +63,14 @@ MidiParser_SH::MidiParser_SH() {
}
MidiParser_SH::~MidiParser_SH() {
+ Common::StackLock lock(_mutex);
unloadMusic();
_driver = NULL;
}
void MidiParser_SH::parseNextEvent(EventInfo &info) {
+ Common::StackLock lock(_mutex);
+
// warning("parseNextEvent");
// there is no delta right at the start of the music data
@@ -165,6 +169,8 @@ void MidiParser_SH::parseNextEvent(EventInfo &info) {
}
bool MidiParser_SH::loadMusic(byte *data, uint32 size) {
+ Common::StackLock lock(_mutex);
+
debugC(kDebugLevelMusic, "Music: loadMusic()");
unloadMusic();
diff --git a/engines/sherlock/music.h b/engines/sherlock/music.h
index 04b9dbd98e..2ebede9ea3 100644
--- a/engines/sherlock/music.h
+++ b/engines/sherlock/music.h
@@ -30,6 +30,7 @@
// for 3DO digital music
#include "audio/audiostream.h"
#include "audio/mixer.h"
+#include "common/mutex.h"
namespace Sherlock {
@@ -41,6 +42,7 @@ public:
~MidiParser_SH();
protected:
+ Common::Mutex _mutex;
virtual void parseNextEvent(EventInfo &info);
uint8 _beats;