diff options
author | Chris Robinson <[email protected]> | 2019-09-01 00:24:49 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-09-01 00:29:26 -0700 |
commit | aee10ef60623e012e5edc6fcf31b2d71b2086bc9 (patch) | |
tree | e6e919d20cb05b51a86b4dc64fa7dd2b8a7a7969 /alc/alc.cpp | |
parent | a15f25b07ad442890bb9a75a7ef7f43cf5ab2ef4 (diff) |
Hold the source lock in UpdateAllSourceProps
Diffstat (limited to 'alc/alc.cpp')
-rw-r--r-- | alc/alc.cpp | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp index a69a8e7c..8ee762d5 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -2203,30 +2203,29 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) }; std::for_each(voices->begin(), voices_end, clear_sends); } - std::for_each(voices->begin(), voices_end, - [device](ALvoice &voice) -> void - { - delete voice.mUpdate.exchange(nullptr, std::memory_order_acq_rel); + auto reset_voice = [device](ALvoice &voice) -> void + { + delete voice.mUpdate.exchange(nullptr, std::memory_order_acq_rel); - /* Force the voice to stopped if it was stopping. */ - ALvoice::State vstate{ALvoice::Stopping}; - voice.mPlayState.compare_exchange_strong(vstate, ALvoice::Stopped, - std::memory_order_acquire, std::memory_order_acquire); - if(voice.mSourceID.load(std::memory_order_relaxed) == 0u) - return; + /* Force the voice to stopped if it was stopping. */ + ALvoice::State vstate{ALvoice::Stopping}; + voice.mPlayState.compare_exchange_strong(vstate, ALvoice::Stopped, + std::memory_order_acquire, std::memory_order_acquire); + if(voice.mSourceID.load(std::memory_order_relaxed) == 0u) + return; - if(device->AvgSpeakerDist > 0.0f) - { - /* Reinitialize the NFC filters for new parameters. */ - const ALfloat w1{SPEEDOFSOUNDMETRESPERSEC / - (device->AvgSpeakerDist * device->Frequency)}; - auto init_nfc = [w1](ALvoice::ChannelData &chandata) -> void - { chandata.mDryParams.NFCtrlFilter.init(w1); }; - std::for_each(voice.mChans.begin(), voice.mChans.begin()+voice.mNumChannels, - init_nfc); - } + if(device->AvgSpeakerDist > 0.0f) + { + /* Reinitialize the NFC filters for new parameters. */ + const ALfloat w1{SPEEDOFSOUNDMETRESPERSEC / + (device->AvgSpeakerDist * device->Frequency)}; + auto init_nfc = [w1](ALvoice::ChannelData &chandata) -> void + { chandata.mDryParams.NFCtrlFilter.init(w1); }; + std::for_each(voice.mChans.begin(), voice.mChans.begin()+voice.mNumChannels, + init_nfc); } - ); + }; + std::for_each(voices->begin(), voices_end, reset_voice); srclock.unlock(); context->mPropsClean.test_and_set(std::memory_order_release); |