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
This commit is contained in:
James Brown 2003-07-04 14:49:51 +00:00
parent 093a31839b
commit a4b61ddaba

View file

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