From 1a2d4c9c28e0c44fbf6f5af936e7a59a9e1ebc45 Mon Sep 17 00:00:00 2001 From: Gregory Montoir Date: Sun, 2 Dec 2007 14:34:33 +0000 Subject: revised mutex handling a bit in dimuse : - protected access to Track.used in startSound - removed mutex lock in cloneToFadeOutTrack as it's always called with mutex already locked on (shouldn't change anything, though, due to mutex re-entrancy) svn-id: r29705 --- engines/scumm/imuse_digi/dimuse_track.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/scumm/imuse_digi/dimuse_track.cpp b/engines/scumm/imuse_digi/dimuse_track.cpp index 86570f478d..383c0281df 100644 --- a/engines/scumm/imuse_digi/dimuse_track.cpp +++ b/engines/scumm/imuse_digi/dimuse_track.cpp @@ -80,12 +80,17 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType, } Track *track = _track[l]; - while (track->used) { + while (1) { + _mutex.lock(); + if (!track->used) { + break; + } // The designated track is not yet available. So, we call flushTracks() // to get it processed (and thus made ready for us). Since the actual // processing is done by another thread, we also call parseEvents to // give it some time (and to avoid busy waiting/looping). flushTracks(); + _mutex.unlock(); #ifndef __PLAYSTATION2__ _vm->parseEvents(); #endif @@ -186,6 +191,7 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType, } track->used = true; + _mutex.unlock(); } void IMuseDigital::setPriority(int soundId, int priority) { @@ -309,7 +315,6 @@ void IMuseDigital::fadeOutMusic(int fadeDelay) { } IMuseDigital::Track *IMuseDigital::cloneToFadeOutTrack(const Track *track, int fadeDelay) { - Common::StackLock lock(_mutex, "IMuseDigital::cloneToFadeOutTrack()"); assert(track); Track *fadeTrack = 0; -- cgit v1.2.3