diff options
-rw-r--r-- | al/source.cpp | 1 | ||||
-rw-r--r-- | alc/alc.cpp | 41 |
2 files changed, 21 insertions, 21 deletions
diff --git a/al/source.cpp b/al/source.cpp index d9a7cb87..08e4bff6 100644 --- a/al/source.cpp +++ b/al/source.cpp @@ -3318,6 +3318,7 @@ ALsource::~ALsource() void UpdateAllSourceProps(ALCcontext *context) { + std::lock_guard<std::mutex> _{context->mSourceLock}; auto voices_end = context->mVoices->begin() + context->mVoiceCount.load(std::memory_order_relaxed); std::for_each(context->mVoices->begin(), voices_end, 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); |