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...
This commit is contained in:
Torbjörn Andersson 2015-06-14 10:33:31 +02:00
parent 8629feb410
commit 870d0d23a3
2 changed files with 8 additions and 0 deletions

View File

@ -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();

View File

@ -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;