aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--al/auxeffectslot.cpp112
-rw-r--r--al/buffer.cpp248
-rw-r--r--al/effect.cpp58
-rw-r--r--al/error.cpp2
-rw-r--r--al/event.cpp6
-rw-r--r--al/extension.cpp4
-rw-r--r--al/filter.cpp58
-rw-r--r--al/listener.cpp28
-rw-r--r--al/source.cpp272
-rw-r--r--al/state.cpp46
-rw-r--r--alc/alc.cpp6
-rw-r--r--alc/alu.cpp12
-rw-r--r--alc/backends/jack.cpp4
-rw-r--r--alc/backends/opensl.cpp97
-rw-r--r--alc/backends/pipewire.cpp14
-rw-r--r--alc/backends/pulseaudio.cpp24
-rw-r--r--alc/effects/convolution.cpp4
-rw-r--r--common/alcomplex.cpp2
-rw-r--r--common/alnumeric.h10
-rw-r--r--common/comptr.h2
-rw-r--r--common/intrusive_ptr.h4
-rw-r--r--common/opthelpers.h11
-rw-r--r--common/polyphase_resampler.cpp16
-rw-r--r--core/ambdec.cpp2
-rw-r--r--core/converter.cpp2
-rw-r--r--core/device.h2
-rw-r--r--core/except.cpp2
-rw-r--r--core/logging.cpp2
-rw-r--r--core/logging.h6
-rw-r--r--core/mastering.cpp2
-rw-r--r--core/mixer/hrtfbase.h4
-rw-r--r--core/uhjfilter.cpp22
-rw-r--r--core/voice.cpp20
33 files changed, 558 insertions, 546 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)
diff --git a/alc/alc.cpp b/alc/alc.cpp
index fa230882..1a4a89ad 100644
--- a/alc/alc.cpp
+++ b/alc/alc.cpp
@@ -2472,7 +2472,7 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
bool ResetDeviceParams(ALCdevice *device, const int *attrList)
{
/* If the device was disconnected, reset it since we're opened anew. */
- if(!device->Connected.load(std::memory_order_relaxed)) [[unlikely]]
+ if(!device->Connected.load(std::memory_order_relaxed)) UNLIKELY
{
/* Make sure disconnection is finished before continuing on. */
device->waitForMix();
@@ -2504,7 +2504,7 @@ bool ResetDeviceParams(ALCdevice *device, const int *attrList)
}
ALCenum err{UpdateDeviceParams(device, attrList)};
- if(err == ALC_NO_ERROR) [[likely]] return ALC_TRUE;
+ if(err == ALC_NO_ERROR) LIKELY return ALC_TRUE;
alcSetError(device, err);
return ALC_FALSE;
@@ -2556,7 +2556,7 @@ ContextRef GetContextRef(void)
*/
}
context = ALCcontext::sGlobalContext.load(std::memory_order_acquire);
- if(context) [[likely]] context->add_ref();
+ if(context) LIKELY context->add_ref();
ALCcontext::sGlobalContextLock.store(false, std::memory_order_release);
}
return ContextRef{context};
diff --git a/alc/alu.cpp b/alc/alu.cpp
index 7af21245..a5230580 100644
--- a/alc/alu.cpp
+++ b/alc/alu.cpp
@@ -488,7 +488,7 @@ bool CalcEffectSlotParams(EffectSlot *slot, EffectSlot **sorted_slots, ContextBa
/* Otherwise, if it would be deleted send it off with a release event. */
RingBuffer *ring{context->mAsyncEvents.get()};
auto evt_vec = ring->getWriteVector();
- if(evt_vec.first.len > 0) [[likely]]
+ if(evt_vec.first.len > 0) LIKELY
{
AsyncEvent *evt{al::construct_at(reinterpret_cast<AsyncEvent*>(evt_vec.first.buf),
AsyncEvent::ReleaseEffectState)};
@@ -1531,7 +1531,7 @@ void CalcAttnSourceParams(Voice *voice, const VoiceProps *props, const ContextBa
}
/* Distance-based air absorption and initial send decay. */
- if(Distance > props->RefDistance) [[likely]]
+ if(Distance > props->RefDistance) LIKELY
{
const float distance_base{(Distance-props->RefDistance) * props->RolloffFactor};
const float distance_meters{distance_base * context->mParams.MetersPerUnit};
@@ -1826,7 +1826,7 @@ void ProcessParamUpdates(ContextBase *ctx, const EffectSlotArray &slots,
ProcessVoiceChanges(ctx);
IncrementRef(ctx->mUpdateCount);
- if(!ctx->mHoldUpdates.load(std::memory_order_acquire)) [[likely]]
+ if(!ctx->mHoldUpdates.load(std::memory_order_acquire)) LIKELY
{
bool force{CalcContextParams(ctx)};
auto sorted_slots = const_cast<EffectSlot**>(slots.data() + slots.size());
@@ -1918,7 +1918,7 @@ void ProcessContexts(DeviceBase *device, const uint SamplesToDo)
* left that don't target any sorted slots, they can't
* contribute to the output, so leave them.
*/
- if(next_target == split_point) [[unlikely]]
+ if(next_target == split_point) UNLIKELY
break;
--next_target;
@@ -1961,7 +1961,7 @@ void ApplyDistanceComp(const al::span<FloatBufferLine> Samples, const size_t Sam
float *inout{al::assume_aligned<16>(chanbuffer.data())};
auto inout_end = inout + SamplesToDo;
- if(SamplesToDo >= base) [[likely]]
+ if(SamplesToDo >= base) LIKELY
{
auto delay_end = std::rotate(inout, inout_end - base, inout_end);
std::swap_ranges(inout, delay_end, distbuf);
@@ -2136,7 +2136,7 @@ void DeviceBase::renderSamples(void *outBuffer, const uint numSamples, const siz
{
const uint samplesToDo{renderSamples(todo)};
- if(outBuffer) [[likely]]
+ if(outBuffer) LIKELY
{
/* Finally, interleave and convert samples, writing to the device's
* output buffer.
diff --git a/alc/backends/jack.cpp b/alc/backends/jack.cpp
index 95796862..791002ca 100644
--- a/alc/backends/jack.cpp
+++ b/alc/backends/jack.cpp
@@ -345,7 +345,7 @@ int JackPlayback::processRt(jack_nframes_t numframes) noexcept
out[numchans++] = static_cast<float*>(jack_port_get_buffer(port, numframes));
}
- if(mPlaying.load(std::memory_order_acquire)) [[likely]]
+ if(mPlaying.load(std::memory_order_acquire)) LIKELY
mDevice->renderSamples({out.data(), numchans}, static_cast<uint>(numframes));
else
{
@@ -369,7 +369,7 @@ int JackPlayback::process(jack_nframes_t numframes) noexcept
}
jack_nframes_t total{0};
- if(mPlaying.load(std::memory_order_acquire)) [[likely]]
+ if(mPlaying.load(std::memory_order_acquire)) LIKELY
{
auto data = mRing->getReadVector();
jack_nframes_t todo{minu(numframes, static_cast<uint>(data.first.len))};
diff --git a/alc/backends/opensl.cpp b/alc/backends/opensl.cpp
index f46438ce..f5b98fb8 100644
--- a/alc/backends/opensl.cpp
+++ b/alc/backends/opensl.cpp
@@ -113,7 +113,7 @@ constexpr SLuint32 GetByteOrderEndianness() noexcept
return SL_BYTEORDER_BIGENDIAN;
}
-const char *res_str(SLresult result) noexcept
+constexpr const char *res_str(SLresult result) noexcept
{
switch(result)
{
@@ -147,10 +147,11 @@ const char *res_str(SLresult result) noexcept
return "Unknown error code";
}
-#define PRINTERR(x, s) do { \
- if((x) != SL_RESULT_SUCCESS) [[unlikely]] \
- ERR("%s: %s\n", (s), res_str((x))); \
-} while(0)
+inline void PrintErr(SLresult res, const char *str)
+{
+ if(res != SL_RESULT_SUCCESS) UNLIKELY
+ ERR("%s: %s\n", str, res_str(res));
+}
struct OpenSLPlayback final : public BackendBase {
@@ -234,11 +235,11 @@ int OpenSLPlayback::mixerProc()
SLAndroidSimpleBufferQueueItf bufferQueue;
SLresult result{VCALL(mBufferQueueObj,GetInterface)(SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
&bufferQueue)};
- PRINTERR(result, "bufferQueue->GetInterface SL_IID_ANDROIDSIMPLEBUFFERQUEUE");
+ PrintErr(result, "bufferQueue->GetInterface SL_IID_ANDROIDSIMPLEBUFFERQUEUE");
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(mBufferQueueObj,GetInterface)(SL_IID_PLAY, &player);
- PRINTERR(result, "bufferQueue->GetInterface SL_IID_PLAY");
+ PrintErr(result, "bufferQueue->GetInterface SL_IID_PLAY");
}
const size_t frame_step{mDevice->channelsFromFmt()};
@@ -254,11 +255,11 @@ int OpenSLPlayback::mixerProc()
SLuint32 state{0};
result = VCALL(player,GetPlayState)(&state);
- PRINTERR(result, "player->GetPlayState");
+ PrintErr(result, "player->GetPlayState");
if(SL_RESULT_SUCCESS == result && state != SL_PLAYSTATE_PLAYING)
{
result = VCALL(player,SetPlayState)(SL_PLAYSTATE_PLAYING);
- PRINTERR(result, "player->SetPlayState");
+ PrintErr(result, "player->SetPlayState");
}
if(SL_RESULT_SUCCESS != result)
{
@@ -295,7 +296,7 @@ int OpenSLPlayback::mixerProc()
}
result = VCALL(bufferQueue,Enqueue)(data.first.buf, mDevice->UpdateSize*mFrameSize);
- PRINTERR(result, "bufferQueue->Enqueue");
+ PrintErr(result, "bufferQueue->Enqueue");
if(SL_RESULT_SUCCESS != result)
{
mDevice->handleDisconnect("Failed to queue audio: 0x%08x", result);
@@ -324,26 +325,26 @@ void OpenSLPlayback::open(const char *name)
// create engine
SLresult result{slCreateEngine(&mEngineObj, 0, nullptr, 0, nullptr, nullptr)};
- PRINTERR(result, "slCreateEngine");
+ PrintErr(result, "slCreateEngine");
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(mEngineObj,Realize)(SL_BOOLEAN_FALSE);
- PRINTERR(result, "engine->Realize");
+ PrintErr(result, "engine->Realize");
}
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(mEngineObj,GetInterface)(SL_IID_ENGINE, &mEngine);
- PRINTERR(result, "engine->GetInterface");
+ PrintErr(result, "engine->GetInterface");
}
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(mEngine,CreateOutputMix)(&mOutputMix, 0, nullptr, nullptr);
- PRINTERR(result, "engine->CreateOutputMix");
+ PrintErr(result, "engine->CreateOutputMix");
}
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(mOutputMix,Realize)(SL_BOOLEAN_FALSE);
- PRINTERR(result, "outputMix->Realize");
+ PrintErr(result, "outputMix->Realize");
}
if(SL_RESULT_SUCCESS != result)
@@ -511,20 +512,20 @@ bool OpenSLPlayback::reset()
result = VCALL(mEngine,CreateAudioPlayer)(&mBufferQueueObj, &audioSrc, &audioSnk, ids.size(),
ids.data(), reqs.data());
- PRINTERR(result, "engine->CreateAudioPlayer");
+ PrintErr(result, "engine->CreateAudioPlayer");
}
if(SL_RESULT_SUCCESS == result)
{
/* Set the stream type to "media" (games, music, etc), if possible. */
SLAndroidConfigurationItf config;
result = VCALL(mBufferQueueObj,GetInterface)(SL_IID_ANDROIDCONFIGURATION, &config);
- PRINTERR(result, "bufferQueue->GetInterface SL_IID_ANDROIDCONFIGURATION");
+ PrintErr(result, "bufferQueue->GetInterface SL_IID_ANDROIDCONFIGURATION");
if(SL_RESULT_SUCCESS == result)
{
SLint32 streamType = SL_ANDROID_STREAM_MEDIA;
result = VCALL(config,SetConfiguration)(SL_ANDROID_KEY_STREAM_TYPE, &streamType,
sizeof(streamType));
- PRINTERR(result, "config->SetConfiguration");
+ PrintErr(result, "config->SetConfiguration");
}
/* Clear any error since this was optional. */
@@ -533,7 +534,7 @@ bool OpenSLPlayback::reset()
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(mBufferQueueObj,Realize)(SL_BOOLEAN_FALSE);
- PRINTERR(result, "bufferQueue->Realize");
+ PrintErr(result, "bufferQueue->Realize");
}
if(SL_RESULT_SUCCESS == result)
{
@@ -560,11 +561,11 @@ void OpenSLPlayback::start()
SLAndroidSimpleBufferQueueItf bufferQueue;
SLresult result{VCALL(mBufferQueueObj,GetInterface)(SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
&bufferQueue)};
- PRINTERR(result, "bufferQueue->GetInterface");
+ PrintErr(result, "bufferQueue->GetInterface");
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(bufferQueue,RegisterCallback)(&OpenSLPlayback::processC, this);
- PRINTERR(result, "bufferQueue->RegisterCallback");
+ PrintErr(result, "bufferQueue->RegisterCallback");
}
if(SL_RESULT_SUCCESS != result)
throw al::backend_exception{al::backend_error::DeviceError,
@@ -590,25 +591,25 @@ void OpenSLPlayback::stop()
SLPlayItf player;
SLresult result{VCALL(mBufferQueueObj,GetInterface)(SL_IID_PLAY, &player)};
- PRINTERR(result, "bufferQueue->GetInterface");
+ PrintErr(result, "bufferQueue->GetInterface");
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(player,SetPlayState)(SL_PLAYSTATE_STOPPED);
- PRINTERR(result, "player->SetPlayState");
+ PrintErr(result, "player->SetPlayState");
}
SLAndroidSimpleBufferQueueItf bufferQueue;
result = VCALL(mBufferQueueObj,GetInterface)(SL_IID_ANDROIDSIMPLEBUFFERQUEUE, &bufferQueue);
- PRINTERR(result, "bufferQueue->GetInterface");
+ PrintErr(result, "bufferQueue->GetInterface");
if(SL_RESULT_SUCCESS == result)
{
result = VCALL0(bufferQueue,Clear)();
- PRINTERR(result, "bufferQueue->Clear");
+ PrintErr(result, "bufferQueue->Clear");
}
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(bufferQueue,RegisterCallback)(nullptr, nullptr);
- PRINTERR(result, "bufferQueue->RegisterCallback");
+ PrintErr(result, "bufferQueue->RegisterCallback");
}
if(SL_RESULT_SUCCESS == result)
{
@@ -617,7 +618,7 @@ void OpenSLPlayback::stop()
std::this_thread::yield();
result = VCALL(bufferQueue,GetState)(&state);
} while(SL_RESULT_SUCCESS == result && state.count > 0);
- PRINTERR(result, "bufferQueue->GetState");
+ PrintErr(result, "bufferQueue->GetState");
mRing->reset();
}
@@ -694,16 +695,16 @@ void OpenSLCapture::open(const char* name)
name};
SLresult result{slCreateEngine(&mEngineObj, 0, nullptr, 0, nullptr, nullptr)};
- PRINTERR(result, "slCreateEngine");
+ PrintErr(result, "slCreateEngine");
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(mEngineObj,Realize)(SL_BOOLEAN_FALSE);
- PRINTERR(result, "engine->Realize");
+ PrintErr(result, "engine->Realize");
}
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(mEngineObj,GetInterface)(SL_IID_ENGINE, &mEngine);
- PRINTERR(result, "engine->GetInterface");
+ PrintErr(result, "engine->GetInterface");
}
if(SL_RESULT_SUCCESS == result)
{
@@ -778,7 +779,7 @@ void OpenSLCapture::open(const char* name)
result = VCALL(mEngine,CreateAudioRecorder)(&mRecordObj, &audioSrc, &audioSnk,
ids.size(), ids.data(), reqs.data());
}
- PRINTERR(result, "engine->CreateAudioRecorder");
+ PrintErr(result, "engine->CreateAudioRecorder");
}
}
if(SL_RESULT_SUCCESS == result)
@@ -786,13 +787,13 @@ void OpenSLCapture::open(const char* name)
/* Set the record preset to "generic", if possible. */
SLAndroidConfigurationItf config;
result = VCALL(mRecordObj,GetInterface)(SL_IID_ANDROIDCONFIGURATION, &config);
- PRINTERR(result, "recordObj->GetInterface SL_IID_ANDROIDCONFIGURATION");
+ PrintErr(result, "recordObj->GetInterface SL_IID_ANDROIDCONFIGURATION");
if(SL_RESULT_SUCCESS == result)
{
SLuint32 preset = SL_ANDROID_RECORDING_PRESET_GENERIC;
result = VCALL(config,SetConfiguration)(SL_ANDROID_KEY_RECORDING_PRESET, &preset,
sizeof(preset));
- PRINTERR(result, "config->SetConfiguration");
+ PrintErr(result, "config->SetConfiguration");
}
/* Clear any error since this was optional. */
@@ -801,19 +802,19 @@ void OpenSLCapture::open(const char* name)
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(mRecordObj,Realize)(SL_BOOLEAN_FALSE);
- PRINTERR(result, "recordObj->Realize");
+ PrintErr(result, "recordObj->Realize");
}
SLAndroidSimpleBufferQueueItf bufferQueue;
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(mRecordObj,GetInterface)(SL_IID_ANDROIDSIMPLEBUFFERQUEUE, &bufferQueue);
- PRINTERR(result, "recordObj->GetInterface");
+ PrintErr(result, "recordObj->GetInterface");
}
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(bufferQueue,RegisterCallback)(&OpenSLCapture::processC, this);
- PRINTERR(result, "bufferQueue->RegisterCallback");
+ PrintErr(result, "bufferQueue->RegisterCallback");
}
if(SL_RESULT_SUCCESS == result)
{
@@ -826,12 +827,12 @@ void OpenSLCapture::open(const char* name)
for(size_t i{0u};i < data.first.len && SL_RESULT_SUCCESS == result;i++)
{
result = VCALL(bufferQueue,Enqueue)(data.first.buf + chunk_size*i, chunk_size);
- PRINTERR(result, "bufferQueue->Enqueue");
+ PrintErr(result, "bufferQueue->Enqueue");
}
for(size_t i{0u};i < data.second.len && SL_RESULT_SUCCESS == result;i++)
{
result = VCALL(bufferQueue,Enqueue)(data.second.buf + chunk_size*i, chunk_size);
- PRINTERR(result, "bufferQueue->Enqueue");
+ PrintErr(result, "bufferQueue->Enqueue");
}
}
@@ -857,12 +858,12 @@ void OpenSLCapture::start()
{
SLRecordItf record;
SLresult result{VCALL(mRecordObj,GetInterface)(SL_IID_RECORD, &record)};
- PRINTERR(result, "recordObj->GetInterface");
+ PrintErr(result, "recordObj->GetInterface");
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(record,SetRecordState)(SL_RECORDSTATE_RECORDING);
- PRINTERR(result, "record->SetRecordState");
+ PrintErr(result, "record->SetRecordState");
}
if(SL_RESULT_SUCCESS != result)
throw al::backend_exception{al::backend_error::DeviceError,
@@ -873,12 +874,12 @@ void OpenSLCapture::stop()
{
SLRecordItf record;
SLresult result{VCALL(mRecordObj,GetInterface)(SL_IID_RECORD, &record)};
- PRINTERR(result, "recordObj->GetInterface");
+ PrintErr(result, "recordObj->GetInterface");
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(record,SetRecordState)(SL_RECORDSTATE_PAUSED);
- PRINTERR(result, "record->SetRecordState");
+ PrintErr(result, "record->SetRecordState");
}
}
@@ -916,12 +917,12 @@ void OpenSLCapture::captureSamples(al::byte *buffer, uint samples)
}
SLAndroidSimpleBufferQueueItf bufferQueue{};
- if(mDevice->Connected.load(std::memory_order_acquire)) [[likely]]
+ if(mDevice->Connected.load(std::memory_order_acquire)) LIKELY
{
const SLresult result{VCALL(mRecordObj,GetInterface)(SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
&bufferQueue)};
- PRINTERR(result, "recordObj->GetInterface");
- if(SL_RESULT_SUCCESS != result) [[unlikely]]
+ PrintErr(result, "recordObj->GetInterface");
+ if(SL_RESULT_SUCCESS != result) UNLIKELY
{
mDevice->handleDisconnect("Failed to get capture buffer queue: 0x%08x", result);
bufferQueue = nullptr;
@@ -942,14 +943,14 @@ void OpenSLCapture::captureSamples(al::byte *buffer, uint samples)
SLresult result{SL_RESULT_SUCCESS};
auto wdata = mRing->getWriteVector();
- if(adv_count > wdata.second.len) [[likely]]
+ if(adv_count > wdata.second.len) LIKELY
{
auto len1 = std::min(wdata.first.len, adv_count-wdata.second.len);
auto buf1 = wdata.first.buf + chunk_size*(wdata.first.len-len1);
for(size_t i{0u};i < len1 && SL_RESULT_SUCCESS == result;i++)
{
result = VCALL(bufferQueue,Enqueue)(buf1 + chunk_size*i, chunk_size);
- PRINTERR(result, "bufferQueue->Enqueue");
+ PrintErr(result, "bufferQueue->Enqueue");
}
}
if(wdata.second.len > 0)
@@ -959,7 +960,7 @@ void OpenSLCapture::captureSamples(al::byte *buffer, uint samples)
for(size_t i{0u};i < len2 && SL_RESULT_SUCCESS == result;i++)
{
result = VCALL(bufferQueue,Enqueue)(buf2 + chunk_size*i, chunk_size);
- PRINTERR(result, "bufferQueue->Enqueue");
+ PrintErr(result, "bufferQueue->Enqueue");
}
}
}
diff --git a/alc/backends/pipewire.cpp b/alc/backends/pipewire.cpp
index 7bde4b78..c6569a74 100644
--- a/alc/backends/pipewire.cpp
+++ b/alc/backends/pipewire.cpp
@@ -477,7 +477,7 @@ struct EventManager {
*/
void waitForInit()
{
- if(!mInitDone.load(std::memory_order_acquire)) [[unlikely]]
+ if(!mInitDone.load(std::memory_order_acquire)) UNLIKELY
{
MainloopUniqueLock plock{mLoop};
plock.wait([this](){ return mInitDone.load(std::memory_order_acquire); });
@@ -862,7 +862,7 @@ void NodeProxy::infoCallback(const pw_node_info *info)
{
/* Can this actually change? */
const char *media_class{spa_dict_lookup(info->props, PW_KEY_MEDIA_CLASS)};
- if(!media_class) [[unlikely]] return;
+ if(!media_class) UNLIKELY return;
NodeType ntype{};
if(al::strcasecmp(media_class, AudioSinkClass) == 0)
@@ -919,7 +919,7 @@ void NodeProxy::paramCallback(int, uint32_t id, uint32_t, uint32_t, const spa_po
if(id == SPA_PARAM_EnumFormat)
{
DeviceNode *node{DeviceNode::Find(mId)};
- if(!node) [[unlikely]] return;
+ if(!node) UNLIKELY return;
if(const spa_pod_prop *prop{spa_pod_find_prop(param, nullptr, SPA_FORMAT_AUDIO_rate)})
node->parseSampleRate(&prop->value);
@@ -1344,7 +1344,7 @@ void PipeWirePlayback::ioChangedCallback(uint32_t id, void *area, uint32_t size)
void PipeWirePlayback::outputCallback()
{
pw_buffer *pw_buf{pw_stream_dequeue_buffer(mStream.get())};
- if(!pw_buf) [[unlikely]] return;
+ if(!pw_buf) UNLIKELY return;
const al::span<spa_data> datas{pw_buf->buffer->datas,
minu(mNumChannels, pw_buf->buffer->n_datas)};
@@ -1360,7 +1360,7 @@ void PipeWirePlayback::outputCallback()
uint length{mRateMatch ? mRateMatch->size : 0u};
#endif
/* If no length is specified, use the device's update size as a fallback. */
- if(!length) [[unlikely]] length = mDevice->UpdateSize;
+ if(!length) UNLIKELY length = mDevice->UpdateSize;
/* For planar formats, each datas[] seems to contain one channel, so store
* the pointers in an array. Limit the render length in case the available
@@ -1729,7 +1729,7 @@ ClockLatency PipeWirePlayback::getClockLatency()
*/
nanoseconds monoclock{seconds{tspec.tv_sec} + nanoseconds{tspec.tv_nsec}};
nanoseconds curtic{}, delay{};
- if(ptime.rate.denom < 1) [[unlikely]]
+ if(ptime.rate.denom < 1) UNLIKELY
{
/* If there's no stream rate, the stream hasn't had a chance to get
* going and return time info yet. Just use dummy values.
@@ -1827,7 +1827,7 @@ void PipeWireCapture::stateChangedCallback(pw_stream_state, pw_stream_state, con
void PipeWireCapture::inputCallback()
{
pw_buffer *pw_buf{pw_stream_dequeue_buffer(mStream.get())};
- if(!pw_buf) [[unlikely]] return;
+ if(!pw_buf) UNLIKELY return;
spa_data *bufdata{pw_buf->buffer->datas};
const uint offset{minu(bufdata->chunk->offset, bufdata->maxsize)};
diff --git a/alc/backends/pulseaudio.cpp b/alc/backends/pulseaudio.cpp
index 9b7e2c08..4b0e316f 100644
--- a/alc/backends/pulseaudio.cpp
+++ b/alc/backends/pulseaudio.cpp
@@ -667,7 +667,7 @@ void PulsePlayback::streamWriteCallback(pa_stream *stream, size_t nbytes) noexce
pa_free_cb_t free_func{nullptr};
auto buflen = static_cast<size_t>(-1);
void *buf{};
- if(pa_stream_begin_write(stream, &buf, &buflen) || !buf) [[unlikely]]
+ if(pa_stream_begin_write(stream, &buf, &buflen) || !buf) UNLIKELY
{
buflen = nbytes;
buf = pa_xmalloc(buflen);
@@ -680,7 +680,7 @@ void PulsePlayback::streamWriteCallback(pa_stream *stream, size_t nbytes) noexce
mDevice->renderSamples(buf, static_cast<uint>(buflen/mFrameSize), mSpec.channels);
int ret{pa_stream_write(stream, buf, buflen, free_func, 0, PA_SEEK_RELATIVE)};
- if(ret != PA_OK) [[unlikely]]
+ if(ret != PA_OK) UNLIKELY
ERR("Failed to write to stream: %d, %s\n", ret, pa_strerror(ret));
} while(nbytes > 0);
}
@@ -1006,7 +1006,7 @@ ClockLatency PulsePlayback::getClockLatency()
err = pa_stream_get_latency(mStream, &latency, &neg);
}
- if(err != 0) [[unlikely]]
+ if(err != 0) UNLIKELY
{
/* If err = -PA_ERR_NODATA, it means we were called too soon after
* starting the stream and no timing info has been received from the
@@ -1017,7 +1017,7 @@ ClockLatency PulsePlayback::getClockLatency()
latency = mDevice->BufferSize - mDevice->UpdateSize;
neg = 0;
}
- else if(neg) [[unlikely]]
+ else if(neg) UNLIKELY
latency = 0;
ret.Latency = std::chrono::microseconds{latency};
@@ -1240,7 +1240,7 @@ void PulseCapture::captureSamples(al::byte *buffer, uint samples)
mLastReadable -= static_cast<uint>(dstbuf.size());
while(!dstbuf.empty())
{
- if(mHoleLength > 0) [[unlikely]]
+ if(mHoleLength > 0) UNLIKELY
{
const size_t rem{minz(dstbuf.size(), mHoleLength)};
std::fill_n(dstbuf.begin(), rem, mSilentVal);
@@ -1259,7 +1259,7 @@ void PulseCapture::captureSamples(al::byte *buffer, uint samples)
continue;
}
- if(!mDevice->Connected.load(std::memory_order_acquire)) [[unlikely]]
+ if(!mDevice->Connected.load(std::memory_order_acquire)) UNLIKELY
break;
MainloopUniqueLock plock{mMainloop};
@@ -1270,7 +1270,7 @@ void PulseCapture::captureSamples(al::byte *buffer, uint samples)
}
const pa_stream_state_t state{pa_stream_get_state(mStream)};
- if(!PA_STREAM_IS_GOOD(state)) [[unlikely]]
+ if(!PA_STREAM_IS_GOOD(state)) UNLIKELY
{
mDevice->handleDisconnect("Bad capture state: %u", state);
break;
@@ -1278,7 +1278,7 @@ void PulseCapture::captureSamples(al::byte *buffer, uint samples)
const void *capbuf;
size_t caplen;
- if(pa_stream_peek(mStream, &capbuf, &caplen) < 0) [[unlikely]]
+ if(pa_stream_peek(mStream, &capbuf, &caplen) < 0) UNLIKELY
{
mDevice->handleDisconnect("Failed retrieving capture samples: %s",
pa_strerror(pa_context_errno(mContext)));
@@ -1287,7 +1287,7 @@ void PulseCapture::captureSamples(al::byte *buffer, uint samples)
plock.unlock();
if(caplen == 0) break;
- if(!capbuf) [[unlikely]]
+ if(!capbuf) UNLIKELY
mHoleLength = caplen;
else
mCapBuffer = {static_cast<const al::byte*>(capbuf), caplen};
@@ -1305,7 +1305,7 @@ uint PulseCapture::availableSamples()
{
MainloopUniqueLock plock{mMainloop};
size_t got{pa_stream_readable_size(mStream)};
- if(static_cast<ssize_t>(got) < 0) [[unlikely]]
+ if(static_cast<ssize_t>(got) < 0) UNLIKELY
{
const char *err{pa_strerror(static_cast<int>(got))};
ERR("pa_stream_readable_size() failed: %s\n", err);
@@ -1342,13 +1342,13 @@ ClockLatency PulseCapture::getClockLatency()
err = pa_stream_get_latency(mStream, &latency, &neg);
}
- if(err != 0) [[unlikely]]
+ if(err != 0) UNLIKELY
{
ERR("Failed to get stream latency: 0x%x\n", err);
latency = 0;
neg = 0;
}
- else if(neg) [[unlikely]]
+ else if(neg) UNLIKELY
latency = 0;
ret.Latency = std::chrono::microseconds{latency};
diff --git a/alc/effects/convolution.cpp b/alc/effects/convolution.cpp
index 92b70323..e526e009 100644
--- a/alc/effects/convolution.cpp
+++ b/alc/effects/convolution.cpp
@@ -420,7 +420,7 @@ void ConvolutionState::update(const ContextBase *context, const EffectSlot *slot
{ SideRight, Deg2Rad( 90.0f), Deg2Rad(0.0f) }
};
- if(mNumConvolveSegs < 1) [[unlikely]]
+ if(mNumConvolveSegs < 1) UNLIKELY
return;
mMix = &ConvolutionState::NormalMix;
@@ -524,7 +524,7 @@ void ConvolutionState::update(const ContextBase *context, const EffectSlot *slot
void ConvolutionState::process(const size_t samplesToDo,
const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut)
{
- if(mNumConvolveSegs < 1) [[unlikely]]
+ if(mNumConvolveSegs < 1) UNLIKELY
return;
constexpr size_t m{ConvolveUpdateSize/2 + 1};
diff --git a/common/alcomplex.cpp b/common/alcomplex.cpp
index 6fbf13cb..4420a1bb 100644
--- a/common/alcomplex.cpp
+++ b/common/alcomplex.cpp
@@ -101,7 +101,7 @@ complex_fft(const al::span<std::complex<Real>> buffer, const al::type_identity_t
*/
const size_t log2_size{static_cast<size_t>(al::countr_zero(fftsize))};
- if(log2_size >= gBitReverses.size()) [[unlikely]]
+ if(log2_size >= gBitReverses.size()) UNLIKELY
{
for(size_t idx{1u};idx < fftsize-1;++idx)
{
diff --git a/common/alnumeric.h b/common/alnumeric.h
index a426763f..d6919e40 100644
--- a/common/alnumeric.h
+++ b/common/alnumeric.h
@@ -170,11 +170,11 @@ inline int float2int(float f) noexcept
shift = ((conv.i>>23)&0xff) - (127+23);
/* Over/underflow */
- if(shift >= 31 || shift < -23) [[unlikely]]
+ if(shift >= 31 || shift < -23) UNLIKELY
return 0;
mant = (conv.i&0x7fffff) | 0x800000;
- if(shift < 0) [[likely]]
+ if(shift < 0) LIKELY
return (mant >> -shift) * sign;
return (mant << shift) * sign;
@@ -207,11 +207,11 @@ inline int double2int(double d) noexcept
shift = ((conv.i64 >> 52) & 0x7ff) - (1023 + 52);
/* Over/underflow */
- if(shift >= 63 || shift < -52) [[unlikely]]
+ if(shift >= 63 || shift < -52) UNLIKELY
return 0;
mant = (conv.i64 & 0xfffffffffffff_i64) | 0x10000000000000_i64;
- if(shift < 0) [[likely]]
+ if(shift < 0) LIKELY
return (int)(mant >> -shift) * sign;
return (int)(mant << shift) * sign;
@@ -260,7 +260,7 @@ inline float fast_roundf(float f) noexcept
sign = (conv.i>>31)&0x01;
expo = (conv.i>>23)&0xff;
- if(expo >= 150/*+23*/) [[unlikely]]
+ if(expo >= 150/*+23*/) UNLIKELY
{
/* An exponent (base-2) of 23 or higher is incapable of sub-integral
* precision, so it's already an integral value. We don't need to worry
diff --git a/common/comptr.h b/common/comptr.h
index f2355d05..cdc6dec0 100644
--- a/common/comptr.h
+++ b/common/comptr.h
@@ -44,7 +44,7 @@ public:
}
ComPtr& operator=(ComPtr&& rhs)
{
- if(&rhs != this) [[likely]]
+ if(&rhs != this) LIKELY
{
if(mPtr) mPtr->Release();
mPtr = std::exchange(rhs.mPtr, nullptr);
diff --git a/common/intrusive_ptr.h b/common/intrusive_ptr.h
index 84d18aa0..27075347 100644
--- a/common/intrusive_ptr.h
+++ b/common/intrusive_ptr.h
@@ -18,7 +18,7 @@ public:
unsigned int dec_ref() noexcept
{
auto ref = DecrementRef(mRef);
- if(ref == 0) [[unlikely]]
+ if(ref == 0) UNLIKELY
delete static_cast<T*>(this);
return ref;
}
@@ -71,7 +71,7 @@ public:
}
intrusive_ptr& operator=(intrusive_ptr&& rhs) noexcept
{
- if(&rhs != this) [[likely]]
+ if(&rhs != this) LIKELY
{
if(mPtr) mPtr->dec_ref();
mPtr = std::exchange(rhs.mPtr, nullptr);
diff --git a/common/opthelpers.h b/common/opthelpers.h
index 95ff781a..f1d9b74a 100644
--- a/common/opthelpers.h
+++ b/common/opthelpers.h
@@ -36,6 +36,17 @@
#define ASSUME(x) ((void)0)
#endif
+/* This shouldn't be needed since unknown attributes are ignored, but older
+ * versions of GCC choke on the attribute syntax in certain situations.
+ */
+#if !__has_attribute(likely)
+#define LIKELY
+#define UNLIKELY
+#else
+#define LIKELY [[likely]]
+#define UNLIKELY [[unlikely]]
+#endif
+
namespace al {
template<typename T>
diff --git a/common/polyphase_resampler.cpp b/common/polyphase_resampler.cpp
index 5475cff8..14f7e40d 100644
--- a/common/polyphase_resampler.cpp
+++ b/common/polyphase_resampler.cpp
@@ -21,7 +21,7 @@ using uint = unsigned int;
*/
double Sinc(const double x)
{
- if(std::abs(x) < Epsilon) [[unlikely]]
+ if(std::abs(x) < Epsilon) UNLIKELY
return 1.0;
return std::sin(al::numbers::pi*x) / (al::numbers::pi*x);
}
@@ -96,7 +96,7 @@ constexpr uint Gcd(uint x, uint y)
constexpr uint CalcKaiserOrder(const double rejection, const double transition)
{
const double w_t{2.0 * al::numbers::pi * transition};
- if(rejection > 21.0) [[likely]]
+ if(rejection > 21.0) LIKELY
return static_cast<uint>(std::ceil((rejection - 7.95) / (2.285 * w_t)));
return static_cast<uint>(std::ceil(5.79 / w_t));
}
@@ -104,7 +104,7 @@ constexpr uint CalcKaiserOrder(const double rejection, const double transition)
// Calculates the beta value of the Kaiser window. Rejection is in dB.
constexpr double CalcKaiserBeta(const double rejection)
{
- if(rejection > 50.0) [[likely]]
+ if(rejection > 50.0) LIKELY
return 0.1102 * (rejection - 8.7);
if(rejection >= 21.0)
return (0.5842 * std::pow(rejection - 21.0, 0.4)) +
@@ -171,13 +171,13 @@ void PPhaseResampler::init(const uint srcRate, const uint dstRate)
// polyphase filter implementation.
void PPhaseResampler::process(const uint inN, const double *in, const uint outN, double *out)
{
- if(outN == 0) [[unlikely]]
+ if(outN == 0) UNLIKELY
return;
// Handle in-place operation.
std::vector<double> workspace;
double *work{out};
- if(work == in) [[unlikely]]
+ if(work == in) UNLIKELY
{
workspace.resize(outN);
work = workspace.data();
@@ -195,17 +195,17 @@ void PPhaseResampler::process(const uint inN, const double *in, const uint outN,
// Only take input when 0 <= j_s < inN.
double r{0.0};
- if(j_f < m) [[likely]]
+ if(j_f < m) LIKELY
{
size_t filt_len{(m-j_f+p-1) / p};
- if(j_s+1 > inN) [[likely]]
+ if(j_s+1 > inN) LIKELY
{
size_t skip{std::min<size_t>(j_s+1 - inN, filt_len)};
j_f += p*skip;
j_s -= skip;
filt_len -= skip;
}
- if(size_t todo{std::min<size_t>(j_s+1, filt_len)}) [[likely]]
+ if(size_t todo{std::min<size_t>(j_s+1, filt_len)}) LIKELY
{
do {
r += f[j_f] * in[j_s];
diff --git a/core/ambdec.cpp b/core/ambdec.cpp
index 5e2de6af..8ca182c4 100644
--- a/core/ambdec.cpp
+++ b/core/ambdec.cpp
@@ -61,7 +61,7 @@ al::optional<std::string> make_error(size_t linenum, const char *fmt, ...)
va_start(args, fmt);
va_copy(args2, args);
const int msglen{std::vsnprintf(&str[plen], str.size()-plen, fmt, args)};
- if(msglen >= 0 && static_cast<size_t>(msglen) >= str.size()-plen) [[unlikely]]
+ if(msglen >= 0 && static_cast<size_t>(msglen) >= str.size()-plen)
{
str.resize(static_cast<size_t>(msglen) + plen + 1u);
std::vsnprintf(&str[plen], str.size()-plen, fmt, args2);
diff --git a/core/converter.cpp b/core/converter.cpp
index c69bada7..a5141448 100644
--- a/core/converter.cpp
+++ b/core/converter.cpp
@@ -140,7 +140,7 @@ void Multi2Mono(uint chanmask, const size_t step, const float scale, float *REST
std::fill_n(dst, frames, 0.0f);
for(size_t c{0};chanmask;++c)
{
- if((chanmask&1)) [[likely]]
+ if((chanmask&1)) LIKELY
{
for(size_t i{0u};i < frames;i++)
dst[i] += LoadSample<T>(ssrc[i*step + c]);
diff --git a/core/device.h b/core/device.h
index 32cf04c3..9aaf7adb 100644
--- a/core/device.h
+++ b/core/device.h
@@ -310,7 +310,7 @@ struct DeviceBase {
void ProcessBs2b(const size_t SamplesToDo);
inline void postProcess(const size_t SamplesToDo)
- { if(PostProcess) [[likely]] (this->*PostProcess)(SamplesToDo); }
+ { if(PostProcess) LIKELY (this->*PostProcess)(SamplesToDo); }
void renderSamples(const al::span<float*> outBuffers, const uint numSamples);
void renderSamples(void *outBuffer, const uint numSamples, const size_t frameStep);
diff --git a/core/except.cpp b/core/except.cpp
index ba4759a3..45fd4eb5 100644
--- a/core/except.cpp
+++ b/core/except.cpp
@@ -18,7 +18,7 @@ void base_exception::setMessage(const char* msg, std::va_list args)
std::va_list args2;
va_copy(args2, args);
int msglen{std::vsnprintf(nullptr, 0, msg, args)};
- if(msglen > 0) [[likely]]
+ if(msglen > 0) LIKELY
{
mMessage.resize(static_cast<size_t>(msglen)+1);
std::vsnprintf(const_cast<char*>(mMessage.data()), mMessage.length(), msg, args2);
diff --git a/core/logging.cpp b/core/logging.cpp
index ec53e5f6..34a95e5a 100644
--- a/core/logging.cpp
+++ b/core/logging.cpp
@@ -45,7 +45,7 @@ void al_print(LogLevel level, FILE *logfile, const char *fmt, ...)
va_start(args, fmt);
va_copy(args2, args);
const int msglen{std::vsnprintf(msg.data(), msg.size(), fmt, args)};
- if(msglen >= 0 && static_cast<size_t>(msglen) >= msg.size()) [[unlikely]]
+ if(msglen >= 0 && static_cast<size_t>(msglen) >= msg.size()) UNLIKELY
{
dynmsg.resize(static_cast<size_t>(msglen)+prefix.size() + 1u);
diff --git a/core/logging.h b/core/logging.h
index c729ef4e..f4b6ab56 100644
--- a/core/logging.h
+++ b/core/logging.h
@@ -25,17 +25,17 @@ void al_print(LogLevel level, FILE *logfile, const char *fmt, ...);
#if (!defined(_WIN32) || defined(NDEBUG)) && !defined(__ANDROID__)
#define TRACE(...) do { \
- if(gLogLevel >= LogLevel::Trace) [[unlikely]] \
+ if(gLogLevel >= LogLevel::Trace) UNLIKELY \
al_print(LogLevel::Trace, gLogFile, __VA_ARGS__); \
} while(0)
#define WARN(...) do { \
- if(gLogLevel >= LogLevel::Warning) [[unlikely]] \
+ if(gLogLevel >= LogLevel::Warning) UNLIKELY \
al_print(LogLevel::Warning, gLogFile, __VA_ARGS__); \
} while(0)
#define ERR(...) do { \
- if(gLogLevel >= LogLevel::Error) [[unlikely]] \
+ if(gLogLevel >= LogLevel::Error) UNLIKELY \
al_print(LogLevel::Error, gLogFile, __VA_ARGS__); \
} while(0)
diff --git a/core/mastering.cpp b/core/mastering.cpp
index cff162da..97a4008e 100644
--- a/core/mastering.cpp
+++ b/core/mastering.cpp
@@ -295,7 +295,7 @@ void SignalDelay(Compressor *Comp, const uint SamplesToDo, FloatBufferLine *OutB
float *delaybuf{al::assume_aligned<16>(Comp->mDelay[c].data())};
auto inout_end = inout + SamplesToDo;
- if(SamplesToDo >= lookAhead) [[likely]]
+ if(SamplesToDo >= lookAhead) LIKELY
{
auto delay_end = std::rotate(inout, inout_end - lookAhead, inout_end);
std::swap_ranges(inout, delay_end, delaybuf);
diff --git a/core/mixer/hrtfbase.h b/core/mixer/hrtfbase.h
index 656b9445..36f88e49 100644
--- a/core/mixer/hrtfbase.h
+++ b/core/mixer/hrtfbase.h
@@ -50,7 +50,7 @@ inline void MixHrtfBlendBase(const float *InSamples, float2 *RESTRICT AccumSampl
const ConstHrirSpan NewCoeffs{newparams->Coeffs};
const float newGainStep{newparams->GainStep};
- if(oldparams->Gain > GainSilenceThreshold) [[likely]]
+ if(oldparams->Gain > GainSilenceThreshold) LIKELY
{
size_t ldelay{HrtfHistoryLength - oldparams->Delay[0]};
size_t rdelay{HrtfHistoryLength - oldparams->Delay[1]};
@@ -66,7 +66,7 @@ inline void MixHrtfBlendBase(const float *InSamples, float2 *RESTRICT AccumSampl
}
}
- if(newGainStep*static_cast<float>(BufferSize) > GainSilenceThreshold) [[likely]]
+ if(newGainStep*static_cast<float>(BufferSize) > GainSilenceThreshold) LIKELY
{
size_t ldelay{HrtfHistoryLength+1 - newparams->Delay[0]};
size_t rdelay{HrtfHistoryLength+1 - newparams->Delay[1]};
diff --git a/core/uhjfilter.cpp b/core/uhjfilter.cpp
index d6a60271..df50956a 100644
--- a/core/uhjfilter.cpp
+++ b/core/uhjfilter.cpp
@@ -67,7 +67,7 @@ void UhjAllPassFilter::process(const al::span<const float,4> coeffs,
return x;
};
std::transform(src.begin(), src.end(), dst, proc_sample);
- if(updateState) [[likely]] mState = state;
+ if(updateState) LIKELY mState = state;
}
@@ -133,7 +133,7 @@ void UhjEncoder<N>::encode(float *LeftOut, float *RightOut,
float *inout{al::assume_aligned<16>(buffer)};
auto inout_end = inout + SamplesToDo;
- if(SamplesToDo >= sFilterDelay) [[likely]]
+ if(SamplesToDo >= sFilterDelay) LIKELY
{
auto delay_end = std::rotate(inout, inout_end - sFilterDelay, inout_end);
std::swap_ranges(inout, delay_end, distbuf);
@@ -270,7 +270,7 @@ void UhjDecoder<N>::decode(const al::span<float*> samples, const size_t samplesT
auto tmpiter = std::copy(mDTHistory.cbegin(), mDTHistory.cend(), mTemp.begin());
std::transform(mD.cbegin(), mD.cbegin()+samplesToDo+sInputPadding, mT.cbegin(), tmpiter,
[](const float d, const float t) noexcept { return 0.828331f*d + 0.767820f*t; });
- if(updateState) [[likely]]
+ if(updateState) LIKELY
std::copy_n(mTemp.cbegin()+samplesToDo, mDTHistory.size(), mDTHistory.begin());
PShift.process({xoutput, samplesToDo}, mTemp.data());
@@ -284,7 +284,7 @@ void UhjDecoder<N>::decode(const al::span<float*> samples, const size_t samplesT
/* Precompute j*S and store in youtput. */
tmpiter = std::copy(mSHistory.cbegin(), mSHistory.cend(), mTemp.begin());
std::copy_n(mS.cbegin(), samplesToDo+sInputPadding, tmpiter);
- if(updateState) [[likely]]
+ if(updateState) LIKELY
std::copy_n(mTemp.cbegin()+samplesToDo, mSHistory.size(), mSHistory.begin());
PShift.process({youtput, samplesToDo}, mTemp.data());
@@ -333,7 +333,7 @@ void UhjDecoderIIR::decode(const al::span<float*> samples, const size_t samplesT
/* Apply filter1 to S and store in mTemp. */
mTemp[0] = mDelayS;
mFilter1S.process(Filter1Coeff, {mS.data(), samplesToDo}, updateState, mTemp.data()+1);
- if(updateState) [[likely]] mDelayS = mTemp[samplesToDo];
+ if(updateState) LIKELY mDelayS = mTemp[samplesToDo];
/* W = 0.981532*S + 0.197484*j(0.828331*D + 0.767820*T) */
for(size_t i{0};i < samplesToDo;++i)
@@ -348,7 +348,7 @@ void UhjDecoderIIR::decode(const al::span<float*> samples, const size_t samplesT
[](const float d, const float t) noexcept { return 0.795968f*d - 0.676392f*t; });
mTemp[0] = mDelayDT;
mFilter1DT.process(Filter1Coeff, {youtput, samplesToDo}, updateState, mTemp.data()+1);
- if(updateState) [[likely]] mDelayDT = mTemp[samplesToDo];
+ if(updateState) LIKELY mDelayDT = mTemp[samplesToDo];
/* Precompute j*S and store in youtput. */
mFilter2S.process(Filter2Coeff, {mS.data(), samplesToDo}, updateState, youtput);
@@ -365,7 +365,7 @@ void UhjDecoderIIR::decode(const al::span<float*> samples, const size_t samplesT
/* Apply filter1 to Q and store in mTemp. */
mTemp[0] = mDelayQ;
mFilter1Q.process(Filter1Coeff, {zoutput, samplesToDo}, updateState, mTemp.data()+1);
- if(updateState) [[likely]] mDelayQ = mTemp[samplesToDo];
+ if(updateState) LIKELY mDelayQ = mTemp[samplesToDo];
/* Z = 1.023332*Q */
for(size_t i{0};i < samplesToDo;++i)
@@ -436,7 +436,7 @@ void UhjStereoDecoder<N>::decode(const al::span<float*> samples, const size_t sa
/* Precompute j*D and store in xoutput. */
auto tmpiter = std::copy(mDTHistory.cbegin(), mDTHistory.cend(), mTemp.begin());
std::copy_n(mD.cbegin(), samplesToDo+sInputPadding, tmpiter);
- if(updateState) [[likely]]
+ if(updateState) LIKELY
std::copy_n(mTemp.cbegin()+samplesToDo, mDTHistory.size(), mDTHistory.begin());
PShift.process({xoutput, samplesToDo}, mTemp.data());
@@ -450,7 +450,7 @@ void UhjStereoDecoder<N>::decode(const al::span<float*> samples, const size_t sa
/* Precompute j*S and store in youtput. */
tmpiter = std::copy(mSHistory.cbegin(), mSHistory.cend(), mTemp.begin());
std::copy_n(mS.cbegin(), samplesToDo+sInputPadding, tmpiter);
- if(updateState) [[likely]]
+ if(updateState) LIKELY
std::copy_n(mTemp.cbegin()+samplesToDo, mSHistory.size(), mSHistory.begin());
PShift.process({youtput, samplesToDo}, mTemp.data());
@@ -504,7 +504,7 @@ void UhjStereoDecoderIIR::decode(const al::span<float*> samples, const size_t sa
/* Apply filter1 to S and store in mTemp. */
mTemp[0] = mDelayS;
mFilter1S.process(Filter1Coeff, {mS.data(), samplesToDo}, updateState, mTemp.data()+1);
- if(updateState) [[likely]] mDelayS = mTemp[samplesToDo];
+ if(updateState) LIKELY mDelayS = mTemp[samplesToDo];
/* Precompute j*D and store in xoutput. */
mFilter2D.process(Filter2Coeff, {mD.data(), samplesToDo}, updateState, xoutput);
@@ -522,7 +522,7 @@ void UhjStereoDecoderIIR::decode(const al::span<float*> samples, const size_t sa
/* Apply filter1 to D and store in mTemp. */
mTemp[0] = mDelayD;
mFilter1D.process(Filter1Coeff, {mD.data(), samplesToDo}, updateState, mTemp.data()+1);
- if(updateState) [[likely]] mDelayD = mTemp[samplesToDo];
+ if(updateState) LIKELY mDelayD = mTemp[samplesToDo];
/* Y = 1.6822415*w*D - 0.2156194*j*S */
for(size_t i{0};i < samplesToDo;++i)
diff --git a/core/voice.cpp b/core/voice.cpp
index d6708f6d..ee5f6ae6 100644
--- a/core/voice.cpp
+++ b/core/voice.cpp
@@ -493,7 +493,7 @@ void LoadBufferStatic(VoiceBufferItem *buffer, VoiceBufferItem *bufferLoopItem,
if(!bufferLoopItem)
{
/* Load what's left to play from the buffer */
- if(buffer->mSampleLen > dataPosInt) [[likely]]
+ if(buffer->mSampleLen > dataPosInt) LIKELY
{
const size_t buffer_remaining{buffer->mSampleLen - dataPosInt};
const size_t remaining{minz(samplesToLoad-samplesLoaded, buffer_remaining)};
@@ -539,7 +539,7 @@ void LoadBufferCallback(VoiceBufferItem *buffer, const size_t dataPosInt,
const size_t srcStep, size_t samplesLoaded, const size_t samplesToLoad, float *voiceSamples)
{
/* Load what's left to play from the buffer */
- if(numCallbackSamples > dataPosInt) [[likely]]
+ if(numCallbackSamples > dataPosInt) LIKELY
{
const size_t remaining{minz(samplesToLoad-samplesLoaded, numCallbackSamples-dataPosInt)};
LoadSamples(voiceSamples+samplesLoaded, buffer->mSamples, srcChannel, dataPosInt,
@@ -603,7 +603,7 @@ void DoHrtfMix(const float *samples, const uint DstBufferSize, DirectParams &par
std::begin(HrtfSamples));
std::copy_n(samples, DstBufferSize, src_iter);
/* Copy the last used samples back into the history buffer for later. */
- if(IsPlaying) [[likely]]
+ if(IsPlaying) LIKELY
std::copy_n(std::begin(HrtfSamples) + DstBufferSize, parms.Hrtf.History.size(),
parms.Hrtf.History.begin());
@@ -710,7 +710,7 @@ void Voice::mix(const State vstate, ContextBase *Context, const nanoseconds devi
VoiceBufferItem *BufferListItem{mCurrentBuffer.load(std::memory_order_relaxed)};
VoiceBufferItem *BufferLoopItem{mLoopBuffer.load(std::memory_order_relaxed)};
const uint increment{mStep};
- if(increment < 1) [[unlikely]]
+ if(increment < 1) UNLIKELY
{
/* If the voice is supposed to be stopping but can't be mixed, just
* stop it before bailing.
@@ -863,7 +863,7 @@ void Voice::mix(const State vstate, ContextBase *Context, const nanoseconds devi
else
{
size_t srcSampleDelay{0};
- if(intPos < 0) [[unlikely]]
+ if(intPos < 0) UNLIKELY
{
/* If the current position is negative, there's that many
* silent samples to load before using the buffer.
@@ -922,13 +922,13 @@ void Voice::mix(const State vstate, ContextBase *Context, const nanoseconds devi
{MixingSamples[chan]+samplesLoaded, dstBufferSize});
/* Store the last source samples used for next time. */
- if(vstate == Playing) [[likely]]
+ if(vstate == Playing) LIKELY
{
/* Only store samples for the end of the mix, excluding what
* gets loaded for decoder padding.
*/
const uint loadEnd{samplesLoaded + dstBufferSize};
- if(samplesToMix > samplesLoaded && samplesToMix <= loadEnd) [[likely]]
+ if(samplesToMix > samplesLoaded && samplesToMix <= loadEnd) LIKELY
{
const size_t dstOffset{samplesToMix - samplesLoaded};
const size_t srcOffset{(dstOffset*increment + fracPos) >> MixerFracBits};
@@ -1046,7 +1046,7 @@ void Voice::mix(const State vstate, ContextBase *Context, const nanoseconds devi
mFlags.set(VoiceIsFading);
/* Don't update positions and buffers if we were stopping. */
- if(vstate == Stopping) [[unlikely]]
+ if(vstate == Stopping) UNLIKELY
{
mPlayState.store(Stopped, std::memory_order_release);
return;
@@ -1059,7 +1059,7 @@ void Voice::mix(const State vstate, ContextBase *Context, const nanoseconds devi
DataPosFrac &= MixerFracMask;
uint buffers_done{0u};
- if(BufferListItem && DataPosInt >= 0) [[likely]]
+ if(BufferListItem && DataPosInt >= 0) LIKELY
{
if(mFlags.test(VoiceIsStatic))
{
@@ -1168,7 +1168,7 @@ void Voice::prepare(DeviceBase *device)
*/
uint num_channels{(mFmtChannels == FmtUHJ2 || mFmtChannels == FmtSuperStereo) ? 3 :
ChannelsFromFmt(mFmtChannels, minu(mAmbiOrder, device->mAmbiOrder))};
- if(num_channels > device->mSampleData.size()) [[unlikely]]
+ if(num_channels > device->mSampleData.size()) UNLIKELY
{
ERR("Unexpected channel count: %u (limit: %zu, %d:%d)\n", num_channels,
device->mSampleData.size(), mFmtChannels, mAmbiOrder);