From 5dfa24d5e271860cd58788790f9aefd742ab26b7 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 29 Mar 2020 03:10:35 -0700 Subject: Stop updating effects when one fails --- alc/alc.cpp | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) (limited to 'alc/alc.cpp') diff --git a/alc/alc.cpp b/alc/alc.cpp index 880d2781..efc822ff 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -2206,23 +2206,20 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) TRACE("Fixed device latency: %" PRId64 "ns\n", int64_t{device->FixedLatency.count()}); - /* Need to delay returning failure until replacement Send arrays have been - * allocated with the appropriate size. - */ + /* Need to delay returning failure until the Send arrays have been cleared. */ bool update_failed{false}; FPUCtl mixer_mode{}; for(ALCcontext *context : *device->mContexts.load()) { - if(context->mDefaultSlot) + if(context->mDefaultSlot && !update_failed) { ALeffectslot *slot{context->mDefaultSlot.get()}; aluInitEffectPanning(slot, device); EffectState *state{slot->Effect.State}; state->mOutTarget = device->Dry.Buffer; - if(!state->deviceUpdate(device)) - update_failed = true; - else + update_failed = !state->deviceUpdate(device); + if(!update_failed) UpdateEffectSlotProps(slot, context); } @@ -2232,22 +2229,21 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) std::fill_n(curarray->end(), curarray->size(), nullptr); for(auto &sublist : context->mEffectSlotList) { - uint64_t usemask = ~sublist.FreeMask; + if(update_failed) break; + uint64_t usemask{~sublist.FreeMask}; while(usemask) { - ALsizei idx = CTZ64(usemask); - ALeffectslot *slot = sublist.EffectSlots + idx; - + ALsizei idx{CTZ64(usemask)}; + ALeffectslot *slot{sublist.EffectSlots + idx}; usemask &= ~(1_u64 << idx); aluInitEffectPanning(slot, device); EffectState *state{slot->Effect.State}; state->mOutTarget = device->Dry.Buffer; - if(state->deviceUpdate(device) == AL_FALSE) - update_failed = true; - else - UpdateEffectSlotProps(slot, context); + update_failed = !state->deviceUpdate(device); + if(update_failed) break; + UpdateEffectSlotProps(slot, context); } } slotlock.unlock(); @@ -2255,12 +2251,11 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) std::unique_lock srclock{context->mSourceLock}; for(auto &sublist : context->mSourceList) { - uint64_t usemask = ~sublist.FreeMask; + uint64_t usemask{~sublist.FreeMask}; while(usemask) { - ALsizei idx = CTZ64(usemask); - ALsource *source = sublist.Sources + idx; - + ALsizei idx{CTZ64(usemask)}; + ALsource *source{sublist.Sources + idx}; usemask &= ~(1_u64 << idx); auto clear_send = [](ALsource::SendData &send) -> void -- cgit v1.2.3