From a913aa6ba86db006a42f12781c0bbf9faa6d9b4e Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 24 Nov 2020 10:49:53 -0800 Subject: Make sure batched source updates are with the proper voice --- al/source.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'al/source.cpp') diff --git a/al/source.cpp b/al/source.cpp index b8b8c965..1af39da2 100644 --- a/al/source.cpp +++ b/al/source.cpp @@ -3435,15 +3435,18 @@ void UpdateAllSourceProps(ALCcontext *context) { std::lock_guard _{context->mSourceLock}; auto voicelist = context->getVoicesSpan(); - std::for_each(voicelist.begin(), voicelist.end(), - [context](Voice *voice) -> void + ALuint vidx{0u}; + for(Voice *voice : voicelist) + { + ALuint sid{voice->mSourceID.load(std::memory_order_acquire)}; + ALsource *source = sid ? LookupSource(context, sid) : nullptr; + if(source && source->VoiceIdx == vidx) { - ALuint sid{voice->mSourceID.load(std::memory_order_acquire)}; - ALsource *source = sid ? LookupSource(context, sid) : nullptr; - if(source && !source->PropsClean.test_and_set(std::memory_order_acq_rel)) + if(!source->PropsClean.test_and_set(std::memory_order_acq_rel)) UpdateSourceProps(source, voice, context); } - ); + ++vidx; + } } SourceSubList::~SourceSubList() -- cgit v1.2.3