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:
parent
093a31839b
commit
a4b61ddaba
1 changed files with 5 additions and 1 deletions
|
@ -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) {
|
int SoundMixer::playRaw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags, int id) {
|
||||||
// Prevent duplicate sounds
|
// Prevent duplicate sounds
|
||||||
|
_syst->lock_mutex(_mutex);
|
||||||
for (int i = 0; i != NUM_CHANNELS; i++)
|
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;
|
return -1;
|
||||||
|
}
|
||||||
|
_syst->unlock_mutex(_mutex);
|
||||||
|
|
||||||
return insertChannel(handle, new ChannelRaw(this, sound, size, rate, flags, id));
|
return insertChannel(handle, new ChannelRaw(this, sound, size, rate, flags, id));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue