diff options
author | Chris Robinson <[email protected]> | 2020-09-05 21:37:35 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-09-05 21:39:31 -0700 |
commit | 800e2b61259ae96ae97e22d86a0fa4e2e8a07be6 (patch) | |
tree | 307ca70d43d6593186c08f6400058d03c7f52d65 /al/auxeffectslot.cpp | |
parent | 13710b474e24cf57030d78818777b5301ba65782 (diff) |
Cleanup and fix alAuxiliaryEffectSlotPlayv/StopvSOFT
Diffstat (limited to 'al/auxeffectslot.cpp')
-rw-r--r-- | al/auxeffectslot.cpp | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp index e5ca89ce..71d43adc 100644 --- a/al/auxeffectslot.cpp +++ b/al/auxeffectslot.cpp @@ -404,30 +404,24 @@ START_API_FUNC context->setError(AL_INVALID_VALUE, "Playing %d effect slots", n); if UNLIKELY(n <= 0) return; - al::vector<ALeffectslot*> slots; - slots.reserve(static_cast<ALuint>(n)); + auto slots = al::vector<ALeffectslot*>(static_cast<ALuint>(n)); std::lock_guard<std::mutex> _{context->mEffectSlotLock}; - auto validate_slot = [&context,&slots](const ALuint id) -> bool + for(size_t i{0};i < slots.size();++i) { - ALeffectslot *slot{LookupEffectSlot(context.get(), id)}; + ALeffectslot *slot{LookupEffectSlot(context.get(), slotids[i])}; if UNLIKELY(!slot) { - context->setError(AL_INVALID_NAME, "Invalid effect slot ID %u", id); - return false; + context->setError(AL_INVALID_NAME, "Invalid effect slot ID %u", slotids[i]); + return; } if(slot->mState != SlotState::Playing) { slot->PropsClean.test_and_set(std::memory_order_acq_rel); slot->updateProps(context.get()); - - slots.emplace_back(slot); } - return true; + slots[i] = slot; }; - auto slotids_end = slotids + n; - auto bad_slot = std::find_if_not(slotids, slotids_end, validate_slot); - if UNLIKELY(bad_slot != slotids_end) return; AddActiveEffectSlots(slotids, static_cast<ALuint>(n), context.get()); for(auto slot : slots) @@ -464,22 +458,23 @@ START_API_FUNC context->setError(AL_INVALID_VALUE, "Stopping %d effect slots", n); if UNLIKELY(n <= 0) return; + auto slots = al::vector<ALeffectslot*>(static_cast<ALuint>(n)); std::lock_guard<std::mutex> _{context->mEffectSlotLock}; - auto validate_slot = [&context](const ALuint id) -> bool + for(size_t i{0};i < slots.size();++i) { - ALeffectslot *slot{LookupEffectSlot(context.get(), id)}; + ALeffectslot *slot{LookupEffectSlot(context.get(), slotids[i])}; if UNLIKELY(!slot) { - context->setError(AL_INVALID_NAME, "Invalid effect slot ID %u", id); - return false; + context->setError(AL_INVALID_NAME, "Invalid effect slot ID %u", slotids[i]); + return; } - return true; + + slots[i] = slot; }; - auto slotids_end = slotids + n; - auto bad_slot = std::find_if_not(slotids, slotids_end, validate_slot); - if UNLIKELY(bad_slot != slotids_end) return; RemoveActiveEffectSlots(slotids, static_cast<ALuint>(n), context.get()); + for(auto slot : slots) + slot->mState = SlotState::Stopped; } END_API_FUNC |