diff options
author | Chris Robinson <[email protected]> | 2022-03-30 04:49:29 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2022-03-30 05:01:06 -0700 |
commit | 6718a49486b307ad938b707549ac1dfb78504300 (patch) | |
tree | f72ac05b3ff23f4e2f4a5fadd8eb44d4967cb8de /al | |
parent | 9537c771054f6aa9445b1f3ddeb8abb348a2eb83 (diff) |
Replace a few asserts with actual checks or ASSUME()
Diffstat (limited to 'al')
-rw-r--r-- | al/auxeffectslot.cpp | 2 | ||||
-rw-r--r-- | al/source.cpp | 12 |
2 files changed, 7 insertions, 7 deletions
diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp index c1577679..c33fb149 100644 --- a/al/auxeffectslot.cpp +++ b/al/auxeffectslot.cpp @@ -915,7 +915,7 @@ END_API_FUNC ALeffectslot::ALeffectslot() { EffectStateFactory *factory{getFactoryByType(EffectSlotType::None)}; - assert(factory != nullptr); + if(!factory) throw std::runtime_error{"Failed to get null effect factory"}; al::intrusive_ptr<EffectState> state{factory->create()}; Effect.State = state; diff --git a/al/source.cpp b/al/source.cpp index ea3a4de7..dee4af2a 100644 --- a/al/source.cpp +++ b/al/source.cpp @@ -266,7 +266,7 @@ double GetSourceSecOffset(ALsource *Source, ALCcontext *context, nanoseconds *cl BufferFmt = BufferList->mBuffer; ++BufferList; } - assert(BufferFmt != nullptr); + ASSUME(BufferFmt != nullptr); return static_cast<double>(readPos) / double{MixerFracOne} / BufferFmt->mSampleRate; } @@ -315,7 +315,7 @@ double GetSourceOffset(ALsource *Source, ALenum name, ALCcontext *context) BufferFmt = BufferList->mBuffer; ++BufferList; } - assert(BufferFmt != nullptr); + ASSUME(BufferFmt != nullptr); double offset{}; switch(name) @@ -375,7 +375,7 @@ double GetSourceLength(const ALsource *source, ALenum name) if(length == 0) return 0.0; - assert(BufferFmt != nullptr); + ASSUME(BufferFmt != nullptr); switch(name) { case AL_SEC_LENGTH_SOFT: @@ -585,7 +585,7 @@ bool SetVoiceOffset(Voice *oldvoice, const VoicePos &vpos, ALsource *source, ALC } ++vidx; } - if UNLIKELY(!newvoice) + if(unlikely(!newvoice)) { auto &allvoices = *context->mVoices.load(std::memory_order_relaxed); if(allvoices.size() == voicelist.size()) @@ -605,7 +605,7 @@ bool SetVoiceOffset(Voice *oldvoice, const VoicePos &vpos, ALsource *source, ALC } ++vidx; } - assert(newvoice != nullptr); + ASSUME(newvoice != nullptr); } /* Initialize the new voice and set its starting offset. @@ -3169,7 +3169,7 @@ START_API_FUNC break; } } - assert(voice != nullptr); + ASSUME(voice != nullptr); voice->mPosition.store(0u, std::memory_order_relaxed); voice->mPositionFrac.store(0, std::memory_order_relaxed); |