aboutsummaryrefslogtreecommitdiffstats
path: root/al/buffer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'al/buffer.cpp')
-rw-r--r--al/buffer.cpp248
1 files changed, 124 insertions, 124 deletions
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);