diff options
Diffstat (limited to 'al')
-rw-r--r-- | al/auxeffectslot.cpp | 112 | ||||
-rw-r--r-- | al/buffer.cpp | 248 | ||||
-rw-r--r-- | al/effect.cpp | 58 | ||||
-rw-r--r-- | al/error.cpp | 2 | ||||
-rw-r--r-- | al/event.cpp | 6 | ||||
-rw-r--r-- | al/extension.cpp | 4 | ||||
-rw-r--r-- | al/filter.cpp | 58 | ||||
-rw-r--r-- | al/listener.cpp | 28 | ||||
-rw-r--r-- | al/source.cpp | 272 | ||||
-rw-r--r-- | al/state.cpp | 46 |
10 files changed, 417 insertions, 417 deletions
diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp index d777bc1f..81929702 100644 --- a/al/auxeffectslot.cpp +++ b/al/auxeffectslot.cpp @@ -90,10 +90,10 @@ inline ALeffectslot *LookupEffectSlot(ALCcontext *context, ALuint id) noexcept const size_t lidx{(id-1) >> 6}; const ALuint slidx{(id-1) & 0x3f}; - if(lidx >= context->mEffectSlotList.size()) [[unlikely]] + if(lidx >= context->mEffectSlotList.size()) UNLIKELY return nullptr; EffectSlotSubList &sublist{context->mEffectSlotList[lidx]}; - if(sublist.FreeMask & (1_u64 << slidx)) [[unlikely]] + if(sublist.FreeMask & (1_u64 << slidx)) UNLIKELY return nullptr; return sublist.EffectSlots + slidx; } @@ -103,10 +103,10 @@ inline ALeffect *LookupEffect(ALCdevice *device, ALuint id) noexcept const size_t lidx{(id-1) >> 6}; const ALuint slidx{(id-1) & 0x3f}; - if(lidx >= device->EffectList.size()) [[unlikely]] + if(lidx >= device->EffectList.size()) UNLIKELY return nullptr; EffectSubList &sublist = device->EffectList[lidx]; - if(sublist.FreeMask & (1_u64 << slidx)) [[unlikely]] + if(sublist.FreeMask & (1_u64 << slidx)) UNLIKELY return nullptr; return sublist.Effects + slidx; } @@ -116,10 +116,10 @@ inline ALbuffer *LookupBuffer(ALCdevice *device, ALuint id) noexcept const size_t lidx{(id-1) >> 6}; const ALuint slidx{(id-1) & 0x3f}; - if(lidx >= device->BufferList.size()) [[unlikely]] + if(lidx >= device->BufferList.size()) UNLIKELY return nullptr; BufferSubList &sublist = device->BufferList[lidx]; - if(sublist.FreeMask & (1_u64 << slidx)) [[unlikely]] + if(sublist.FreeMask & (1_u64 << slidx)) UNLIKELY return nullptr; return sublist.Buffers + slidx; } @@ -159,7 +159,7 @@ void AddActiveEffectSlots(const al::span<ALeffectslot*> auxslots, ALCcontext *co /* Reallocate newarray if the new size ended up smaller from duplicate * removal. */ - if(newcount < newarray->size()) [[unlikely]] + if(newcount < newarray->size()) UNLIKELY { curarray = newarray; newarray = EffectSlot::CreatePtrArray(newcount); @@ -197,7 +197,7 @@ void RemoveActiveEffectSlots(const al::span<ALeffectslot*> auxslots, ALCcontext /* Reallocate with the new size. */ auto newsize = static_cast<size_t>(std::distance(newarray->begin(), new_end)); - if(newsize != newarray->size()) [[likely]] + if(newsize != newarray->size()) LIKELY { curarray = newarray; newarray = EffectSlot::CreatePtrArray(newsize); @@ -251,7 +251,7 @@ bool EnsureEffectSlots(ALCcontext *context, size_t needed) while(needed > count) { - if(context->mEffectSlotList.size() >= 1<<25) [[unlikely]] + if(context->mEffectSlotList.size() >= 1<<25) UNLIKELY return false; context->mEffectSlotList.emplace_back(); @@ -259,7 +259,7 @@ bool EnsureEffectSlots(ALCcontext *context, size_t needed) sublist->FreeMask = ~0_u64; sublist->EffectSlots = static_cast<ALeffectslot*>( al_calloc(alignof(ALeffectslot), sizeof(ALeffectslot)*64)); - if(!sublist->EffectSlots) [[unlikely]] + if(!sublist->EffectSlots) UNLIKELY { context->mEffectSlotList.pop_back(); return false; @@ -320,11 +320,11 @@ AL_API void AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; - if(n < 0) [[unlikely]] + if(n < 0) UNLIKELY context->setError(AL_INVALID_VALUE, "Generating %d effect slots", n); - if(n <= 0) [[unlikely]] return; + if(n <= 0) UNLIKELY return; std::lock_guard<std::mutex> _{context->mEffectSlotLock}; ALCdevice *device{context->mALDevice.get()}; @@ -364,22 +364,22 @@ AL_API void AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, const ALuint *ef START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; - if(n < 0) [[unlikely]] + if(n < 0) UNLIKELY context->setError(AL_INVALID_VALUE, "Deleting %d effect slots", n); - if(n <= 0) [[unlikely]] return; + if(n <= 0) UNLIKELY return; std::lock_guard<std::mutex> _{context->mEffectSlotLock}; if(n == 1) { ALeffectslot *slot{LookupEffectSlot(context.get(), effectslots[0])}; - if(!slot) [[unlikely]] + if(!slot) UNLIKELY { context->setError(AL_INVALID_NAME, "Invalid effect slot ID %u", effectslots[0]); return; } - if(ReadRef(slot->ref) != 0) [[unlikely]] + if(ReadRef(slot->ref) != 0) UNLIKELY { context->setError(AL_INVALID_OPERATION, "Deleting in-use effect slot %u", effectslots[0]); @@ -394,12 +394,12 @@ START_API_FUNC for(size_t i{0};i < slots.size();++i) { ALeffectslot *slot{LookupEffectSlot(context.get(), effectslots[i])}; - if(!slot) [[unlikely]] + if(!slot) UNLIKELY { context->setError(AL_INVALID_NAME, "Invalid effect slot ID %u", effectslots[i]); return; } - if(ReadRef(slot->ref) != 0) [[unlikely]] + if(ReadRef(slot->ref) != 0) UNLIKELY { context->setError(AL_INVALID_OPERATION, "Deleting in-use effect slot %u", effectslots[i]); @@ -428,7 +428,7 @@ AL_API ALboolean AL_APIENTRY alIsAuxiliaryEffectSlot(ALuint effectslot) START_API_FUNC { ContextRef context{GetContextRef()}; - if(context) [[likely]] + if(context) LIKELY { std::lock_guard<std::mutex> _{context->mEffectSlotLock}; if(LookupEffectSlot(context.get(), effectslot) != nullptr) @@ -443,11 +443,11 @@ AL_API void AL_APIENTRY alAuxiliaryEffectSlotPlaySOFT(ALuint slotid) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mEffectSlotLock}; ALeffectslot *slot{LookupEffectSlot(context.get(), slotid)}; - if(!slot) [[unlikely]] + if(!slot) UNLIKELY { context->setError(AL_INVALID_NAME, "Invalid effect slot ID %u", slotid); return; @@ -467,18 +467,18 @@ AL_API void AL_APIENTRY alAuxiliaryEffectSlotPlayvSOFT(ALsizei n, const ALuint * START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; - if(n < 0) [[unlikely]] + if(n < 0) UNLIKELY context->setError(AL_INVALID_VALUE, "Playing %d effect slots", n); - if(n <= 0) [[unlikely]] return; + if(n <= 0) UNLIKELY return; auto slots = al::vector<ALeffectslot*>(static_cast<ALuint>(n)); std::lock_guard<std::mutex> _{context->mEffectSlotLock}; for(size_t i{0};i < slots.size();++i) { ALeffectslot *slot{LookupEffectSlot(context.get(), slotids[i])}; - if(!slot) [[unlikely]] + if(!slot) UNLIKELY { context->setError(AL_INVALID_NAME, "Invalid effect slot ID %u", slotids[i]); return; @@ -502,11 +502,11 @@ AL_API void AL_APIENTRY alAuxiliaryEffectSlotStopSOFT(ALuint slotid) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mEffectSlotLock}; ALeffectslot *slot{LookupEffectSlot(context.get(), slotid)}; - if(!slot) [[unlikely]] + if(!slot) UNLIKELY { context->setError(AL_INVALID_NAME, "Invalid effect slot ID %u", slotid); return; @@ -521,18 +521,18 @@ AL_API void AL_APIENTRY alAuxiliaryEffectSlotStopvSOFT(ALsizei n, const ALuint * START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; - if(n < 0) [[unlikely]] + if(n < 0) UNLIKELY context->setError(AL_INVALID_VALUE, "Stopping %d effect slots", n); - if(n <= 0) [[unlikely]] return; + if(n <= 0) UNLIKELY return; auto slots = al::vector<ALeffectslot*>(static_cast<ALuint>(n)); std::lock_guard<std::mutex> _{context->mEffectSlotLock}; for(size_t i{0};i < slots.size();++i) { ALeffectslot *slot{LookupEffectSlot(context.get(), slotids[i])}; - if(!slot) [[unlikely]] + if(!slot) UNLIKELY { context->setError(AL_INVALID_NAME, "Invalid effect slot ID %u", slotids[i]); return; @@ -552,12 +552,12 @@ AL_API void AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param, START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mPropLock}; std::lock_guard<std::mutex> __{context->mEffectSlotLock}; ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot); - if(!slot) [[unlikely]] + if(!slot) UNLIKELY return context->setError(AL_INVALID_NAME, "Invalid effect slot ID %u", effectslot); ALeffectslot *target{}; @@ -580,12 +580,12 @@ START_API_FUNC err = slot->initEffect(AL_EFFECT_NULL, EffectProps{}, context.get()); } } - if(err != AL_NO_ERROR) [[unlikely]] + if(err != AL_NO_ERROR) UNLIKELY { context->setError(err, "Effect initialization failed"); return; } - if(slot->mState == SlotState::Initial) [[unlikely]] + if(slot->mState == SlotState::Initial) UNLIKELY { slot->mPropsDirty = false; slot->updateProps(context.get()); @@ -600,7 +600,7 @@ START_API_FUNC if(!(value == AL_TRUE || value == AL_FALSE)) return context->setError(AL_INVALID_VALUE, "Effect slot auxiliary send auto out of range"); - if(slot->AuxSendAuto == !!value) [[unlikely]] + if(slot->AuxSendAuto == !!value) UNLIKELY return; slot->AuxSendAuto = !!value; break; @@ -609,7 +609,7 @@ START_API_FUNC target = LookupEffectSlot(context.get(), static_cast<ALuint>(value)); if(value && !target) return context->setError(AL_INVALID_VALUE, "Invalid effect slot target ID"); - if(slot->Target == target) [[unlikely]] + if(slot->Target == target) UNLIKELY return; if(target) { @@ -647,10 +647,10 @@ START_API_FUNC if(ALbuffer *buffer{slot->Buffer}) { - if(buffer->id == static_cast<ALuint>(value)) [[unlikely]] + if(buffer->id == static_cast<ALuint>(value)) UNLIKELY return; } - else if(value == 0) [[unlikely]] + else if(value == 0) UNLIKELY return; { @@ -703,11 +703,11 @@ START_API_FUNC } ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mEffectSlotLock}; ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot); - if(!slot) [[unlikely]] + if(!slot) UNLIKELY return context->setError(AL_INVALID_NAME, "Invalid effect slot ID %u", effectslot); switch(param) @@ -723,12 +723,12 @@ AL_API void AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mPropLock}; std::lock_guard<std::mutex> __{context->mEffectSlotLock}; ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot); - if(!slot) [[unlikely]] + if(!slot) UNLIKELY return context->setError(AL_INVALID_NAME, "Invalid effect slot ID %u", effectslot); switch(param) @@ -736,7 +736,7 @@ START_API_FUNC case AL_EFFECTSLOT_GAIN: if(!(value >= 0.0f && value <= 1.0f)) return context->setError(AL_INVALID_VALUE, "Effect slot gain out of range"); - if(slot->Gain == value) [[unlikely]] + if(slot->Gain == value) UNLIKELY return; slot->Gain = value; break; @@ -760,11 +760,11 @@ START_API_FUNC } ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mEffectSlotLock}; ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot); - if(!slot) [[unlikely]] + if(!slot) UNLIKELY return context->setError(AL_INVALID_NAME, "Invalid effect slot ID %u", effectslot); switch(param) @@ -781,11 +781,11 @@ AL_API void AL_APIENTRY alGetAuxiliaryEffectSloti(ALuint effectslot, ALenum para START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mEffectSlotLock}; ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot); - if(!slot) [[unlikely]] + if(!slot) UNLIKELY return context->setError(AL_INVALID_NAME, "Invalid effect slot ID %u", effectslot); switch(param) @@ -833,11 +833,11 @@ START_API_FUNC } ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mEffectSlotLock}; ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot); - if(!slot) [[unlikely]] + if(!slot) UNLIKELY return context->setError(AL_INVALID_NAME, "Invalid effect slot ID %u", effectslot); switch(param) @@ -853,11 +853,11 @@ AL_API void AL_APIENTRY alGetAuxiliaryEffectSlotf(ALuint effectslot, ALenum para START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mEffectSlotLock}; ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot); - if(!slot) [[unlikely]] + if(!slot) UNLIKELY return context->setError(AL_INVALID_NAME, "Invalid effect slot ID %u", effectslot); switch(param) @@ -883,11 +883,11 @@ START_API_FUNC } ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mEffectSlotLock}; ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot); - if(!slot) [[unlikely]] + if(!slot) UNLIKELY return context->setError(AL_INVALID_NAME, "Invalid effect slot ID %u", effectslot); switch(param) diff --git a/al/buffer.cpp b/al/buffer.cpp index 25f0b9e0..05657a2a 100644 --- a/al/buffer.cpp +++ b/al/buffer.cpp @@ -225,14 +225,14 @@ bool EnsureBuffers(ALCdevice *device, size_t needed) while(needed > count) { - if(device->BufferList.size() >= 1<<25) [[unlikely]] + if(device->BufferList.size() >= 1<<25) UNLIKELY return false; device->BufferList.emplace_back(); auto sublist = device->BufferList.end() - 1; sublist->FreeMask = ~0_u64; sublist->Buffers = static_cast<ALbuffer*>(al_calloc(alignof(ALbuffer), sizeof(ALbuffer)*64)); - if(!sublist->Buffers) [[unlikely]] + if(!sublist->Buffers) UNLIKELY { device->BufferList.pop_back(); return false; @@ -281,10 +281,10 @@ inline ALbuffer *LookupBuffer(ALCdevice *device, ALuint id) const size_t lidx{(id-1) >> 6}; const ALuint slidx{(id-1) & 0x3f}; - if(lidx >= device->BufferList.size()) [[unlikely]] + if(lidx >= device->BufferList.size()) UNLIKELY return nullptr; BufferSubList &sublist = device->BufferList[lidx]; - if(sublist.FreeMask & (1_u64 << slidx)) [[unlikely]] + if(sublist.FreeMask & (1_u64 << slidx)) UNLIKELY return nullptr; return sublist.Buffers + slidx; } @@ -345,22 +345,22 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, ALuint size, UserFmtChannels SrcChannels, UserFmtType SrcType, const al::byte *SrcData, ALbitfieldSOFT access) { - if(ReadRef(ALBuf->ref) != 0 || ALBuf->MappedAccess != 0) [[unlikely]] + if(ReadRef(ALBuf->ref) != 0 || ALBuf->MappedAccess != 0) UNLIKELY return context->setError(AL_INVALID_OPERATION, "Modifying storage for in-use buffer %u", ALBuf->id); /* Currently no channel configurations need to be converted. */ auto DstChannels = FmtFromUserFmt(SrcChannels); - if(!DstChannels) [[unlikely]] + if(!DstChannels) UNLIKELY return context->setError(AL_INVALID_ENUM, "Invalid format"); const auto DstType = FmtFromUserFmt(SrcType); - if(!DstType) [[unlikely]] + if(!DstType) UNLIKELY return context->setError(AL_INVALID_ENUM, "Invalid format"); const ALuint unpackalign{ALBuf->UnpackAlign}; const ALuint align{SanitizeAlignment(SrcType, unpackalign)}; - if(align < 1) [[unlikely]] + if(align < 1) UNLIKELY return context->setError(AL_INVALID_VALUE, "Invalid unpack alignment %u for %s samples", unpackalign, NameFromUserFmtType(SrcType)); @@ -370,11 +370,11 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, ALuint size, if((access&AL_PRESERVE_DATA_BIT_SOFT)) { /* Can only preserve data with the same format and alignment. */ - if(ALBuf->mChannels != *DstChannels || ALBuf->OriginalType != SrcType) [[unlikely]] + if(ALBuf->mChannels != *DstChannels || ALBuf->OriginalType != SrcType) UNLIKELY return context->setError(AL_INVALID_VALUE, "Preserving data of mismatched format"); - if(ALBuf->mBlockAlign != align) [[unlikely]] + if(ALBuf->mBlockAlign != align) UNLIKELY return context->setError(AL_INVALID_VALUE, "Preserving data of mismatched alignment"); - if(ALBuf->mAmbiOrder != ambiorder) [[unlikely]] + if(ALBuf->mAmbiOrder != ambiorder) UNLIKELY return context->setError(AL_INVALID_VALUE, "Preserving data of mismatched order"); } @@ -385,16 +385,16 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, ALuint size, ((SrcType == UserFmtIMA4) ? (align-1)/2 + 4 : (SrcType == UserFmtMSADPCM) ? (align-2)/2 + 7 : (align * BytesFromUserFmt(SrcType)))}; - if((size%SrcBlockSize) != 0) [[unlikely]] + if((size%SrcBlockSize) != 0) UNLIKELY return context->setError(AL_INVALID_VALUE, "Data size %d is not a multiple of frame size %d (%d unpack alignment)", size, SrcBlockSize, align); const ALuint blocks{size / SrcBlockSize}; - if(blocks > std::numeric_limits<ALsizei>::max()/align) [[unlikely]] + if(blocks > std::numeric_limits<ALsizei>::max()/align) UNLIKELY return context->setError(AL_OUT_OF_MEMORY, "Buffer size overflow, %d blocks x %d samples per block", blocks, align); - if(blocks > std::numeric_limits<size_t>::max()/SrcBlockSize) [[unlikely]] + if(blocks > std::numeric_limits<size_t>::max()/SrcBlockSize) UNLIKELY return context->setError(AL_OUT_OF_MEMORY, "Buffer size overflow, %d frames x %d bytes per frame", blocks, SrcBlockSize); @@ -470,18 +470,18 @@ void PrepareCallback(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, UserFmtChannels SrcChannels, UserFmtType SrcType, ALBUFFERCALLBACKTYPESOFT callback, void *userptr) { - if(ReadRef(ALBuf->ref) != 0 || ALBuf->MappedAccess != 0) [[unlikely]] + if(ReadRef(ALBuf->ref) != 0 || ALBuf->MappedAccess != 0) UNLIKELY return context->setError(AL_INVALID_OPERATION, "Modifying callback for in-use buffer %u", ALBuf->id); /* Currently no channel configurations need to be converted. */ const auto DstChannels = FmtFromUserFmt(SrcChannels); - if(!DstChannels) [[unlikely]] + if(!DstChannels) UNLIKELY return context->setError(AL_INVALID_ENUM, "Invalid format"); /* Formats that need conversion aren't supported with callbacks. */ const auto DstType = FmtFromUserFmt(SrcType); - if(!DstType) [[unlikely]] + if(!DstType) UNLIKELY return context->setError(AL_INVALID_ENUM, "Unsupported callback format"); const ALuint ambiorder{IsBFormat(*DstChannels) ? ALBuf->UnpackAmbiOrder : @@ -627,11 +627,11 @@ AL_API void AL_APIENTRY alGenBuffers(ALsizei n, ALuint *buffers) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; - if(n < 0) [[unlikely]] + if(n < 0) UNLIKELY context->setError(AL_INVALID_VALUE, "Generating %d buffers", n); - if(n <= 0) [[unlikely]] return; + if(n <= 0) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; @@ -641,7 +641,7 @@ START_API_FUNC return; } - if(n == 1) [[likely]] + if(n == 1) LIKELY { /* Special handling for the easy and normal case. */ ALbuffer *buffer{AllocBuffer(device)}; @@ -667,11 +667,11 @@ AL_API void AL_APIENTRY alDeleteBuffers(ALsizei n, const ALuint *buffers) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; - if(n < 0) [[unlikely]] + if(n < 0) UNLIKELY context->setError(AL_INVALID_VALUE, "Deleting %d buffers", n); - if(n <= 0) [[unlikely]] return; + if(n <= 0) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; @@ -681,12 +681,12 @@ START_API_FUNC { if(!bid) return true; ALbuffer *ALBuf{LookupBuffer(device, bid)}; - if(!ALBuf) [[unlikely]] + if(!ALBuf) UNLIKELY { context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", bid); return false; } - if(ReadRef(ALBuf->ref) != 0) [[unlikely]] + if(ReadRef(ALBuf->ref) != 0) UNLIKELY { context->setError(AL_INVALID_OPERATION, "Deleting in-use buffer %u", bid); return false; @@ -695,7 +695,7 @@ START_API_FUNC }; const ALuint *buffers_end = buffers + n; auto invbuf = std::find_if_not(buffers, buffers_end, validate_buffer); - if(invbuf != buffers_end) [[unlikely]] return; + if(invbuf != buffers_end) UNLIKELY return; /* All good. Delete non-0 buffer IDs. */ auto delete_buffer = [device](const ALuint bid) -> void @@ -711,7 +711,7 @@ AL_API ALboolean AL_APIENTRY alIsBuffer(ALuint buffer) START_API_FUNC { ContextRef context{GetContextRef()}; - if(context) [[likely]] + if(context) LIKELY { ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; @@ -732,28 +732,28 @@ AL_API void AL_APIENTRY alBufferStorageSOFT(ALuint buffer, ALenum format, const START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; ALbuffer *albuf = LookupBuffer(device, buffer); - if(!albuf) [[unlikely]] + if(!albuf) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer); - else if(size < 0) [[unlikely]] + else if(size < 0) UNLIKELY context->setError(AL_INVALID_VALUE, "Negative storage size %d", size); - else if(freq < 1) [[unlikely]] + else if(freq < 1) UNLIKELY context->setError(AL_INVALID_VALUE, "Invalid sample rate %d", freq); - else if((flags&INVALID_STORAGE_MASK) != 0) [[unlikely]] + else if((flags&INVALID_STORAGE_MASK) != 0) UNLIKELY context->setError(AL_INVALID_VALUE, "Invalid storage flags 0x%x", flags&INVALID_STORAGE_MASK); - else if((flags&AL_MAP_PERSISTENT_BIT_SOFT) && !(flags&MAP_READ_WRITE_FLAGS)) [[unlikely]] + else if((flags&AL_MAP_PERSISTENT_BIT_SOFT) && !(flags&MAP_READ_WRITE_FLAGS)) UNLIKELY context->setError(AL_INVALID_VALUE, "Declaring persistently mapped storage without read or write access"); else { auto usrfmt = DecomposeUserFormat(format); - if(!usrfmt) [[unlikely]] + if(!usrfmt) UNLIKELY context->setError(AL_INVALID_ENUM, "Invalid format 0x%04x", format); else { @@ -768,40 +768,40 @@ AL_API void* AL_APIENTRY alMapBufferSOFT(ALuint buffer, ALsizei offset, ALsizei START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return nullptr; + if(!context) UNLIKELY return nullptr; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; ALbuffer *albuf = LookupBuffer(device, buffer); - if(!albuf) [[unlikely]] + if(!albuf) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer); - else if((access&INVALID_MAP_FLAGS) != 0) [[unlikely]] + else if((access&INVALID_MAP_FLAGS) != 0) UNLIKELY context->setError(AL_INVALID_VALUE, "Invalid map flags 0x%x", access&INVALID_MAP_FLAGS); - else if(!(access&MAP_READ_WRITE_FLAGS)) [[unlikely]] + else if(!(access&MAP_READ_WRITE_FLAGS)) UNLIKELY context->setError(AL_INVALID_VALUE, "Mapping buffer %u without read or write access", buffer); else { ALbitfieldSOFT unavailable = (albuf->Access^access) & access; - if(ReadRef(albuf->ref) != 0 && !(access&AL_MAP_PERSISTENT_BIT_SOFT)) [[unlikely]] + if(ReadRef(albuf->ref) != 0 && !(access&AL_MAP_PERSISTENT_BIT_SOFT)) UNLIKELY context->setError(AL_INVALID_OPERATION, "Mapping in-use buffer %u without persistent mapping", buffer); - else if(albuf->MappedAccess != 0) [[unlikely]] + else if(albuf->MappedAccess != 0) UNLIKELY context->setError(AL_INVALID_OPERATION, "Mapping already-mapped buffer %u", buffer); - else if((unavailable&AL_MAP_READ_BIT_SOFT)) [[unlikely]] + else if((unavailable&AL_MAP_READ_BIT_SOFT)) UNLIKELY context->setError(AL_INVALID_VALUE, "Mapping buffer %u for reading without read access", buffer); - else if((unavailable&AL_MAP_WRITE_BIT_SOFT)) [[unlikely]] + else if((unavailable&AL_MAP_WRITE_BIT_SOFT)) UNLIKELY context->setError(AL_INVALID_VALUE, "Mapping buffer %u for writing without write access", buffer); - else if((unavailable&AL_MAP_PERSISTENT_BIT_SOFT)) [[unlikely]] + else if((unavailable&AL_MAP_PERSISTENT_BIT_SOFT)) UNLIKELY context->setError(AL_INVALID_VALUE, "Mapping buffer %u persistently without persistent access", buffer); else if(offset < 0 || length <= 0 || static_cast<ALuint>(offset) >= albuf->OriginalSize || static_cast<ALuint>(length) > albuf->OriginalSize - static_cast<ALuint>(offset)) - [[unlikely]] + UNLIKELY context->setError(AL_INVALID_VALUE, "Mapping invalid range %d+%d for buffer %u", offset, length, buffer); else @@ -822,15 +822,15 @@ AL_API void AL_APIENTRY alUnmapBufferSOFT(ALuint buffer) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; ALbuffer *albuf = LookupBuffer(device, buffer); - if(!albuf) [[unlikely]] + if(!albuf) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer); - else if(albuf->MappedAccess == 0) [[unlikely]] + else if(albuf->MappedAccess == 0) UNLIKELY context->setError(AL_INVALID_OPERATION, "Unmapping unmapped buffer %u", buffer); else { @@ -845,20 +845,20 @@ AL_API void AL_APIENTRY alFlushMappedBufferSOFT(ALuint buffer, ALsizei offset, A START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; ALbuffer *albuf = LookupBuffer(device, buffer); - if(!albuf) [[unlikely]] + if(!albuf) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer); - else if(!(albuf->MappedAccess&AL_MAP_WRITE_BIT_SOFT)) [[unlikely]] + else if(!(albuf->MappedAccess&AL_MAP_WRITE_BIT_SOFT)) UNLIKELY context->setError(AL_INVALID_OPERATION, "Flushing buffer %u while not mapped for writing", buffer); else if(offset < albuf->MappedOffset || length <= 0 || offset >= albuf->MappedOffset+albuf->MappedSize - || length > albuf->MappedOffset+albuf->MappedSize-offset) [[unlikely]] + || length > albuf->MappedOffset+albuf->MappedSize-offset) UNLIKELY context->setError(AL_INVALID_VALUE, "Flushing invalid range %d+%d on buffer %u", offset, length, buffer); else @@ -877,34 +877,34 @@ AL_API void AL_APIENTRY alBufferSubDataSOFT(ALuint buffer, ALenum format, const START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; ALbuffer *albuf = LookupBuffer(device, buffer); - if(!albuf) [[unlikely]] + if(!albuf) UNLIKELY return context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer); auto usrfmt = DecomposeUserFormat(format); - if(!usrfmt) [[unlikely]] + if(!usrfmt) UNLIKELY return context->setError(AL_INVALID_ENUM, "Invalid format 0x%04x", format); const ALuint unpack_align{albuf->UnpackAlign}; const ALuint align{SanitizeAlignment(usrfmt->type, unpack_align)}; - if(align < 1) [[unlikely]] + if(align < 1) UNLIKELY return context->setError(AL_INVALID_VALUE, "Invalid unpack alignment %u", unpack_align); if(al::to_underlying(usrfmt->channels) != al::to_underlying(albuf->mChannels) - || usrfmt->type != albuf->OriginalType) [[unlikely]] + || usrfmt->type != albuf->OriginalType) UNLIKELY return context->setError(AL_INVALID_ENUM, "Unpacking data with mismatched format"); - if(align != albuf->mBlockAlign) [[unlikely]] + if(align != albuf->mBlockAlign) UNLIKELY return context->setError(AL_INVALID_VALUE, "Unpacking data with alignment %u does not match original alignment %u", align, albuf->mBlockAlign); - if(albuf->isBFormat() && albuf->UnpackAmbiOrder != albuf->mAmbiOrder) [[unlikely]] + if(albuf->isBFormat() && albuf->UnpackAmbiOrder != albuf->mAmbiOrder) UNLIKELY return context->setError(AL_INVALID_VALUE, "Unpacking data with mismatched ambisonic order"); - if(albuf->MappedAccess != 0) [[unlikely]] + if(albuf->MappedAccess != 0) UNLIKELY return context->setError(AL_INVALID_OPERATION, "Unpacking data into mapped buffer %u", buffer); @@ -916,14 +916,14 @@ START_API_FUNC if(offset < 0 || length < 0 || static_cast<ALuint>(offset) > albuf->OriginalSize || static_cast<ALuint>(length) > albuf->OriginalSize-static_cast<ALuint>(offset)) - [[unlikely]] + UNLIKELY return context->setError(AL_INVALID_VALUE, "Invalid data sub-range %d+%d on buffer %u", offset, length, buffer); - if((static_cast<ALuint>(offset)%byte_align) != 0) [[unlikely]] + if((static_cast<ALuint>(offset)%byte_align) != 0) UNLIKELY return context->setError(AL_INVALID_VALUE, "Sub-range offset %d is not a multiple of frame size %d (%d unpack alignment)", offset, byte_align, align); - if((static_cast<ALuint>(length)%byte_align) != 0) [[unlikely]] + if((static_cast<ALuint>(length)%byte_align) != 0) UNLIKELY return context->setError(AL_INVALID_VALUE, "Sub-range length %d is not a multiple of frame size %d (%d unpack alignment)", length, byte_align, align); @@ -940,7 +940,7 @@ AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint /*buffer*/, ALuint /*samplera START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; context->setError(AL_INVALID_OPERATION, "alBufferSamplesSOFT not supported"); } @@ -951,7 +951,7 @@ AL_API void AL_APIENTRY alBufferSubSamplesSOFT(ALuint /*buffer*/, ALsizei /*offs START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; context->setError(AL_INVALID_OPERATION, "alBufferSubSamplesSOFT not supported"); } @@ -962,7 +962,7 @@ AL_API void AL_APIENTRY alGetBufferSamplesSOFT(ALuint /*buffer*/, ALsizei /*offs START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; context->setError(AL_INVALID_OPERATION, "alGetBufferSamplesSOFT not supported"); } @@ -972,7 +972,7 @@ AL_API ALboolean AL_APIENTRY alIsBufferFormatSupportedSOFT(ALenum /*format*/) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return AL_FALSE; + if(!context) UNLIKELY return AL_FALSE; context->setError(AL_INVALID_OPERATION, "alIsBufferFormatSupportedSOFT not supported"); return AL_FALSE; @@ -984,12 +984,12 @@ AL_API void AL_APIENTRY alBufferf(ALuint buffer, ALenum param, ALfloat /*value*/ START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; - if(LookupBuffer(device, buffer) == nullptr) [[unlikely]] + if(LookupBuffer(device, buffer) == nullptr) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer); else switch(param) { @@ -1004,12 +1004,12 @@ AL_API void AL_APIENTRY alBuffer3f(ALuint buffer, ALenum param, START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; - if(LookupBuffer(device, buffer) == nullptr) [[unlikely]] + if(LookupBuffer(device, buffer) == nullptr) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer); else switch(param) { @@ -1023,14 +1023,14 @@ AL_API void AL_APIENTRY alBufferfv(ALuint buffer, ALenum param, const ALfloat *v START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; - if(LookupBuffer(device, buffer) == nullptr) [[unlikely]] + if(LookupBuffer(device, buffer) == nullptr) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer); - else if(!values) [[unlikely]] + else if(!values) UNLIKELY context->setError(AL_INVALID_VALUE, "NULL pointer"); else switch(param) { @@ -1045,53 +1045,53 @@ AL_API void AL_APIENTRY alBufferi(ALuint buffer, ALenum param, ALint value) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; ALbuffer *albuf = LookupBuffer(device, buffer); - if(!albuf) [[unlikely]] + if(!albuf) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer); else switch(param) { case AL_UNPACK_BLOCK_ALIGNMENT_SOFT: - if(value < 0) [[unlikely]] + if(value < 0) UNLIKELY context->setError(AL_INVALID_VALUE, "Invalid unpack block alignment %d", value); else albuf->UnpackAlign = static_cast<ALuint>(value); break; case AL_PACK_BLOCK_ALIGNMENT_SOFT: - if(value < 0) [[unlikely]] + if(value < 0) UNLIKELY context->setError(AL_INVALID_VALUE, "Invalid pack block alignment %d", value); else albuf->PackAlign = static_cast<ALuint>(value); break; case AL_AMBISONIC_LAYOUT_SOFT: - if(ReadRef(albuf->ref) != 0) [[unlikely]] + if(ReadRef(albuf->ref) != 0) UNLIKELY context->setError(AL_INVALID_OPERATION, "Modifying in-use buffer %u's ambisonic layout", buffer); - else if(value != AL_FUMA_SOFT && value != AL_ACN_SOFT) [[unlikely]] + else if(value != AL_FUMA_SOFT && value != AL_ACN_SOFT) UNLIKELY context->setError(AL_INVALID_VALUE, "Invalid unpack ambisonic layout %04x", value); else albuf->mAmbiLayout = AmbiLayoutFromEnum(value).value(); break; case AL_AMBISONIC_SCALING_SOFT: - if(ReadRef(albuf->ref) != 0) [[unlikely]] + if(ReadRef(albuf->ref) != 0) UNLIKELY context->setError(AL_INVALID_OPERATION, "Modifying in-use buffer %u's ambisonic scaling", buffer); else if(value != AL_FUMA_SOFT && value != AL_SN3D_SOFT && value != AL_N3D_SOFT) - [[unlikely]] + UNLIKELY context->setError(AL_INVALID_VALUE, "Invalid unpack ambisonic scaling %04x", value); else albuf->mAmbiScaling = AmbiScalingFromEnum(value).value(); break; case AL_UNPACK_AMBISONIC_ORDER_SOFT: - if(value < 1 || value > 14) [[unlikely]] + if(value < 1 || value > 14) UNLIKELY context->setError(AL_INVALID_VALUE, "Invalid unpack ambisonic order %d", value); else albuf->UnpackAmbiOrder = static_cast<ALuint>(value); @@ -1108,12 +1108,12 @@ AL_API void AL_APIENTRY alBuffer3i(ALuint buffer, ALenum param, START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; - if(LookupBuffer(device, buffer) == nullptr) [[unlikely]] + if(LookupBuffer(device, buffer) == nullptr) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer); else switch(param) { @@ -1141,24 +1141,24 @@ START_API_FUNC } ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; ALbuffer *albuf = LookupBuffer(device, buffer); - if(!albuf) [[unlikely]] + if(!albuf) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer); - else if(!values) [[unlikely]] + else if(!values) UNLIKELY context->setError(AL_INVALID_VALUE, "NULL pointer"); else switch(param) { case AL_LOOP_POINTS_SOFT: - if(ReadRef(albuf->ref) != 0) [[unlikely]] + if(ReadRef(albuf->ref) != 0) UNLIKELY context->setError(AL_INVALID_OPERATION, "Modifying in-use buffer %u's loop points", buffer); else if(values[0] < 0 || values[0] >= values[1] - || static_cast<ALuint>(values[1]) > albuf->mSampleLen) [[unlikely]] + || static_cast<ALuint>(values[1]) > albuf->mSampleLen) UNLIKELY context->setError(AL_INVALID_VALUE, "Invalid loop point range %d -> %d on buffer %u", values[0], values[1], buffer); else @@ -1179,15 +1179,15 @@ AL_API void AL_APIENTRY alGetBufferf(ALuint buffer, ALenum param, ALfloat *value START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; ALbuffer *albuf = LookupBuffer(device, buffer); - if(!albuf) [[unlikely]] + if(!albuf) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer); - else if(!value) [[unlikely]] + else if(!value) UNLIKELY context->setError(AL_INVALID_VALUE, "NULL pointer"); else switch(param) { @@ -1201,14 +1201,14 @@ AL_API void AL_APIENTRY alGetBuffer3f(ALuint buffer, ALenum param, ALfloat *valu START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; - if(LookupBuffer(device, buffer) == nullptr) [[unlikely]] + if(LookupBuffer(device, buffer) == nullptr) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer); - else if(!value1 || !value2 || !value3) [[unlikely]] + else if(!value1 || !value2 || !value3) UNLIKELY context->setError(AL_INVALID_VALUE, "NULL pointer"); else switch(param) { @@ -1229,14 +1229,14 @@ START_API_FUNC } ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; - if(LookupBuffer(device, buffer) == nullptr) [[unlikely]] + if(LookupBuffer(device, buffer) == nullptr) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer); - else if(!values) [[unlikely]] + else if(!values) UNLIKELY context->setError(AL_INVALID_VALUE, "NULL pointer"); else switch(param) { @@ -1251,14 +1251,14 @@ AL_API void AL_APIENTRY alGetBufferi(ALuint buffer, ALenum param, ALint *value) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; ALbuffer *albuf = LookupBuffer(device, buffer); - if(!albuf) [[unlikely]] + if(!albuf) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer); - else if(!value) [[unlikely]] + else if(!value) UNLIKELY context->setError(AL_INVALID_VALUE, "NULL pointer"); else switch(param) { @@ -1310,13 +1310,13 @@ AL_API void AL_APIENTRY alGetBuffer3i(ALuint buffer, ALenum param, ALint *value1 START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; - if(LookupBuffer(device, buffer) == nullptr) [[unlikely]] + if(LookupBuffer(device, buffer) == nullptr) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer); - else if(!value1 || !value2 || !value3) [[unlikely]] + else if(!value1 || !value2 || !value3) UNLIKELY context->setError(AL_INVALID_VALUE, "NULL pointer"); else switch(param) { @@ -1348,14 +1348,14 @@ START_API_FUNC } ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; ALbuffer *albuf = LookupBuffer(device, buffer); - if(!albuf) [[unlikely]] + if(!albuf) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer); - else if(!values) [[unlikely]] + else if(!values) UNLIKELY context->setError(AL_INVALID_VALUE, "NULL pointer"); else switch(param) { @@ -1376,22 +1376,22 @@ AL_API void AL_APIENTRY alBufferCallbackSOFT(ALuint buffer, ALenum format, ALsiz START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; ALbuffer *albuf = LookupBuffer(device, buffer); - if(!albuf) [[unlikely]] + if(!albuf) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer); - else if(freq < 1) [[unlikely]] + else if(freq < 1) UNLIKELY context->setError(AL_INVALID_VALUE, "Invalid sample rate %d", freq); - else if(callback == nullptr) [[unlikely]] + else if(callback == nullptr) UNLIKELY context->setError(AL_INVALID_VALUE, "NULL callback"); else { auto usrfmt = DecomposeUserFormat(format); - if(!usrfmt) [[unlikely]] + if(!usrfmt) UNLIKELY context->setError(AL_INVALID_ENUM, "Invalid format 0x%04x", format); else PrepareCallback(context.get(), albuf, freq, usrfmt->channels, usrfmt->type, callback, @@ -1404,14 +1404,14 @@ AL_API void AL_APIENTRY alGetBufferPtrSOFT(ALuint buffer, ALenum param, ALvoid * START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; ALbuffer *albuf = LookupBuffer(device, buffer); - if(!albuf) [[unlikely]] + if(!albuf) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer); - else if(!value) [[unlikely]] + else if(!value) UNLIKELY context->setError(AL_INVALID_VALUE, "NULL pointer"); else switch(param) { @@ -1432,13 +1432,13 @@ AL_API void AL_APIENTRY alGetBuffer3PtrSOFT(ALuint buffer, ALenum param, ALvoid START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; - if(LookupBuffer(device, buffer) == nullptr) [[unlikely]] + if(LookupBuffer(device, buffer) == nullptr) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer); - else if(!value1 || !value2 || !value3) [[unlikely]] + else if(!value1 || !value2 || !value3) UNLIKELY context->setError(AL_INVALID_VALUE, "NULL pointer"); else switch(param) { @@ -1460,13 +1460,13 @@ START_API_FUNC } ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; - if(LookupBuffer(device, buffer) == nullptr) [[unlikely]] + if(LookupBuffer(device, buffer) == nullptr) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer); - else if(!values) [[unlikely]] + else if(!values) UNLIKELY context->setError(AL_INVALID_VALUE, "NULL pointer"); else switch(param) { @@ -1551,7 +1551,7 @@ START_API_FUNC continue; const auto al_buffer = LookupBuffer(device, buffer); - if(!al_buffer) [[unlikely]] + if(!al_buffer) UNLIKELY { ERR(EAX_PREFIX "Invalid buffer ID %u.\n", buffer); return ALC_FALSE; @@ -1567,7 +1567,7 @@ START_API_FUNC * buffer ID is specified multiple times in the provided list, it * counts each instance as more memory that needs to fit in X-RAM. */ - if(std::numeric_limits<size_t>::max()-al_buffer->OriginalSize < total_needed) [[unlikely]] + if(std::numeric_limits<size_t>::max()-al_buffer->OriginalSize < total_needed) UNLIKELY { context->setError(AL_OUT_OF_MEMORY, EAX_PREFIX "Buffer size overflow (%u + %zu)\n", al_buffer->OriginalSize, total_needed); diff --git a/al/effect.cpp b/al/effect.cpp index bb4e9de6..bde89912 100644 --- a/al/effect.cpp +++ b/al/effect.cpp @@ -167,14 +167,14 @@ bool EnsureEffects(ALCdevice *device, size_t needed) while(needed > count) { - if(device->EffectList.size() >= 1<<25) [[unlikely]] + if(device->EffectList.size() >= 1<<25) UNLIKELY return false; device->EffectList.emplace_back(); auto sublist = device->EffectList.end() - 1; sublist->FreeMask = ~0_u64; sublist->Effects = static_cast<ALeffect*>(al_calloc(alignof(ALeffect), sizeof(ALeffect)*64)); - if(!sublist->Effects) [[unlikely]] + if(!sublist->Effects) UNLIKELY { device->EffectList.pop_back(); return false; @@ -220,10 +220,10 @@ inline ALeffect *LookupEffect(ALCdevice *device, ALuint id) const size_t lidx{(id-1) >> 6}; const ALuint slidx{(id-1) & 0x3f}; - if(lidx >= device->EffectList.size()) [[unlikely]] + if(lidx >= device->EffectList.size()) UNLIKELY return nullptr; EffectSubList &sublist = device->EffectList[lidx]; - if(sublist.FreeMask & (1_u64 << slidx)) [[unlikely]] + if(sublist.FreeMask & (1_u64 << slidx)) UNLIKELY return nullptr; return sublist.Effects + slidx; } @@ -234,11 +234,11 @@ AL_API void AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; - if(n < 0) [[unlikely]] + if(n < 0) UNLIKELY context->setError(AL_INVALID_VALUE, "Generating %d effects", n); - if(n <= 0) [[unlikely]] return; + if(n <= 0) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->EffectLock}; @@ -248,7 +248,7 @@ START_API_FUNC return; } - if(n == 1) [[likely]] + if(n == 1) LIKELY { /* Special handling for the easy and normal case. */ ALeffect *effect{AllocEffect(device)}; @@ -274,11 +274,11 @@ AL_API void AL_APIENTRY alDeleteEffects(ALsizei n, const ALuint *effects) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; - if(n < 0) [[unlikely]] + if(n < 0) UNLIKELY context->setError(AL_INVALID_VALUE, "Deleting %d effects", n); - if(n <= 0) [[unlikely]] return; + if(n <= 0) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->EffectLock}; @@ -289,7 +289,7 @@ START_API_FUNC const ALuint *effects_end = effects + n; auto inveffect = std::find_if_not(effects, effects_end, validate_effect); - if(inveffect != effects_end) [[unlikely]] + if(inveffect != effects_end) UNLIKELY { context->setError(AL_INVALID_NAME, "Invalid effect ID %u", *inveffect); return; @@ -309,7 +309,7 @@ AL_API ALboolean AL_APIENTRY alIsEffect(ALuint effect) START_API_FUNC { ContextRef context{GetContextRef()}; - if(context) [[likely]] + if(context) LIKELY { ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->EffectLock}; @@ -324,13 +324,13 @@ AL_API void AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint value) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->EffectLock}; ALeffect *aleffect{LookupEffect(device, effect)}; - if(!aleffect) [[unlikely]] + if(!aleffect) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid effect ID %u", effect); else if(param == AL_EFFECT_TYPE) { @@ -374,13 +374,13 @@ START_API_FUNC } ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->EffectLock}; ALeffect *aleffect{LookupEffect(device, effect)}; - if(!aleffect) [[unlikely]] + if(!aleffect) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid effect ID %u", effect); else try { @@ -397,13 +397,13 @@ AL_API void AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat value) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->EffectLock}; ALeffect *aleffect{LookupEffect(device, effect)}; - if(!aleffect) [[unlikely]] + if(!aleffect) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid effect ID %u", effect); else try { @@ -420,13 +420,13 @@ AL_API void AL_APIENTRY alEffectfv(ALuint effect, ALenum param, const ALfloat *v START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->EffectLock}; ALeffect *aleffect{LookupEffect(device, effect)}; - if(!aleffect) [[unlikely]] + if(!aleffect) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid effect ID %u", effect); else try { @@ -443,13 +443,13 @@ AL_API void AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *value) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->EffectLock}; const ALeffect *aleffect{LookupEffect(device, effect)}; - if(!aleffect) [[unlikely]] + if(!aleffect) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid effect ID %u", effect); else if(param == AL_EFFECT_TYPE) *value = aleffect->type; @@ -475,13 +475,13 @@ START_API_FUNC } ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->EffectLock}; const ALeffect *aleffect{LookupEffect(device, effect)}; - if(!aleffect) [[unlikely]] + if(!aleffect) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid effect ID %u", effect); else try { @@ -498,13 +498,13 @@ AL_API void AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *value START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->EffectLock}; const ALeffect *aleffect{LookupEffect(device, effect)}; - if(!aleffect) [[unlikely]] + if(!aleffect) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid effect ID %u", effect); else try { @@ -521,13 +521,13 @@ AL_API void AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *valu START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->EffectLock}; const ALeffect *aleffect{LookupEffect(device, effect)}; - if(!aleffect) [[unlikely]] + if(!aleffect) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid effect ID %u", effect); else try { diff --git a/al/error.cpp b/al/error.cpp index 0340f430..afa7019a 100644 --- a/al/error.cpp +++ b/al/error.cpp @@ -85,7 +85,7 @@ AL_API ALenum AL_APIENTRY alGetError(void) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] + if(!context) UNLIKELY { static constexpr ALenum deferror{AL_INVALID_OPERATION}; WARN("Querying error state on null context (implicitly 0x%04x)\n", deferror); diff --git a/al/event.cpp b/al/event.cpp index 8b8fa686..1bc39d1e 100644 --- a/al/event.cpp +++ b/al/event.cpp @@ -55,7 +55,7 @@ static int EventThread(ALCcontext *context) ring->readAdvance(1); quitnow = evt.EnumType == AsyncEvent::KillThread; - if(quitnow) [[unlikely]] break; + if(quitnow) UNLIKELY break; if(evt.EnumType == AsyncEvent::ReleaseEffectState) { @@ -150,7 +150,7 @@ AL_API void AL_APIENTRY alEventControlSOFT(ALsizei count, const ALenum *types, A START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; if(count < 0) context->setError(AL_INVALID_VALUE, "Controlling %d events", count); if(count <= 0) return; @@ -205,7 +205,7 @@ AL_API void AL_APIENTRY alEventCallbackSOFT(ALEVENTPROCSOFT callback, void *user START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mPropLock}; std::lock_guard<std::mutex> __{context->mEventCbLock}; diff --git a/al/extension.cpp b/al/extension.cpp index 3a84ee08..3ead0af8 100644 --- a/al/extension.cpp +++ b/al/extension.cpp @@ -37,9 +37,9 @@ AL_API ALboolean AL_APIENTRY alIsExtensionPresent(const ALchar *extName) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return AL_FALSE; + if(!context) UNLIKELY return AL_FALSE; - if(!extName) [[unlikely]] + if(!extName) UNLIKELY { context->setError(AL_INVALID_VALUE, "NULL pointer"); return AL_FALSE; diff --git a/al/filter.cpp b/al/filter.cpp index 68daee76..73efa01f 100644 --- a/al/filter.cpp +++ b/al/filter.cpp @@ -336,14 +336,14 @@ bool EnsureFilters(ALCdevice *device, size_t needed) while(needed > count) { - if(device->FilterList.size() >= 1<<25) [[unlikely]] + if(device->FilterList.size() >= 1<<25) UNLIKELY return false; device->FilterList.emplace_back(); auto sublist = device->FilterList.end() - 1; sublist->FreeMask = ~0_u64; sublist->Filters = static_cast<ALfilter*>(al_calloc(alignof(ALfilter), sizeof(ALfilter)*64)); - if(!sublist->Filters) [[unlikely]] + if(!sublist->Filters) UNLIKELY { device->FilterList.pop_back(); return false; @@ -391,10 +391,10 @@ inline ALfilter *LookupFilter(ALCdevice *device, ALuint id) const size_t lidx{(id-1) >> 6}; const ALuint slidx{(id-1) & 0x3f}; - if(lidx >= device->FilterList.size()) [[unlikely]] + if(lidx >= device->FilterList.size()) UNLIKELY return nullptr; FilterSubList &sublist = device->FilterList[lidx]; - if(sublist.FreeMask & (1_u64 << slidx)) [[unlikely]] + if(sublist.FreeMask & (1_u64 << slidx)) UNLIKELY return nullptr; return sublist.Filters + slidx; } @@ -405,11 +405,11 @@ AL_API void AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; - if(n < 0) [[unlikely]] + if(n < 0) UNLIKELY context->setError(AL_INVALID_VALUE, "Generating %d filters", n); - if(n <= 0) [[unlikely]] return; + if(n <= 0) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->FilterLock}; @@ -419,7 +419,7 @@ START_API_FUNC return; } - if(n == 1) [[likely]] + if(n == 1) LIKELY { /* Special handling for the easy and normal case. */ ALfilter *filter{AllocFilter(device)}; @@ -445,11 +445,11 @@ AL_API void AL_APIENTRY alDeleteFilters(ALsizei n, const ALuint *filters) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; - if(n < 0) [[unlikely]] + if(n < 0) UNLIKELY context->setError(AL_INVALID_VALUE, "Deleting %d filters", n); - if(n <= 0) [[unlikely]] return; + if(n <= 0) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->FilterLock}; @@ -460,7 +460,7 @@ START_API_FUNC const ALuint *filters_end = filters + n; auto invflt = std::find_if_not(filters, filters_end, validate_filter); - if(invflt != filters_end) [[unlikely]] + if(invflt != filters_end) UNLIKELY { context->setError(AL_INVALID_NAME, "Invalid filter ID %u", *invflt); return; @@ -480,7 +480,7 @@ AL_API ALboolean AL_APIENTRY alIsFilter(ALuint filter) START_API_FUNC { ContextRef context{GetContextRef()}; - if(context) [[likely]] + if(context) LIKELY { ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->FilterLock}; @@ -496,13 +496,13 @@ AL_API void AL_APIENTRY alFilteri(ALuint filter, ALenum param, ALint value) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->FilterLock}; ALfilter *alfilt{LookupFilter(device, filter)}; - if(!alfilt) [[unlikely]] + if(!alfilt) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid filter ID %u", filter); else { @@ -537,13 +537,13 @@ START_API_FUNC } ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->FilterLock}; ALfilter *alfilt{LookupFilter(device, filter)}; - if(!alfilt) [[unlikely]] + if(!alfilt) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid filter ID %u", filter); else try { @@ -560,13 +560,13 @@ AL_API void AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat value) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->FilterLock}; ALfilter *alfilt{LookupFilter(device, filter)}; - if(!alfilt) [[unlikely]] + if(!alfilt) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid filter ID %u", filter); else try { @@ -583,13 +583,13 @@ AL_API void AL_APIENTRY alFilterfv(ALuint filter, ALenum param, const ALfloat *v START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->FilterLock}; ALfilter *alfilt{LookupFilter(device, filter)}; - if(!alfilt) [[unlikely]] + if(!alfilt) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid filter ID %u", filter); else try { @@ -606,13 +606,13 @@ AL_API void AL_APIENTRY alGetFilteri(ALuint filter, ALenum param, ALint *value) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->FilterLock}; const ALfilter *alfilt{LookupFilter(device, filter)}; - if(!alfilt) [[unlikely]] + if(!alfilt) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid filter ID %u", filter); else { @@ -641,13 +641,13 @@ START_API_FUNC } ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->FilterLock}; const ALfilter *alfilt{LookupFilter(device, filter)}; - if(!alfilt) [[unlikely]] + if(!alfilt) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid filter ID %u", filter); else try { @@ -664,13 +664,13 @@ AL_API void AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *value START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->FilterLock}; const ALfilter *alfilt{LookupFilter(device, filter)}; - if(!alfilt) [[unlikely]] + if(!alfilt) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid filter ID %u", filter); else try { @@ -687,13 +687,13 @@ AL_API void AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *valu START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALCdevice *device{context->mALDevice.get()}; std::lock_guard<std::mutex> _{device->FilterLock}; const ALfilter *alfilt{LookupFilter(device, filter)}; - if(!alfilt) [[unlikely]] + if(!alfilt) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid filter ID %u", filter); else try { diff --git a/al/listener.cpp b/al/listener.cpp index 4aa261dd..2a9b77f3 100644 --- a/al/listener.cpp +++ b/al/listener.cpp @@ -81,7 +81,7 @@ AL_API void AL_APIENTRY alListenerf(ALenum param, ALfloat value) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALlistener &listener = context->mListener; std::lock_guard<std::mutex> _{context->mPropLock}; @@ -111,7 +111,7 @@ AL_API void AL_APIENTRY alListener3f(ALenum param, ALfloat value1, ALfloat value START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALlistener &listener = context->mListener; std::lock_guard<std::mutex> _{context->mPropLock}; @@ -161,9 +161,9 @@ START_API_FUNC } ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; - if(!values) [[unlikely]] + if(!values) UNLIKELY return context->setError(AL_INVALID_VALUE, "NULL pointer"); ALlistener &listener = context->mListener; @@ -195,7 +195,7 @@ AL_API void AL_APIENTRY alListeneri(ALenum param, ALint /*value*/) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mPropLock}; switch(param) @@ -219,7 +219,7 @@ START_API_FUNC } ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mPropLock}; switch(param) @@ -257,10 +257,10 @@ START_API_FUNC } ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mPropLock}; - if(!values) [[unlikely]] + if(!values) UNLIKELY context->setError(AL_INVALID_VALUE, "NULL pointer"); else switch(param) { @@ -275,7 +275,7 @@ AL_API void AL_APIENTRY alGetListenerf(ALenum param, ALfloat *value) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALlistener &listener = context->mListener; std::lock_guard<std::mutex> _{context->mPropLock}; @@ -301,7 +301,7 @@ AL_API void AL_APIENTRY alGetListener3f(ALenum param, ALfloat *value1, ALfloat * START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALlistener &listener = context->mListener; std::lock_guard<std::mutex> _{context->mPropLock}; @@ -344,7 +344,7 @@ START_API_FUNC } ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALlistener &listener = context->mListener; std::lock_guard<std::mutex> _{context->mPropLock}; @@ -373,7 +373,7 @@ AL_API void AL_APIENTRY alGetListeneri(ALenum param, ALint *value) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mPropLock}; if(!value) @@ -390,7 +390,7 @@ AL_API void AL_APIENTRY alGetListener3i(ALenum param, ALint *value1, ALint *valu START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALlistener &listener = context->mListener; std::lock_guard<std::mutex> _{context->mPropLock}; @@ -428,7 +428,7 @@ START_API_FUNC } ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; ALlistener &listener = context->mListener; std::lock_guard<std::mutex> _{context->mPropLock}; diff --git a/al/source.cpp b/al/source.cpp index 8e323445..7a739d3d 100644 --- a/al/source.cpp +++ b/al/source.cpp @@ -553,7 +553,7 @@ void InitVoice(Voice *voice, ALsource *source, ALbufferQueueItem *BufferList, AL VoiceChange *GetVoiceChanger(ALCcontext *ctx) { VoiceChange *vchg{ctx->mVoiceChangeTail}; - if(vchg == ctx->mCurrentVoiceChange.load(std::memory_order_acquire)) [[unlikely]] + if(vchg == ctx->mCurrentVoiceChange.load(std::memory_order_acquire)) UNLIKELY { ctx->allocVoiceChanges(); vchg = ctx->mVoiceChangeTail; @@ -575,7 +575,7 @@ void SendVoiceChanges(ALCcontext *ctx, VoiceChange *tail) const bool connected{device->Connected.load(std::memory_order_acquire)}; device->waitForMix(); - if(!connected) [[unlikely]] + if(!connected) UNLIKELY { if(ctx->mStopVoicesOnDisconnect.load(std::memory_order_acquire)) { @@ -613,7 +613,7 @@ bool SetVoiceOffset(Voice *oldvoice, const VoicePos &vpos, ALsource *source, ALC } ++vidx; } - if(!newvoice) [[unlikely]] + if(!newvoice) UNLIKELY { auto &allvoices = *context->mVoices.load(std::memory_order_relaxed); if(allvoices.size() == voicelist.size()) @@ -670,7 +670,7 @@ bool SetVoiceOffset(Voice *oldvoice, const VoicePos &vpos, ALsource *source, ALC /* If the old voice still has a sourceID, it's still active and the change- * over will work on the next update. */ - if(oldvoice->mSourceID.load(std::memory_order_acquire) != 0u) [[likely]] + if(oldvoice->mSourceID.load(std::memory_order_acquire) != 0u) LIKELY return true; /* Otherwise, if the new voice's state is not pending, the change-over @@ -723,14 +723,14 @@ bool EnsureSources(ALCcontext *context, size_t needed) while(needed > count) { - if(context->mSourceList.size() >= 1<<25) [[unlikely]] + if(context->mSourceList.size() >= 1<<25) UNLIKELY return false; context->mSourceList.emplace_back(); auto sublist = context->mSourceList.end() - 1; sublist->FreeMask = ~0_u64; sublist->Sources = static_cast<ALsource*>(al_calloc(alignof(ALsource), sizeof(ALsource)*64)); - if(!sublist->Sources) [[unlikely]] + if(!sublist->Sources) UNLIKELY { context->mSourceList.pop_back(); return false; @@ -790,10 +790,10 @@ inline ALsource *LookupSource(ALCcontext *context, ALuint id) noexcept const size_t lidx{(id-1) >> 6}; const ALuint slidx{(id-1) & 0x3f}; - if(lidx >= context->mSourceList.size()) [[unlikely]] + if(lidx >= context->mSourceList.size()) UNLIKELY return nullptr; SourceSubList &sublist{context->mSourceList[lidx]}; - if(sublist.FreeMask & (1_u64 << slidx)) [[unlikely]] + if(sublist.FreeMask & (1_u64 << slidx)) UNLIKELY return nullptr; return sublist.Sources + slidx; } @@ -803,10 +803,10 @@ inline ALbuffer *LookupBuffer(ALCdevice *device, ALuint id) noexcept const size_t lidx{(id-1) >> 6}; const ALuint slidx{(id-1) & 0x3f}; - if(lidx >= device->BufferList.size()) [[unlikely]] + if(lidx >= device->BufferList.size()) UNLIKELY return nullptr; BufferSubList &sublist = device->BufferList[lidx]; - if(sublist.FreeMask & (1_u64 << slidx)) [[unlikely]] + if(sublist.FreeMask & (1_u64 << slidx)) UNLIKELY return nullptr; return sublist.Buffers + slidx; } @@ -816,10 +816,10 @@ inline ALfilter *LookupFilter(ALCdevice *device, ALuint id) noexcept const size_t lidx{(id-1) >> 6}; const ALuint slidx{(id-1) & 0x3f}; - if(lidx >= device->FilterList.size()) [[unlikely]] + if(lidx >= device->FilterList.size()) UNLIKELY return nullptr; FilterSubList &sublist = device->FilterList[lidx]; - if(sublist.FreeMask & (1_u64 << slidx)) [[unlikely]] + if(sublist.FreeMask & (1_u64 << slidx)) UNLIKELY return nullptr; return sublist.Filters + slidx; } @@ -829,10 +829,10 @@ inline ALeffectslot *LookupEffectSlot(ALCcontext *context, ALuint id) noexcept const size_t lidx{(id-1) >> 6}; const ALuint slidx{(id-1) & 0x3f}; - if(lidx >= context->mEffectSlotList.size()) [[unlikely]] + if(lidx >= context->mEffectSlotList.size()) UNLIKELY return nullptr; EffectSlotSubList &sublist{context->mEffectSlotList[lidx]}; - if(sublist.FreeMask & (1_u64 << slidx)) [[unlikely]] + if(sublist.FreeMask & (1_u64 << slidx)) UNLIKELY return nullptr; return sublist.EffectSlots + slidx; } @@ -1212,14 +1212,14 @@ auto GetCheckers(ALCcontext *const Context, const SourceProp prop, const al::spa return std::make_pair( [=](size_t expect) -> void { - if(values.size() == expect || values.size() == MaxValues) [[likely]] return; + if(values.size() == expect || values.size() == MaxValues) LIKELY return; Context->setError(AL_INVALID_ENUM, "Property 0x%04x expects %zu value(s), got %zu", prop, expect, values.size()); throw check_size_exception{}; }, [Context](bool passed) -> void { - if(passed) [[likely]] return; + if(passed) LIKELY return; Context->setError(AL_INVALID_VALUE, "Value out of range"); throw check_value_exception{}; } @@ -1931,7 +1931,7 @@ auto GetSizeChecker(ALCcontext *const Context, const SourceProp prop, const al:: { return [=](size_t expect) -> void { - if(values.size() == expect || values.size() == MaxValues) [[likely]] return; + if(values.size() == expect || values.size() == MaxValues) LIKELY return; Context->setError(AL_INVALID_ENUM, "Property 0x%04x expects %zu value(s), got %zu", prop, expect, values.size()); throw check_size_exception{}; @@ -2506,7 +2506,7 @@ void StartSources(ALCcontext *const context, const al::span<ALsource*> srchandle /* If the device is disconnected, and voices stop on disconnect, go right * to stopped. */ - if(!device->Connected.load(std::memory_order_acquire)) [[unlikely]] + if(!device->Connected.load(std::memory_order_acquire)) UNLIKELY { if(context->mStopVoicesOnDisconnect.load(std::memory_order_acquire)) { @@ -2532,7 +2532,7 @@ void StartSources(ALCcontext *const context, const al::span<ALsource*> srchandle if(free_voices == srchandles.size()) break; } - if(srchandles.size() != free_voices) [[unlikely]] + if(srchandles.size() != free_voices) UNLIKELY { const size_t inc_amount{srchandles.size() - free_voices}; auto &allvoices = *context->mVoices.load(std::memory_order_relaxed); @@ -2558,7 +2558,7 @@ void StartSources(ALCcontext *const context, const al::span<ALsource*> srchandle auto BufferList = std::find_if(source->mQueue.begin(), source->mQueue.end(), find_buffer); /* If there's nothing to play, go right to stopped. */ - if(BufferList == source->mQueue.end()) [[unlikely]] + if(BufferList == source->mQueue.end()) UNLIKELY { /* NOTE: A source without any playable buffers should not have a * Voice since it shouldn't be in a playing or paused state. So @@ -2664,7 +2664,7 @@ void StartSources(ALCcontext *const context, const al::span<ALsource*> srchandle cur->mSourceID = source->id; cur->mState = VChangeState::Play; } - if(tail) [[likely]] + if(tail) LIKELY SendVoiceChanges(context, tail); } @@ -2674,11 +2674,11 @@ AL_API void AL_APIENTRY alGenSources(ALsizei n, ALuint *sources) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; - if(n < 0) [[unlikely]] + if(n < 0) UNLIKELY context->setError(AL_INVALID_VALUE, "Generating %d sources", n); - if(n <= 0) [[unlikely]] return; + if(n <= 0) UNLIKELY return; std::unique_lock<std::mutex> srclock{context->mSourceLock}; ALCdevice *device{context->mALDevice.get()}; @@ -2724,11 +2724,11 @@ AL_API void AL_APIENTRY alDeleteSources(ALsizei n, const ALuint *sources) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; - if(n < 0) [[unlikely]] + if(n < 0) UNLIKELY context->setError(AL_INVALID_VALUE, "Deleting %d sources", n); - if(n <= 0) [[unlikely]] return; + if(n <= 0) UNLIKELY return; std::lock_guard<std::mutex> _{context->mSourceLock}; @@ -2738,7 +2738,7 @@ START_API_FUNC const ALuint *sources_end = sources + n; auto invsrc = std::find_if_not(sources, sources_end, validate_source); - if(invsrc != sources_end) [[unlikely]] + if(invsrc != sources_end) UNLIKELY return context->setError(AL_INVALID_NAME, "Invalid source ID %u", *invsrc); /* All good. Delete source IDs. */ @@ -2755,7 +2755,7 @@ AL_API ALboolean AL_APIENTRY alIsSource(ALuint source) START_API_FUNC { ContextRef context{GetContextRef()}; - if(context) [[likely]] + if(context) LIKELY { std::lock_guard<std::mutex> _{context->mSourceLock}; if(LookupSource(context.get(), source) != nullptr) @@ -2770,12 +2770,12 @@ AL_API void AL_APIENTRY alSourcef(ALuint source, ALenum param, ALfloat value) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mPropLock}; std::lock_guard<std::mutex> __{context->mSourceLock}; ALsource *Source = LookupSource(context.get(), source); - if(!Source) [[unlikely]] + if(!Source) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid source ID %u", source); else SetSourcefv(Source, context.get(), static_cast<SourceProp>(param), {&value, 1u}); @@ -2786,12 +2786,12 @@ AL_API void AL_APIENTRY alSource3f(ALuint source, ALenum param, ALfloat value1, START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mPropLock}; std::lock_guard<std::mutex> __{context->mSourceLock}; ALsource *Source = LookupSource(context.get(), source); - if(!Source) [[unlikely]] + if(!Source) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid source ID %u", source); else { @@ -2805,14 +2805,14 @@ AL_API void AL_APIENTRY alSourcefv(ALuint source, ALenum param, const ALfloat *v START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mPropLock}; std::lock_guard<std::mutex> __{context->mSourceLock}; ALsource *Source = LookupSource(context.get(), source); - if(!Source) [[unlikely]] + if(!Source) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid source ID %u", source); - else if(!values) [[unlikely]] + else if(!values) UNLIKELY context->setError(AL_INVALID_VALUE, "NULL pointer"); else SetSourcefv(Source, context.get(), static_cast<SourceProp>(param), {values, MaxValues}); @@ -2824,12 +2824,12 @@ AL_API void AL_APIENTRY alSourcedSOFT(ALuint source, ALenum param, ALdouble valu START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mPropLock}; std::lock_guard<std::mutex> __{context->mSourceLock}; ALsource *Source = LookupSource(context.get(), source); - if(!Source) [[unlikely]] + if(!Source) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid source ID %u", source); else { @@ -2843,12 +2843,12 @@ AL_API void AL_APIENTRY alSource3dSOFT(ALuint source, ALenum param, ALdouble val START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mPropLock}; std::lock_guard<std::mutex> __{context->mSourceLock}; ALsource *Source = LookupSource(context.get(), source); - if(!Source) [[unlikely]] + if(!Source) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid source ID %u", source); else { @@ -2863,14 +2863,14 @@ AL_API void AL_APIENTRY alSourcedvSOFT(ALuint source, ALenum param, const ALdoub START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mPropLock}; std::lock_guard<std::mutex> __{context->mSourceLock}; ALsource *Source = LookupSource(context.get(), source); - if(!Source) [[unlikely]] + if(!Source) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid source ID %u", source); - else if(!values) [[unlikely]] + else if(!values) UNLIKELY context->setError(AL_INVALID_VALUE, "NULL pointer"); else { @@ -2888,12 +2888,12 @@ AL_API void AL_APIENTRY alSourcei(ALuint source, ALenum param, ALint value) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mPropLock}; std::lock_guard<std::mutex> __{context->mSourceLock}; ALsource *Source = LookupSource(context.get(), source); - if(!Source) [[unlikely]] + if(!Source) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid source ID %u", source); else SetSourceiv(Source, context.get(), static_cast<SourceProp>(param), {&value, 1u}); @@ -2904,12 +2904,12 @@ AL_API void AL_APIENTRY alSource3i(ALuint source, ALenum param, ALint value1, AL START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mPropLock}; std::lock_guard<std::mutex> __{context->mSourceLock}; ALsource *Source = LookupSource(context.get(), source); - if(!Source) [[unlikely]] + if(!Source) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid source ID %u", source); else { @@ -2923,14 +2923,14 @@ AL_API void AL_APIENTRY alSourceiv(ALuint source, ALenum param, const ALint *val START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mPropLock}; std::lock_guard<std::mutex> __{context->mSourceLock}; ALsource *Source = LookupSource(context.get(), source); - if(!Source) [[unlikely]] + if(!Source) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid source ID %u", source); - else if(!values) [[unlikely]] + else if(!values) UNLIKELY context->setError(AL_INVALID_VALUE, "NULL pointer"); else SetSourceiv(Source, context.get(), static_cast<SourceProp>(param), {values, MaxValues}); @@ -2942,12 +2942,12 @@ AL_API void AL_APIENTRY alSourcei64SOFT(ALuint source, ALenum param, ALint64SOFT START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mPropLock}; std::lock_guard<std::mutex> __{context->mSourceLock}; ALsource *Source{LookupSource(context.get(), source)}; - if(!Source) [[unlikely]] + if(!Source) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid source ID %u", source); else SetSourcei64v(Source, context.get(), static_cast<SourceProp>(param), {&value, 1u}); @@ -2958,12 +2958,12 @@ AL_API void AL_APIENTRY alSource3i64SOFT(ALuint source, ALenum param, ALint64SOF START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mPropLock}; std::lock_guard<std::mutex> __{context->mSourceLock}; ALsource *Source{LookupSource(context.get(), source)}; - if(!Source) [[unlikely]] + if(!Source) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid source ID %u", source); else { @@ -2977,14 +2977,14 @@ AL_API void AL_APIENTRY alSourcei64vSOFT(ALuint source, ALenum param, const ALin START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mPropLock}; std::lock_guard<std::mutex> __{context->mSourceLock}; ALsource *Source{LookupSource(context.get(), source)}; - if(!Source) [[unlikely]] + if(!Source) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid source ID %u", source); - else if(!values) [[unlikely]] + else if(!values) UNLIKELY context->setError(AL_INVALID_VALUE, "NULL pointer"); else SetSourcei64v(Source, context.get(), static_cast<SourceProp>(param), {values, MaxValues}); @@ -2996,13 +2996,13 @@ AL_API void AL_APIENTRY alGetSourcef(ALuint source, ALenum param, ALfloat *value START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mSourceLock}; ALsource *Source{LookupSource(context.get(), source)}; - if(!Source) [[unlikely]] + if(!Source) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid source ID %u", source); - else if(!value) [[unlikely]] + else if(!value) UNLIKELY context->setError(AL_INVALID_VALUE, "NULL pointer"); else { @@ -3017,13 +3017,13 @@ AL_API void AL_APIENTRY alGetSource3f(ALuint source, ALenum param, ALfloat *valu START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mSourceLock}; ALsource *Source{LookupSource(context.get(), source)}; - if(!Source) [[unlikely]] + if(!Source) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid source ID %u", source); - else if(!(value1 && value2 && value3)) [[unlikely]] + else if(!(value1 && value2 && value3)) UNLIKELY context->setError(AL_INVALID_VALUE, "NULL pointer"); else { @@ -3042,13 +3042,13 @@ AL_API void AL_APIENTRY alGetSourcefv(ALuint source, ALenum param, ALfloat *valu START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mSourceLock}; ALsource *Source{LookupSource(context.get(), source)}; - if(!Source) [[unlikely]] + if(!Source) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid source ID %u", source); - else if(!values) [[unlikely]] + else if(!values) UNLIKELY context->setError(AL_INVALID_VALUE, "NULL pointer"); else { @@ -3068,13 +3068,13 @@ AL_API void AL_APIENTRY alGetSourcedSOFT(ALuint source, ALenum param, ALdouble * START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mSourceLock}; ALsource *Source{LookupSource(context.get(), source)}; - if(!Source) [[unlikely]] + if(!Source) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid source ID %u", source); - else if(!value) [[unlikely]] + else if(!value) UNLIKELY context->setError(AL_INVALID_VALUE, "NULL pointer"); else GetSourcedv(Source, context.get(), static_cast<SourceProp>(param), {value, 1u}); @@ -3085,13 +3085,13 @@ AL_API void AL_APIENTRY alGetSource3dSOFT(ALuint source, ALenum param, ALdouble START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mSourceLock}; ALsource *Source{LookupSource(context.get(), source)}; - if(!Source) [[unlikely]] + if(!Source) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid source ID %u", source); - else if(!(value1 && value2 && value3)) [[unlikely]] + else if(!(value1 && value2 && value3)) UNLIKELY context->setError(AL_INVALID_VALUE, "NULL pointer"); else { @@ -3110,13 +3110,13 @@ AL_API void AL_APIENTRY alGetSourcedvSOFT(ALuint source, ALenum param, ALdouble START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mSourceLock}; ALsource *Source{LookupSource(context.get(), source)}; - if(!Source) [[unlikely]] + if(!Source) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid source ID %u", source); - else if(!values) [[unlikely]] + else if(!values) UNLIKELY context->setError(AL_INVALID_VALUE, "NULL pointer"); else GetSourcedv(Source, context.get(), static_cast<SourceProp>(param), {values, MaxValues}); @@ -3128,13 +3128,13 @@ AL_API void AL_APIENTRY alGetSourcei(ALuint source, ALenum param, ALint *value) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mSourceLock}; ALsource *Source{LookupSource(context.get(), source)}; - if(!Source) [[unlikely]] + if(!Source) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid source ID %u", source); - else if(!value) [[unlikely]] + else if(!value) UNLIKELY context->setError(AL_INVALID_VALUE, "NULL pointer"); else GetSourceiv(Source, context.get(), static_cast<SourceProp>(param), {value, 1u}); @@ -3145,13 +3145,13 @@ AL_API void AL_APIENTRY alGetSource3i(ALuint source, ALenum param, ALint *value1 START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mSourceLock}; ALsource *Source{LookupSource(context.get(), source)}; - if(!Source) [[unlikely]] + if(!Source) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid source ID %u", source); - else if(!(value1 && value2 && value3)) [[unlikely]] + else if(!(value1 && value2 && value3)) UNLIKELY context->setError(AL_INVALID_VALUE, "NULL pointer"); else { @@ -3170,13 +3170,13 @@ AL_API void AL_APIENTRY alGetSourceiv(ALuint source, ALenum param, ALint *values START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mSourceLock}; ALsource *Source{LookupSource(context.get(), source)}; - if(!Source) [[unlikely]] + if(!Source) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid source ID %u", source); - else if(!values) [[unlikely]] + else if(!values) UNLIKELY context->setError(AL_INVALID_VALUE, "NULL pointer"); else GetSourceiv(Source, context.get(), static_cast<SourceProp>(param), {values, MaxValues}); @@ -3188,13 +3188,13 @@ AL_API void AL_APIENTRY alGetSourcei64SOFT(ALuint source, ALenum param, ALint64S START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mSourceLock}; ALsource *Source{LookupSource(context.get(), source)}; - if(!Source) [[unlikely]] + if(!Source) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid source ID %u", source); - else if(!value) [[unlikely]] + else if(!value) UNLIKELY context->setError(AL_INVALID_VALUE, "NULL pointer"); else GetSourcei64v(Source, context.get(), static_cast<SourceProp>(param), {value, 1u}); @@ -3205,13 +3205,13 @@ AL_API void AL_APIENTRY alGetSource3i64SOFT(ALuint source, ALenum param, ALint64 START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mSourceLock}; ALsource *Source{LookupSource(context.get(), source)}; - if(!Source) [[unlikely]] + if(!Source) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid source ID %u", source); - else if(!(value1 && value2 && value3)) [[unlikely]] + else if(!(value1 && value2 && value3)) UNLIKELY context->setError(AL_INVALID_VALUE, "NULL pointer"); else { @@ -3230,13 +3230,13 @@ AL_API void AL_APIENTRY alGetSourcei64vSOFT(ALuint source, ALenum param, ALint64 START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mSourceLock}; ALsource *Source{LookupSource(context.get(), source)}; - if(!Source) [[unlikely]] + if(!Source) UNLIKELY context->setError(AL_INVALID_NAME, "Invalid source ID %u", source); - else if(!values) [[unlikely]] + else if(!values) UNLIKELY context->setError(AL_INVALID_VALUE, "NULL pointer"); else GetSourcei64v(Source, context.get(), static_cast<SourceProp>(param), {values, MaxValues}); @@ -3248,7 +3248,7 @@ AL_API void AL_APIENTRY alSourcePlay(ALuint source) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mSourceLock}; ALsource *srchandle{LookupSource(context.get(), source)}; @@ -3263,9 +3263,9 @@ void AL_APIENTRY alSourcePlayAtTimeSOFT(ALuint source, ALint64SOFT start_time) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; - if(start_time < 0) [[unlikely]] + if(start_time < 0) UNLIKELY return context->setError(AL_INVALID_VALUE, "Invalid time point %" PRId64, start_time); std::lock_guard<std::mutex> _{context->mSourceLock}; @@ -3281,16 +3281,16 @@ AL_API void AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; - if(n < 0) [[unlikely]] + if(n < 0) UNLIKELY context->setError(AL_INVALID_VALUE, "Playing %d sources", n); - if(n <= 0) [[unlikely]] return; + if(n <= 0) UNLIKELY return; al::vector<ALsource*> extra_sources; std::array<ALsource*,8> source_storage; al::span<ALsource*> srchandles; - if(static_cast<ALuint>(n) <= source_storage.size()) [[likely]] + if(static_cast<ALuint>(n) <= source_storage.size()) LIKELY srchandles = {source_storage.data(), static_cast<ALuint>(n)}; else { @@ -3302,7 +3302,7 @@ START_API_FUNC for(auto &srchdl : srchandles) { srchdl = LookupSource(context.get(), *sources); - if(!srchdl) [[unlikely]] + if(!srchdl) UNLIKELY return context->setError(AL_INVALID_NAME, "Invalid source ID %u", *sources); ++sources; } @@ -3315,19 +3315,19 @@ void AL_APIENTRY alSourcePlayAtTimevSOFT(ALsizei n, const ALuint *sources, ALint START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; - if(n < 0) [[unlikely]] + if(n < 0) UNLIKELY context->setError(AL_INVALID_VALUE, "Playing %d sources", n); - if(n <= 0) [[unlikely]] return; + if(n <= 0) UNLIKELY return; - if(start_time < 0) [[unlikely]] + if(start_time < 0) UNLIKELY return context->setError(AL_INVALID_VALUE, "Invalid time point %" PRId64, start_time); al::vector<ALsource*> extra_sources; std::array<ALsource*,8> source_storage; al::span<ALsource*> srchandles; - if(static_cast<ALuint>(n) <= source_storage.size()) [[likely]] + if(static_cast<ALuint>(n) <= source_storage.size()) LIKELY srchandles = {source_storage.data(), static_cast<ALuint>(n)}; else { @@ -3358,16 +3358,16 @@ AL_API void AL_APIENTRY alSourcePausev(ALsizei n, const ALuint *sources) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; - if(n < 0) [[unlikely]] + if(n < 0) UNLIKELY context->setError(AL_INVALID_VALUE, "Pausing %d sources", n); - if(n <= 0) [[unlikely]] return; + if(n <= 0) UNLIKELY return; al::vector<ALsource*> extra_sources; std::array<ALsource*,8> source_storage; al::span<ALsource*> srchandles; - if(static_cast<ALuint>(n) <= source_storage.size()) [[likely]] + if(static_cast<ALuint>(n) <= source_storage.size()) LIKELY srchandles = {source_storage.data(), static_cast<ALuint>(n)}; else { @@ -3406,7 +3406,7 @@ START_API_FUNC cur->mState = VChangeState::Pause; } } - if(tail) [[likely]] + if(tail) LIKELY { SendVoiceChanges(context.get(), tail); /* Second, now that the voice changes have been sent, because it's @@ -3434,16 +3434,16 @@ AL_API void AL_APIENTRY alSourceStopv(ALsizei n, const ALuint *sources) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; - if(n < 0) [[unlikely]] + if(n < 0) UNLIKELY context->setError(AL_INVALID_VALUE, "Stopping %d sources", n); - if(n <= 0) [[unlikely]] return; + if(n <= 0) UNLIKELY return; al::vector<ALsource*> extra_sources; std::array<ALsource*,8> source_storage; al::span<ALsource*> srchandles; - if(static_cast<ALuint>(n) <= source_storage.size()) [[likely]] + if(static_cast<ALuint>(n) <= source_storage.size()) LIKELY srchandles = {source_storage.data(), static_cast<ALuint>(n)}; else { @@ -3482,7 +3482,7 @@ START_API_FUNC source->OffsetType = AL_NONE; source->VoiceIdx = INVALID_VOICE_IDX; } - if(tail) [[likely]] + if(tail) LIKELY SendVoiceChanges(context.get(), tail); } END_API_FUNC @@ -3497,16 +3497,16 @@ AL_API void AL_APIENTRY alSourceRewindv(ALsizei n, const ALuint *sources) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; - if(n < 0) [[unlikely]] + if(n < 0) UNLIKELY context->setError(AL_INVALID_VALUE, "Rewinding %d sources", n); - if(n <= 0) [[unlikely]] return; + if(n <= 0) UNLIKELY return; al::vector<ALsource*> extra_sources; std::array<ALsource*,8> source_storage; al::span<ALsource*> srchandles; - if(static_cast<ALuint>(n) <= source_storage.size()) [[likely]] + if(static_cast<ALuint>(n) <= source_storage.size()) LIKELY srchandles = {source_storage.data(), static_cast<ALuint>(n)}; else { @@ -3547,7 +3547,7 @@ START_API_FUNC source->OffsetType = AL_NONE; source->VoiceIdx = INVALID_VOICE_IDX; } - if(tail) [[likely]] + if(tail) LIKELY SendVoiceChanges(context.get(), tail); } END_API_FUNC @@ -3557,19 +3557,19 @@ AL_API void AL_APIENTRY alSourceQueueBuffers(ALuint src, ALsizei nb, const ALuin START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; - if(nb < 0) [[unlikely]] + if(nb < 0) UNLIKELY context->setError(AL_INVALID_VALUE, "Queueing %d buffers", nb); - if(nb <= 0) [[unlikely]] return; + if(nb <= 0) UNLIKELY return; std::lock_guard<std::mutex> _{context->mSourceLock}; ALsource *source{LookupSource(context.get(),src)}; - if(!source) [[unlikely]] + if(!source) UNLIKELY return context->setError(AL_INVALID_NAME, "Invalid source ID %u", src); /* Can't queue on a Static Source */ - if(source->SourceType == AL_STATIC) [[unlikely]] + if(source->SourceType == AL_STATIC) UNLIKELY return context->setError(AL_INVALID_OPERATION, "Queueing onto static source %u", src); /* Check for a valid Buffer, for its frequency and format */ @@ -3637,7 +3637,7 @@ START_API_FUNC fmt_mismatch |= BufferFmt->mAmbiOrder != buffer->mAmbiOrder; fmt_mismatch |= BufferFmt->OriginalType != buffer->OriginalType; } - if(fmt_mismatch) [[unlikely]] + if(fmt_mismatch) UNLIKELY { context->setError(AL_INVALID_OPERATION, "Queueing buffer with mismatched format"); @@ -3673,26 +3673,26 @@ AL_API void AL_APIENTRY alSourceUnqueueBuffers(ALuint src, ALsizei nb, ALuint *b START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; - if(nb < 0) [[unlikely]] + if(nb < 0) UNLIKELY context->setError(AL_INVALID_VALUE, "Unqueueing %d buffers", nb); - if(nb <= 0) [[unlikely]] return; + if(nb <= 0) UNLIKELY return; std::lock_guard<std::mutex> _{context->mSourceLock}; ALsource *source{LookupSource(context.get(),src)}; - if(!source) [[unlikely]] + if(!source) UNLIKELY return context->setError(AL_INVALID_NAME, "Invalid source ID %u", src); - if(source->SourceType != AL_STREAMING) [[unlikely]] + if(source->SourceType != AL_STREAMING) UNLIKELY return context->setError(AL_INVALID_VALUE, "Unqueueing from a non-streaming source %u", src); - if(source->Looping) [[unlikely]] + if(source->Looping) UNLIKELY return context->setError(AL_INVALID_VALUE, "Unqueueing from looping source %u", src); /* Make sure enough buffers have been processed to unqueue. */ uint processed{0u}; - if(source->state != AL_INITIAL) [[likely]] + if(source->state != AL_INITIAL) LIKELY { VoiceBufferItem *Current{nullptr}; if(Voice *voice{GetSourceVoice(source, context.get())}) @@ -3704,7 +3704,7 @@ START_API_FUNC ++processed; } } - if(processed < static_cast<ALuint>(nb)) [[unlikely]] + if(processed < static_cast<ALuint>(nb)) UNLIKELY return context->setError(AL_INVALID_VALUE, "Unqueueing %d buffer%s (only %u processed)", nb, (nb==1)?"":"s", processed); @@ -3727,7 +3727,7 @@ AL_API void AL_APIENTRY alSourceQueueBufferLayersSOFT(ALuint, ALsizei, const ALu START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; context->setError(AL_INVALID_OPERATION, "alSourceQueueBufferLayersSOFT not supported"); } diff --git a/al/state.cpp b/al/state.cpp index 11202374..86d81b13 100644 --- a/al/state.cpp +++ b/al/state.cpp @@ -158,7 +158,7 @@ AL_API void AL_APIENTRY alEnable(ALenum capability) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; switch(capability) { @@ -184,7 +184,7 @@ AL_API void AL_APIENTRY alDisable(ALenum capability) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; switch(capability) { @@ -210,7 +210,7 @@ AL_API ALboolean AL_APIENTRY alIsEnabled(ALenum capability) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return AL_FALSE; + if(!context) UNLIKELY return AL_FALSE; std::lock_guard<std::mutex> _{context->mPropLock}; ALboolean value{AL_FALSE}; @@ -236,7 +236,7 @@ AL_API ALboolean AL_APIENTRY alGetBoolean(ALenum pname) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return AL_FALSE; + if(!context) UNLIKELY return AL_FALSE; std::lock_guard<std::mutex> _{context->mPropLock}; ALboolean value{AL_FALSE}; @@ -293,7 +293,7 @@ AL_API ALdouble AL_APIENTRY alGetDouble(ALenum pname) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return 0.0; + if(!context) UNLIKELY return 0.0; std::lock_guard<std::mutex> _{context->mPropLock}; ALdouble value{0.0}; @@ -344,7 +344,7 @@ AL_API ALfloat AL_APIENTRY alGetFloat(ALenum pname) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return 0.0f; + if(!context) UNLIKELY return 0.0f; std::lock_guard<std::mutex> _{context->mPropLock}; ALfloat value{0.0f}; @@ -395,7 +395,7 @@ AL_API ALint AL_APIENTRY alGetInteger(ALenum pname) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return 0; + if(!context) UNLIKELY return 0; std::lock_guard<std::mutex> _{context->mPropLock}; ALint value{0}; @@ -481,7 +481,7 @@ AL_API ALint64SOFT AL_APIENTRY alGetInteger64SOFT(ALenum pname) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return 0_i64; + if(!context) UNLIKELY return 0_i64; std::lock_guard<std::mutex> _{context->mPropLock}; ALint64SOFT value{0}; @@ -532,7 +532,7 @@ AL_API ALvoid* AL_APIENTRY alGetPointerSOFT(ALenum pname) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return nullptr; + if(!context) UNLIKELY return nullptr; std::lock_guard<std::mutex> _{context->mPropLock}; void *value{nullptr}; @@ -575,7 +575,7 @@ START_API_FUNC } ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; if(!values) context->setError(AL_INVALID_VALUE, "NULL pointer"); @@ -608,7 +608,7 @@ START_API_FUNC } ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; if(!values) context->setError(AL_INVALID_VALUE, "NULL pointer"); @@ -641,7 +641,7 @@ START_API_FUNC } ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; if(!values) context->setError(AL_INVALID_VALUE, "NULL pointer"); @@ -674,7 +674,7 @@ START_API_FUNC } ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; if(!values) context->setError(AL_INVALID_VALUE, "NULL pointer"); @@ -707,7 +707,7 @@ START_API_FUNC } ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; if(!values) context->setError(AL_INVALID_VALUE, "NULL pointer"); @@ -734,7 +734,7 @@ START_API_FUNC } ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; if(!values) context->setError(AL_INVALID_VALUE, "NULL pointer"); @@ -750,7 +750,7 @@ AL_API const ALchar* AL_APIENTRY alGetString(ALenum pname) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return nullptr; + if(!context) UNLIKELY return nullptr; const ALchar *value{nullptr}; switch(pname) @@ -806,7 +806,7 @@ AL_API void AL_APIENTRY alDopplerFactor(ALfloat value) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; if(!(value >= 0.0f && std::isfinite(value))) context->setError(AL_INVALID_VALUE, "Doppler factor %f out of range", value); @@ -823,7 +823,7 @@ AL_API void AL_APIENTRY alDopplerVelocity(ALfloat value) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; if(!(value >= 0.0f && std::isfinite(value))) context->setError(AL_INVALID_VALUE, "Doppler velocity %f out of range", value); @@ -840,7 +840,7 @@ AL_API void AL_APIENTRY alSpeedOfSound(ALfloat value) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; if(!(value > 0.0f && std::isfinite(value))) context->setError(AL_INVALID_VALUE, "Speed of sound %f out of range", value); @@ -857,7 +857,7 @@ AL_API void AL_APIENTRY alDistanceModel(ALenum value) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; if(auto model = DistanceModelFromALenum(value)) { @@ -876,7 +876,7 @@ AL_API void AL_APIENTRY alDeferUpdatesSOFT(void) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mPropLock}; context->deferUpdates(); @@ -887,7 +887,7 @@ AL_API void AL_APIENTRY alProcessUpdatesSOFT(void) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return; + if(!context) UNLIKELY return; std::lock_guard<std::mutex> _{context->mPropLock}; context->processUpdates(); @@ -899,7 +899,7 @@ AL_API const ALchar* AL_APIENTRY alGetStringiSOFT(ALenum pname, ALsizei index) START_API_FUNC { ContextRef context{GetContextRef()}; - if(!context) [[unlikely]] return nullptr; + if(!context) UNLIKELY return nullptr; const ALchar *value{nullptr}; switch(pname) |