Avoid ugly reinterpret_casts with offsetof
This commit is contained in:
+12
-6
@@ -991,13 +991,19 @@ void ALeffectslot::updateProps(ALCcontext *context)
|
|||||||
void UpdateAllEffectSlotProps(ALCcontext *context)
|
void UpdateAllEffectSlotProps(ALCcontext *context)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> _{context->mEffectSlotLock};
|
std::lock_guard<std::mutex> _{context->mEffectSlotLock};
|
||||||
EffectSlotArray *slots{context->mActiveAuxSlots.load(std::memory_order_acquire)};
|
for(auto &sublist : context->mEffectSlotList)
|
||||||
for(EffectSlot *slot : *slots)
|
|
||||||
{
|
{
|
||||||
ALeffectslot *auxslot{reinterpret_cast<ALeffectslot*>(
|
uint64_t usemask{~sublist.FreeMask};
|
||||||
reinterpret_cast<al::byte*>(slot) - offsetof(ALeffectslot,mSlot))};
|
while(usemask)
|
||||||
if(!auxslot->PropsClean.test_and_set(std::memory_order_acq_rel))
|
{
|
||||||
auxslot->updateProps(context);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user