aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorJames Brown2003-07-04 14:49:51 +0000
committerJames Brown2003-07-04 14:49:51 +0000
commita4b61ddaba3baab93a3bbf8307c44755cfe0885c (patch)
treeb234ef6f18a9d6f1ea4d46db259e1f2ea5b3b6fe /sound
parent093a31839beca7897032c245ca009da8de7a43d4 (diff)
downloadscummvm-rg350-a4b61ddaba3baab93a3bbf8307c44755cfe0885c.tar.gz
scummvm-rg350-a4b61ddaba3baab93a3bbf8307c44755cfe0885c.tar.bz2
scummvm-rg350-a4b61ddaba3baab93a3bbf8307c44755cfe0885c.zip
Prevent apparantly possible race condition. I don't get this stuff, and I don't see why the next call to insertChannel is immune to the same theoretical problem :)
svn-id: r8742
Diffstat (limited to 'sound')
-rw-r--r--sound/mixer.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/sound/mixer.cpp b/sound/mixer.cpp
index 6dbead7e49..dd7a6ede62 100644
--- a/sound/mixer.cpp
+++ b/sound/mixer.cpp
@@ -230,9 +230,13 @@ int SoundMixer::insertChannel(PlayingSoundHandle *handle, Channel *chan) {
int SoundMixer::playRaw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags, int id) {
// Prevent duplicate sounds
+ _syst->lock_mutex(_mutex);
for (int i = 0; i != NUM_CHANNELS; i++)
- if (_channels[i] != NULL && _channels[i]->_id == id)
+ if (_channels[i] != NULL && _channels[i]->_id == id) {
+ _syst->unlock_mutex(_mutex);
return -1;
+ }
+ _syst->unlock_mutex(_mutex);
return insertChannel(handle, new ChannelRaw(this, sound, size, rate, flags, id));
}