diff options
author | Chris Robinson <[email protected]> | 2020-12-29 09:57:08 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-12-29 09:57:08 -0800 |
commit | ec7e7c917403aba97aaa4ac990a863a0aca99b3e (patch) | |
tree | fcbd32b622ae1133292e3d27c0348e641c3bf600 /al | |
parent | 96942d7968db88f8462e9fd49e6db3e36804c1bd (diff) |
Avoid ugly reinterpret_casts with offsetof
Diffstat (limited to 'al')
-rw-r--r-- | al/auxeffectslot.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp index 524546b5..61a31774 100644 --- a/al/auxeffectslot.cpp +++ b/al/auxeffectslot.cpp @@ -991,13 +991,19 @@ void ALeffectslot::updateProps(ALCcontext *context) void UpdateAllEffectSlotProps(ALCcontext *context) { std::lock_guard<std::mutex> _{context->mEffectSlotLock}; - EffectSlotArray *slots{context->mActiveAuxSlots.load(std::memory_order_acquire)}; - for(EffectSlot *slot : *slots) + for(auto &sublist : context->mEffectSlotList) { - ALeffectslot *auxslot{reinterpret_cast<ALeffectslot*>( - reinterpret_cast<al::byte*>(slot) - offsetof(ALeffectslot,mSlot))}; - if(!auxslot->PropsClean.test_and_set(std::memory_order_acq_rel)) - auxslot->updateProps(context); + uint64_t usemask{~sublist.FreeMask}; + while(usemask) + { + const int idx{CountTrailingZeros(usemask)}; + ALeffectslot *slot{sublist.EffectSlots + idx}; + usemask &= ~(1_u64 << idx); + + if(slot->mState != SlotState::Stopped + && slot->PropsClean.test_and_set(std::memory_order_acq_rel)) + slot->updateProps(context); + } } } |