diff options
author | Chris Robinson <[email protected]> | 2022-07-29 02:59:10 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2022-07-29 02:59:10 -0700 |
commit | 81b739abc17040b7db36841a69d4afbe3a396909 (patch) | |
tree | bf08edc615c45ece249e03ebf94ed7c52679a381 /al/auxeffectslot.cpp | |
parent | 339465c91f1317f3c6f441c98658d933984a5291 (diff) |
AllocEffectSlot can't fail
Diffstat (limited to 'al/auxeffectslot.cpp')
-rw-r--r-- | al/auxeffectslot.cpp | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp index 5f58d730..172a3566 100644 --- a/al/auxeffectslot.cpp +++ b/al/auxeffectslot.cpp @@ -281,7 +281,7 @@ ALeffectslot *AllocEffectSlot(ALCcontext *context) ALeffectslot *slot{al::construct_at(sublist->EffectSlots + slidx, context)}; aluInitEffectPanning(slot->mSlot, context); - /* Add 1 to avoid source ID 0. */ + /* Add 1 to avoid ID 0. */ slot->id = ((lidx<<6) | slidx) + 1; context->mNumEffectSlots += 1; @@ -326,7 +326,7 @@ START_API_FUNC context->setError(AL_INVALID_VALUE, "Generating %d effect slots", n); if UNLIKELY(n <= 0) return; - std::unique_lock<std::mutex> slotlock{context->mEffectSlotLock}; + std::lock_guard<std::mutex> _{context->mEffectSlotLock}; ALCdevice *device{context->mALDevice.get()}; if(static_cast<ALuint>(n) > device->AuxiliaryEffectSlotMax-context->mNumEffectSlots) { @@ -344,7 +344,6 @@ START_API_FUNC if(n == 1) { ALeffectslot *slot{AllocEffectSlot(context.get())}; - if(!slot) return; effectslots[0] = slot->id; } else @@ -354,12 +353,6 @@ START_API_FUNC ids.reserve(static_cast<ALuint>(count)); do { ALeffectslot *slot{AllocEffectSlot(context.get())}; - if(!slot) - { - slotlock.unlock(); - alDeleteAuxiliaryEffectSlots(static_cast<ALsizei>(ids.size()), ids.data()); - return; - } ids.emplace_back(slot->id); } while(--count); std::copy(ids.cbegin(), ids.cend(), effectslots); @@ -1606,14 +1599,7 @@ EaxAlEffectSlotUPtr eax_create_al_effect_slot(ALCcontext& context) return nullptr; } - auto effect_slot = EaxAlEffectSlotUPtr{AllocEffectSlot(&context)}; - - if(effect_slot == nullptr) { - ERR(EAX_PREFIX "%s\n", "Failed to allocate."); - return nullptr; - } - - return effect_slot; + return EaxAlEffectSlotUPtr{AllocEffectSlot(&context)}; #undef EAX_PREFIX } |