aboutsummaryrefslogtreecommitdiffstats
path: root/al
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-08-04 11:59:14 -0700
committerChris Robinson <[email protected]>2019-08-04 11:59:14 -0700
commit2fa2c35bdc2a09d5e856bb12ad6dff556bbe65a8 (patch)
tree4a6c7a5f2a80ad7870e9028e48b8b99e558042f5 /al
parent7897de31d0f75f4ac1d91fe8c470953e9f54d151 (diff)
Modify LIKELY and UNLIKELY to not need extra parenthesis
Diffstat (limited to 'al')
-rw-r--r--al/auxeffectslot.cpp56
-rw-r--r--al/buffer.cpp224
-rw-r--r--al/effect.cpp70
-rw-r--r--al/error.cpp2
-rw-r--r--al/event.cpp12
-rw-r--r--al/extension.cpp2
-rw-r--r--al/filter.cpp70
-rw-r--r--al/listener.cpp24
-rw-r--r--al/source.cpp268
-rw-r--r--al/state.cpp46
10 files changed, 377 insertions, 397 deletions
diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp
index 912765fc..e961874d 100644
--- a/al/auxeffectslot.cpp
+++ b/al/auxeffectslot.cpp
@@ -53,10 +53,10 @@ inline ALeffectslot *LookupEffectSlot(ALCcontext *context, ALuint id) noexcept
ALuint lidx = (id-1) >> 6;
ALsizei slidx = (id-1) & 0x3f;
- if(UNLIKELY(lidx >= context->mEffectSlotList.size()))
+ if UNLIKELY(lidx >= context->mEffectSlotList.size())
return nullptr;
EffectSlotSubList &sublist{context->mEffectSlotList[lidx]};
- if(UNLIKELY(sublist.FreeMask & (1_u64 << slidx)))
+ if UNLIKELY(sublist.FreeMask & (1_u64 << slidx))
return nullptr;
return sublist.EffectSlots + slidx;
}
@@ -66,10 +66,10 @@ inline ALeffect *LookupEffect(ALCdevice *device, ALuint id) noexcept
ALuint lidx = (id-1) >> 6;
ALsizei slidx = (id-1) & 0x3f;
- if(UNLIKELY(lidx >= device->EffectList.size()))
+ if UNLIKELY(lidx >= device->EffectList.size())
return nullptr;
EffectSubList &sublist = device->EffectList[lidx];
- if(UNLIKELY(sublist.FreeMask & (1_u64 << slidx)))
+ if UNLIKELY(sublist.FreeMask & (1_u64 << slidx))
return nullptr;
return sublist.Effects + slidx;
}
@@ -104,7 +104,7 @@ void AddActiveEffectSlots(const ALuint *slotids, ALsizei count, ALCcontext *cont
/* Reallocate newarray if the new size ended up smaller from duplicate
* removal.
*/
- if(UNLIKELY(newcount < newarray->size()))
+ if UNLIKELY(newcount < newarray->size())
{
curarray = newarray;
newarray = ALeffectslot::CreatePtrArray(newcount);
@@ -139,7 +139,7 @@ void RemoveActiveEffectSlots(const ALuint *slotids, ALsizei count, ALCcontext *c
/* Reallocate with the new size. */
auto newsize = static_cast<size_t>(std::distance(newarray->begin(), slotiter));
- if(LIKELY(newsize != newarray->size()))
+ if LIKELY(newsize != newarray->size())
{
curarray = newarray;
newarray = ALeffectslot::CreatePtrArray(newsize);
@@ -174,7 +174,7 @@ ALeffectslot *AllocEffectSlot(ALCcontext *context)
auto lidx = static_cast<ALsizei>(std::distance(context->mEffectSlotList.begin(), sublist));
ALeffectslot *slot;
ALsizei slidx;
- if(LIKELY(sublist != context->mEffectSlotList.end()))
+ if LIKELY(sublist != context->mEffectSlotList.end())
{
slidx = CTZ64(sublist->FreeMask);
slot = sublist->EffectSlots + slidx;
@@ -184,7 +184,7 @@ ALeffectslot *AllocEffectSlot(ALCcontext *context)
/* Don't allocate so many list entries that the 32-bit ID could
* overflow...
*/
- if(UNLIKELY(context->mEffectSlotList.size() >= 1<<25))
+ if UNLIKELY(context->mEffectSlotList.size() >= 1<<25)
{
context->setError(AL_OUT_OF_MEMORY, "Too many effect slots allocated");
return nullptr;
@@ -194,7 +194,7 @@ ALeffectslot *AllocEffectSlot(ALCcontext *context)
sublist->FreeMask = ~0_u64;
sublist->EffectSlots = static_cast<ALeffectslot*>(al_calloc(16, sizeof(ALeffectslot)*64));
- if(UNLIKELY(!sublist->EffectSlots))
+ if UNLIKELY(!sublist->EffectSlots)
{
context->mEffectSlotList.pop_back();
context->setError(AL_OUT_OF_MEMORY, "Failed to allocate effect slot batch");
@@ -260,7 +260,7 @@ AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslo
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
if(n < 0)
SETERR_RETURN(context, AL_INVALID_VALUE,, "Generating %d effect slots", n);
@@ -303,7 +303,7 @@ AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, const ALuint *
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
if(n < 0)
SETERR_RETURN(context, AL_INVALID_VALUE,, "Deleting %d effect slots", n);
@@ -347,7 +347,7 @@ AL_API ALboolean AL_APIENTRY alIsAuxiliaryEffectSlot(ALuint effectslot)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(LIKELY(context))
+ if LIKELY(context)
{
std::lock_guard<std::mutex> _{context->mEffectSlotLock};
if(LookupEffectSlot(context.get(), effectslot) != nullptr)
@@ -362,12 +362,12 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mEffectSlotLock};
ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot);
- if(UNLIKELY(!slot))
+ if UNLIKELY(!slot)
SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot);
ALeffectslot *target{};
@@ -450,11 +450,11 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mEffectSlotLock};
ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot);
- if(UNLIKELY(!slot))
+ if UNLIKELY(!slot)
SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot);
switch(param)
@@ -470,12 +470,12 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mEffectSlotLock};
ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot);
- if(UNLIKELY(!slot))
+ if UNLIKELY(!slot)
SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot);
switch(param)
@@ -505,11 +505,11 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mEffectSlotLock};
ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot);
- if(UNLIKELY(!slot))
+ if UNLIKELY(!slot)
SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot);
switch(param)
@@ -526,11 +526,11 @@ AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSloti(ALuint effectslot, ALenum pa
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mEffectSlotLock};
ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot);
- if(UNLIKELY(!slot))
+ if UNLIKELY(!slot)
SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot);
switch(param)
@@ -562,11 +562,11 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mEffectSlotLock};
ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot);
- if(UNLIKELY(!slot))
+ if UNLIKELY(!slot)
SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot);
switch(param)
@@ -582,11 +582,11 @@ AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotf(ALuint effectslot, ALenum pa
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mEffectSlotLock};
ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot);
- if(UNLIKELY(!slot))
+ if UNLIKELY(!slot)
SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot);
switch(param)
@@ -612,11 +612,11 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mEffectSlotLock};
ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot);
- if(UNLIKELY(!slot))
+ if UNLIKELY(!slot)
SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot);
switch(param)
diff --git a/al/buffer.cpp b/al/buffer.cpp
index a068399c..df2496cb 100644
--- a/al/buffer.cpp
+++ b/al/buffer.cpp
@@ -256,7 +256,7 @@ ALbuffer *AllocBuffer(ALCcontext *context)
auto lidx = static_cast<ALsizei>(std::distance(device->BufferList.begin(), sublist));
ALbuffer *buffer{nullptr};
ALsizei slidx{0};
- if(LIKELY(sublist != device->BufferList.end()))
+ if LIKELY(sublist != device->BufferList.end())
{
slidx = CTZ64(sublist->FreeMask);
buffer = sublist->Buffers + slidx;
@@ -266,7 +266,7 @@ ALbuffer *AllocBuffer(ALCcontext *context)
/* Don't allocate so many list entries that the 32-bit ID could
* overflow...
*/
- if(UNLIKELY(device->BufferList.size() >= 1<<25))
+ if UNLIKELY(device->BufferList.size() >= 1<<25)
{
context->setError(AL_OUT_OF_MEMORY, "Too many buffers allocated");
return nullptr;
@@ -275,7 +275,7 @@ ALbuffer *AllocBuffer(ALCcontext *context)
sublist = device->BufferList.end() - 1;
sublist->FreeMask = ~0_u64;
sublist->Buffers = reinterpret_cast<ALbuffer*>(al_calloc(16, sizeof(ALbuffer)*64));
- if(UNLIKELY(!sublist->Buffers))
+ if UNLIKELY(!sublist->Buffers)
{
device->BufferList.pop_back();
context->setError(AL_OUT_OF_MEMORY, "Failed to allocate buffer batch");
@@ -311,10 +311,10 @@ inline ALbuffer *LookupBuffer(ALCdevice *device, ALuint id)
ALuint lidx = (id-1) >> 6;
ALsizei slidx = (id-1) & 0x3f;
- if(UNLIKELY(lidx >= device->BufferList.size()))
+ if UNLIKELY(lidx >= device->BufferList.size())
return nullptr;
BufferSubList &sublist = device->BufferList[lidx];
- if(UNLIKELY(sublist.FreeMask & (1_u64 << slidx)))
+ if UNLIKELY(sublist.FreeMask & (1_u64 << slidx))
return nullptr;
return sublist.Buffers + slidx;
}
@@ -380,7 +380,7 @@ const ALchar *NameFromUserFmtType(UserFmtType type)
*/
void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALuint freq, ALsizei size, UserFmtChannels SrcChannels, UserFmtType SrcType, const al::byte *SrcData, ALbitfieldSOFT access)
{
- if(UNLIKELY(ReadRef(ALBuf->ref) != 0 || ALBuf->MappedAccess != 0))
+ if UNLIKELY(ReadRef(ALBuf->ref) != 0 || ALBuf->MappedAccess != 0)
SETERR_RETURN(context, AL_INVALID_OPERATION,, "Modifying storage for in-use buffer %u",
ALBuf->id);
@@ -398,8 +398,7 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALuint freq, ALsizei size, U
case UserFmtBFormat2D: DstChannels = FmtBFormat2D; break;
case UserFmtBFormat3D: DstChannels = FmtBFormat3D; break;
}
- if (UNLIKELY(static_cast<long>(SrcChannels) !=
- static_cast<long>(DstChannels)))
+ if UNLIKELY(static_cast<long>(SrcChannels) != static_cast<long>(DstChannels))
SETERR_RETURN(context, AL_INVALID_ENUM, , "Invalid format");
/* IMA4 and MSADPCM convert to 16-bit short. */
@@ -422,24 +421,23 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALuint freq, ALsizei size, U
*/
if((access&MAP_READ_WRITE_FLAGS))
{
- if (UNLIKELY(static_cast<long>(SrcType) != static_cast<long>(DstType)))
- SETERR_RETURN(context, AL_INVALID_VALUE, ,
- "%s samples cannot be mapped",
- NameFromUserFmtType(SrcType));
+ if UNLIKELY(static_cast<long>(SrcType) != static_cast<long>(DstType))
+ SETERR_RETURN(context, AL_INVALID_VALUE,, "%s samples cannot be mapped",
+ NameFromUserFmtType(SrcType));
}
const ALsizei unpackalign{ALBuf->UnpackAlign.load()};
const ALsizei align{SanitizeAlignment(SrcType, unpackalign)};
- if(UNLIKELY(align < 1))
+ if UNLIKELY(align < 1)
SETERR_RETURN(context, AL_INVALID_VALUE,, "Invalid unpack alignment %d for %s samples",
- unpackalign, NameFromUserFmtType(SrcType));
+ unpackalign, NameFromUserFmtType(SrcType));
if((access&AL_PRESERVE_DATA_BIT_SOFT))
{
/* Can only preserve data with the same format and alignment. */
- if(UNLIKELY(ALBuf->mFmtChannels != DstChannels || ALBuf->OriginalType != SrcType))
+ if UNLIKELY(ALBuf->mFmtChannels != DstChannels || ALBuf->OriginalType != SrcType)
SETERR_RETURN(context, AL_INVALID_VALUE,, "Preserving data of mismatched format");
- if(UNLIKELY(ALBuf->OriginalAlign != align))
+ if UNLIKELY(ALBuf->OriginalAlign != align)
SETERR_RETURN(context, AL_INVALID_VALUE,, "Preserving data of mismatched alignment");
}
@@ -451,12 +449,12 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALuint freq, ALsizei size, U
(SrcType == UserFmtMSADPCM) ? ((align-2)/2 + 7) * ChannelsFromUserFmt(SrcChannels) :
(align * FrameSizeFromUserFmt(SrcChannels, SrcType))
};
- if(UNLIKELY((size%SrcByteAlign) != 0))
+ if UNLIKELY((size%SrcByteAlign) != 0)
SETERR_RETURN(context, AL_INVALID_VALUE,,
"Data size %d is not a multiple of frame size %d (%d unpack alignment)",
size, SrcByteAlign, align);
- if(UNLIKELY(size/SrcByteAlign > std::numeric_limits<ALsizei>::max()/align))
+ if UNLIKELY(size/SrcByteAlign > std::numeric_limits<ALsizei>::max()/align)
SETERR_RETURN(context, AL_OUT_OF_MEMORY,,
"Buffer size overflow, %d blocks x %d samples per block", size/SrcByteAlign, align);
const auto frames = static_cast<ALuint>(size / SrcByteAlign * align);
@@ -466,7 +464,7 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALuint freq, ALsizei size, U
*/
ALsizei NumChannels{ChannelsFromFmt(DstChannels)};
ALsizei FrameSize{NumChannels * BytesFromFmt(DstType)};
- if(UNLIKELY(frames > std::numeric_limits<size_t>::max()/FrameSize))
+ if UNLIKELY(frames > std::numeric_limits<size_t>::max()/FrameSize)
SETERR_RETURN(context, AL_OUT_OF_MEMORY,,
"Buffer size overflow, %d frames x %d bytes per frame", frames, FrameSize);
size_t newsize{static_cast<size_t>(frames) * FrameSize};
@@ -606,21 +604,19 @@ AL_API ALvoid AL_APIENTRY alGenBuffers(ALsizei n, ALuint *buffers)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
- if(UNLIKELY(n < 0))
- {
+ if UNLIKELY(n < 0)
context->setError(AL_INVALID_VALUE, "Generating %d buffers", n);
- return;
- }
+ if UNLIKELY(n <= 0) return;
- if(LIKELY(n == 1))
+ if LIKELY(n == 1)
{
/* Special handling for the easy and normal case. */
ALbuffer *buffer = AllocBuffer(context.get());
if(buffer) buffers[0] = buffer->id;
}
- else if(n > 1)
+ else
{
/* Store the allocated buffer IDs in a separate local list, to avoid
* modifying the user storage in case of failure.
@@ -646,15 +642,11 @@ AL_API ALvoid AL_APIENTRY alDeleteBuffers(ALsizei n, const ALuint *buffers)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
- if(UNLIKELY(n < 0))
- {
+ if UNLIKELY(n < 0)
context->setError(AL_INVALID_VALUE, "Deleting %d buffers", n);
- return;
- }
- if(UNLIKELY(n == 0))
- return;
+ if UNLIKELY(n <= 0) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
@@ -666,12 +658,12 @@ START_API_FUNC
{
if(!bid) return false;
ALbuffer *ALBuf = LookupBuffer(device, bid);
- if(UNLIKELY(!ALBuf))
+ if UNLIKELY(!ALBuf)
{
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", bid);
return true;
}
- if(UNLIKELY(ReadRef(ALBuf->ref) != 0))
+ if UNLIKELY(ReadRef(ALBuf->ref) != 0)
{
context->setError(AL_INVALID_OPERATION, "Deleting in-use buffer %u", bid);
return true;
@@ -679,7 +671,7 @@ START_API_FUNC
return false;
}
);
- if(LIKELY(invbuf == buffers_end))
+ if LIKELY(invbuf == buffers_end)
{
/* All good. Delete non-0 buffer IDs. */
std::for_each(buffers, buffers_end,
@@ -697,7 +689,7 @@ AL_API ALboolean AL_APIENTRY alIsBuffer(ALuint buffer)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(LIKELY(context))
+ if LIKELY(context)
{
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
@@ -718,28 +710,28 @@ AL_API void AL_APIENTRY alBufferStorageSOFT(ALuint buffer, ALenum format, const
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
- if(UNLIKELY(!albuf))
+ if UNLIKELY(!albuf)
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
- else if(UNLIKELY(size < 0))
+ else if UNLIKELY(size < 0)
context->setError(AL_INVALID_VALUE, "Negative storage size %d", size);
- else if(UNLIKELY(freq < 1))
+ else if UNLIKELY(freq < 1)
context->setError(AL_INVALID_VALUE, "Invalid sample rate %d", freq);
- else if(UNLIKELY((flags&INVALID_STORAGE_MASK) != 0))
+ else if UNLIKELY((flags&INVALID_STORAGE_MASK) != 0)
context->setError(AL_INVALID_VALUE, "Invalid storage flags 0x%x",
flags&INVALID_STORAGE_MASK);
- else if(UNLIKELY((flags&AL_MAP_PERSISTENT_BIT_SOFT) && !(flags&MAP_READ_WRITE_FLAGS)))
+ else if UNLIKELY((flags&AL_MAP_PERSISTENT_BIT_SOFT) && !(flags&MAP_READ_WRITE_FLAGS))
context->setError(AL_INVALID_VALUE,
"Declaring persistently mapped storage without read or write access");
else
{
auto usrfmt = DecomposeUserFormat(format);
- if(UNLIKELY(!usrfmt))
+ if UNLIKELY(!usrfmt)
context->setError(AL_INVALID_ENUM, "Invalid format 0x%04x", format);
else
LoadData(context.get(), albuf, freq, size, usrfmt->channels, usrfmt->type,
@@ -752,38 +744,38 @@ AL_API void* AL_APIENTRY alMapBufferSOFT(ALuint buffer, ALsizei offset, ALsizei
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return nullptr;
+ if UNLIKELY(!context) return nullptr;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
- if(UNLIKELY(!albuf))
+ if UNLIKELY(!albuf)
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
- else if(UNLIKELY((access&INVALID_MAP_FLAGS) != 0))
+ else if UNLIKELY((access&INVALID_MAP_FLAGS) != 0)
context->setError(AL_INVALID_VALUE, "Invalid map flags 0x%x", access&INVALID_MAP_FLAGS);
- else if(UNLIKELY(!(access&MAP_READ_WRITE_FLAGS)))
+ else if UNLIKELY(!(access&MAP_READ_WRITE_FLAGS))
context->setError(AL_INVALID_VALUE, "Mapping buffer %u without read or write access",
buffer);
else
{
ALbitfieldSOFT unavailable = (albuf->Access^access) & access;
- if(UNLIKELY(ReadRef(albuf->ref) != 0 && !(access&AL_MAP_PERSISTENT_BIT_SOFT)))
+ if UNLIKELY(ReadRef(albuf->ref) != 0 && !(access&AL_MAP_PERSISTENT_BIT_SOFT))
context->setError(AL_INVALID_OPERATION,
"Mapping in-use buffer %u without persistent mapping", buffer);
- else if(UNLIKELY(albuf->MappedAccess != 0))
+ else if UNLIKELY(albuf->MappedAccess != 0)
context->setError(AL_INVALID_OPERATION, "Mapping already-mapped buffer %u", buffer);
- else if(UNLIKELY((unavailable&AL_MAP_READ_BIT_SOFT)))
+ else if UNLIKELY((unavailable&AL_MAP_READ_BIT_SOFT))
context->setError(AL_INVALID_VALUE,
"Mapping buffer %u for reading without read access", buffer);
- else if(UNLIKELY((unavailable&AL_MAP_WRITE_BIT_SOFT)))
+ else if UNLIKELY((unavailable&AL_MAP_WRITE_BIT_SOFT))
context->setError(AL_INVALID_VALUE,
"Mapping buffer %u for writing without write access", buffer);
- else if(UNLIKELY((unavailable&AL_MAP_PERSISTENT_BIT_SOFT)))
+ else if UNLIKELY((unavailable&AL_MAP_PERSISTENT_BIT_SOFT))
context->setError(AL_INVALID_VALUE,
"Mapping buffer %u persistently without persistent access", buffer);
- else if(UNLIKELY(offset < 0 || offset >= albuf->OriginalSize ||
- length <= 0 || length > albuf->OriginalSize - offset))
+ else if UNLIKELY(offset < 0 || offset >= albuf->OriginalSize ||
+ length <= 0 || length > albuf->OriginalSize - offset)
context->setError(AL_INVALID_VALUE, "Mapping invalid range %d+%d for buffer %u",
offset, length, buffer);
else
@@ -804,15 +796,15 @@ AL_API void AL_APIENTRY alUnmapBufferSOFT(ALuint buffer)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
- if(UNLIKELY(!albuf))
+ if UNLIKELY(!albuf)
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
- else if(albuf->MappedAccess == 0)
+ else if UNLIKELY(albuf->MappedAccess == 0)
context->setError(AL_INVALID_OPERATION, "Unmapping unmapped buffer %u", buffer);
else
{
@@ -827,20 +819,20 @@ AL_API void AL_APIENTRY alFlushMappedBufferSOFT(ALuint buffer, ALsizei offset, A
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
- if(UNLIKELY(!albuf))
+ if UNLIKELY(!albuf)
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
- else if(UNLIKELY(!(albuf->MappedAccess&AL_MAP_WRITE_BIT_SOFT)))
+ else if UNLIKELY(!(albuf->MappedAccess&AL_MAP_WRITE_BIT_SOFT))
context->setError(AL_INVALID_OPERATION, "Flushing buffer %u while not mapped for writing",
buffer);
- else if(UNLIKELY(offset < albuf->MappedOffset ||
+ else if UNLIKELY(offset < albuf->MappedOffset ||
offset >= albuf->MappedOffset+albuf->MappedSize ||
- length <= 0 || length > albuf->MappedOffset+albuf->MappedSize-offset))
+ length <= 0 || length > albuf->MappedOffset+albuf->MappedSize-offset)
context->setError(AL_INVALID_VALUE, "Flushing invalid range %d+%d on buffer %u", offset,
length, buffer);
else
@@ -859,20 +851,20 @@ AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer, ALenum format, cons
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
- if(UNLIKELY(!albuf))
+ if UNLIKELY(!albuf)
{
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
return;
}
auto usrfmt = DecomposeUserFormat(format);
- if(UNLIKELY(!usrfmt))
+ if UNLIKELY(!usrfmt)
{
context->setError(AL_INVALID_ENUM, "Invalid format 0x%04x", format);
return;
@@ -880,16 +872,16 @@ START_API_FUNC
ALsizei unpack_align{albuf->UnpackAlign.load()};
ALsizei align{SanitizeAlignment(usrfmt->type, unpack_align)};
- if(UNLIKELY(align < 1))
+ if UNLIKELY(align < 1)
context->setError(AL_INVALID_VALUE, "Invalid unpack alignment %d", unpack_align);
- else if(UNLIKELY(long{usrfmt->channels} != long{albuf->mFmtChannels} ||
- usrfmt->type != albuf->OriginalType))
+ else if UNLIKELY(long{usrfmt->channels} != long{albuf->mFmtChannels} ||
+ usrfmt->type != albuf->OriginalType)
context->setError(AL_INVALID_ENUM, "Unpacking data with mismatched format");
- else if(UNLIKELY(align != albuf->OriginalAlign))
+ else if UNLIKELY(align != albuf->OriginalAlign)
context->setError(AL_INVALID_VALUE,
"Unpacking data with alignment %u does not match original alignment %u", align,
albuf->OriginalAlign);
- else if(UNLIKELY(albuf->MappedAccess != 0))
+ else if UNLIKELY(albuf->MappedAccess != 0)
context->setError(AL_INVALID_OPERATION, "Unpacking data into mapped buffer %u", buffer);
else
{
@@ -901,15 +893,15 @@ START_API_FUNC
(align * frame_size)
};
- if(UNLIKELY(offset < 0 || length < 0 || offset > albuf->OriginalSize ||
- length > albuf->OriginalSize-offset))
+ if UNLIKELY(offset < 0 || length < 0 || offset > albuf->OriginalSize ||
+ length > albuf->OriginalSize-offset)
context->setError(AL_INVALID_VALUE, "Invalid data sub-range %d+%d on buffer %u",
offset, length, buffer);
- else if(UNLIKELY((offset%byte_align) != 0))
+ else if UNLIKELY((offset%byte_align) != 0)
context->setError(AL_INVALID_VALUE,
"Sub-range offset %d is not a multiple of frame size %d (%d unpack alignment)",
offset, byte_align, align);
- else if(UNLIKELY((length%byte_align) != 0))
+ else if UNLIKELY((length%byte_align) != 0)
context->setError(AL_INVALID_VALUE,
"Sub-range length %d is not a multiple of frame size %d (%d unpack alignment)",
length, byte_align, align);
@@ -943,7 +935,7 @@ AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint /*buffer*/, ALuint /*samplera
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
context->setError(AL_INVALID_OPERATION, "alBufferSamplesSOFT not supported");
}
@@ -954,7 +946,7 @@ AL_API void AL_APIENTRY alBufferSubSamplesSOFT(ALuint /*buffer*/, ALsizei /*offs
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
context->setError(AL_INVALID_OPERATION, "alBufferSubSamplesSOFT not supported");
}
@@ -965,7 +957,7 @@ AL_API void AL_APIENTRY alGetBufferSamplesSOFT(ALuint /*buffer*/, ALsizei /*offs
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
context->setError(AL_INVALID_OPERATION, "alGetBufferSamplesSOFT not supported");
}
@@ -975,7 +967,7 @@ AL_API ALboolean AL_APIENTRY alIsBufferFormatSupportedSOFT(ALenum /*format*/)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(!context) return AL_FALSE;
+ if UNLIKELY(!context) return AL_FALSE;
context->setError(AL_INVALID_OPERATION, "alIsBufferFormatSupportedSOFT not supported");
return AL_FALSE;
@@ -987,12 +979,12 @@ AL_API void AL_APIENTRY alBufferf(ALuint buffer, ALenum param, ALfloat /*value*/
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
- if(UNLIKELY(LookupBuffer(device, buffer) == nullptr))
+ if UNLIKELY(LookupBuffer(device, buffer) == nullptr)
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
else switch(param)
{
@@ -1007,12 +999,12 @@ AL_API void AL_APIENTRY alBuffer3f(ALuint buffer, ALenum param,
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
- if(UNLIKELY(LookupBuffer(device, buffer) == nullptr))
+ if UNLIKELY(LookupBuffer(device, buffer) == nullptr)
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
else switch(param)
{
@@ -1026,14 +1018,14 @@ AL_API void AL_APIENTRY alBufferfv(ALuint buffer, ALenum param, const ALfloat *v
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
- if(UNLIKELY(LookupBuffer(device, buffer) == nullptr))
+ if UNLIKELY(LookupBuffer(device, buffer) == nullptr)
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
- else if(UNLIKELY(!values))
+ else if UNLIKELY(!values)
context->setError(AL_INVALID_VALUE, "NULL pointer");
else switch(param)
{
@@ -1048,25 +1040,25 @@ AL_API void AL_APIENTRY alBufferi(ALuint buffer, ALenum param, ALint value)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
- if(UNLIKELY(!albuf))
+ if UNLIKELY(!albuf)
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
else switch(param)
{
case AL_UNPACK_BLOCK_ALIGNMENT_SOFT:
- if(UNLIKELY(value < 0))
+ if UNLIKELY(value < 0)
context->setError(AL_INVALID_VALUE, "Invalid unpack block alignment %d", value);
else
albuf->UnpackAlign.store(value);
break;
case AL_PACK_BLOCK_ALIGNMENT_SOFT:
- if(UNLIKELY(value < 0))
+ if UNLIKELY(value < 0)
context->setError(AL_INVALID_VALUE, "Invalid pack block alignment %d", value);
else
albuf->PackAlign.store(value);
@@ -1083,12 +1075,12 @@ AL_API void AL_APIENTRY alBuffer3i(ALuint buffer, ALenum param,
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
- if(UNLIKELY(LookupBuffer(device, buffer) == nullptr))
+ if UNLIKELY(LookupBuffer(device, buffer) == nullptr)
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
else switch(param)
{
@@ -1113,24 +1105,24 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
- if(UNLIKELY(!albuf))
+ if UNLIKELY(!albuf)
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
- else if(UNLIKELY(!values))
+ else if UNLIKELY(!values)
context->setError(AL_INVALID_VALUE, "NULL pointer");
else switch(param)
{
case AL_LOOP_POINTS_SOFT:
- if(UNLIKELY(ReadRef(albuf->ref) != 0))
+ if UNLIKELY(ReadRef(albuf->ref) != 0)
context->setError(AL_INVALID_OPERATION, "Modifying in-use buffer %u's loop points",
buffer);
- else if(UNLIKELY(values[0] < 0 || values[0] >= values[1] ||
- static_cast<ALuint>(values[1]) > albuf->SampleLen))
+ else if UNLIKELY(values[0] < 0 || values[0] >= values[1] ||
+ static_cast<ALuint>(values[1]) > albuf->SampleLen)
context->setError(AL_INVALID_VALUE, "Invalid loop point range %d -> %d on buffer %u",
values[0], values[1], buffer);
else
@@ -1151,15 +1143,15 @@ AL_API ALvoid AL_APIENTRY alGetBufferf(ALuint buffer, ALenum param, ALfloat *val
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
- if(UNLIKELY(!albuf))
+ if UNLIKELY(!albuf)
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
- else if(UNLIKELY(!value))
+ else if UNLIKELY(!value)
context->setError(AL_INVALID_VALUE, "NULL pointer");
else switch(param)
{
@@ -1173,14 +1165,14 @@ AL_API void AL_APIENTRY alGetBuffer3f(ALuint buffer, ALenum param, ALfloat *valu
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
- if(UNLIKELY(LookupBuffer(device, buffer) == nullptr))
+ if UNLIKELY(LookupBuffer(device, buffer) == nullptr)
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
- else if(UNLIKELY(!value1 || !value2 || !value3))
+ else if UNLIKELY(!value1 || !value2 || !value3)
context->setError(AL_INVALID_VALUE, "NULL pointer");
else switch(param)
{
@@ -1201,14 +1193,14 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
- if(UNLIKELY(LookupBuffer(device, buffer) == nullptr))
+ if UNLIKELY(LookupBuffer(device, buffer) == nullptr)
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
- else if(UNLIKELY(!values))
+ else if UNLIKELY(!values)
context->setError(AL_INVALID_VALUE, "NULL pointer");
else switch(param)
{
@@ -1223,14 +1215,14 @@ AL_API ALvoid AL_APIENTRY alGetBufferi(ALuint buffer, ALenum param, ALint *value
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
- if(UNLIKELY(!albuf))
+ if UNLIKELY(!albuf)
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
- else if(UNLIKELY(!value))
+ else if UNLIKELY(!value)
context->setError(AL_INVALID_VALUE, "NULL pointer");
else switch(param)
{
@@ -1268,13 +1260,13 @@ AL_API void AL_APIENTRY alGetBuffer3i(ALuint buffer, ALenum param, ALint *value1
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
- if(UNLIKELY(LookupBuffer(device, buffer) == nullptr))
+ if UNLIKELY(LookupBuffer(device, buffer) == nullptr)
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
- else if(UNLIKELY(!value1 || !value2 || !value3))
+ else if UNLIKELY(!value1 || !value2 || !value3)
context->setError(AL_INVALID_VALUE, "NULL pointer");
else switch(param)
{
@@ -1303,14 +1295,14 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
- if(UNLIKELY(!albuf))
+ if UNLIKELY(!albuf)
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
- else if(UNLIKELY(!values))
+ else if UNLIKELY(!values)
context->setError(AL_INVALID_VALUE, "NULL pointer");
else switch(param)
{
diff --git a/al/effect.cpp b/al/effect.cpp
index 15200a88..e5571be0 100644
--- a/al/effect.cpp
+++ b/al/effect.cpp
@@ -148,7 +148,7 @@ ALeffect *AllocEffect(ALCcontext *context)
auto lidx = static_cast<ALsizei>(std::distance(device->EffectList.begin(), sublist));
ALeffect *effect{nullptr};
ALsizei slidx{0};
- if(LIKELY(sublist != device->EffectList.end()))
+ if LIKELY(sublist != device->EffectList.end())
{
slidx = CTZ64(sublist->FreeMask);
effect = sublist->Effects + slidx;
@@ -158,7 +158,7 @@ ALeffect *AllocEffect(ALCcontext *context)
/* Don't allocate so many list entries that the 32-bit ID could
* overflow...
*/
- if(UNLIKELY(device->EffectList.size() >= 1<<25))
+ if UNLIKELY(device->EffectList.size() >= 1<<25)
{
context->setError(AL_OUT_OF_MEMORY, "Too many effects allocated");
return nullptr;
@@ -167,7 +167,7 @@ ALeffect *AllocEffect(ALCcontext *context)
sublist = device->EffectList.end() - 1;
sublist->FreeMask = ~0_u64;
sublist->Effects = static_cast<ALeffect*>(al_calloc(16, sizeof(ALeffect)*64));
- if(UNLIKELY(!sublist->Effects))
+ if UNLIKELY(!sublist->Effects)
{
device->EffectList.pop_back();
context->setError(AL_OUT_OF_MEMORY, "Failed to allocate effect batch");
@@ -205,10 +205,10 @@ inline ALeffect *LookupEffect(ALCdevice *device, ALuint id)
ALuint lidx = (id-1) >> 6;
ALsizei slidx = (id-1) & 0x3f;
- if(UNLIKELY(lidx >= device->EffectList.size()))
+ if UNLIKELY(lidx >= device->EffectList.size())
return nullptr;
EffectSubList &sublist = device->EffectList[lidx];
- if(UNLIKELY(sublist.FreeMask & (1_u64 << slidx)))
+ if UNLIKELY(sublist.FreeMask & (1_u64 << slidx))
return nullptr;
return sublist.Effects + slidx;
}
@@ -219,21 +219,19 @@ AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
- if(UNLIKELY(n < 0))
- {
+ if UNLIKELY(n < 0)
context->setError(AL_INVALID_VALUE, "Generating %d effects", n);
- return;
- }
+ if UNLIKELY(n <= 0) return;
- if(LIKELY(n == 1))
+ if LIKELY(n == 1)
{
/* Special handling for the easy and normal case. */
ALeffect *effect = AllocEffect(context.get());
if(effect) effects[0] = effect->id;
}
- else if(n > 1)
+ else
{
/* Store the allocated buffer IDs in a separate local list, to avoid
* modifying the user storage in case of failure.
@@ -259,15 +257,11 @@ AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, const ALuint *effects)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
- if(UNLIKELY(n < 0))
- {
+ if UNLIKELY(n < 0)
context->setError(AL_INVALID_VALUE, "Deleting %d effects", n);
- return;
- }
- if(UNLIKELY(n == 0))
- return;
+ if UNLIKELY(n <= 0) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
@@ -279,7 +273,7 @@ START_API_FUNC
{
if(!eid) return false;
ALeffect *effect{LookupEffect(device, eid)};
- if(UNLIKELY(!effect))
+ if UNLIKELY(!effect)
{
context->setError(AL_INVALID_NAME, "Invalid effect ID %u", eid);
return true;
@@ -287,7 +281,7 @@ START_API_FUNC
return false;
}
);
- if(LIKELY(inveffect == effects_end))
+ if LIKELY(inveffect == effects_end)
{
/* All good. Delete non-0 effect IDs. */
std::for_each(effects, effects_end,
@@ -305,7 +299,7 @@ AL_API ALboolean AL_APIENTRY alIsEffect(ALuint effect)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(LIKELY(context))
+ if LIKELY(context)
{
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
@@ -320,13 +314,13 @@ AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint value)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
ALeffect *aleffect{LookupEffect(device, effect)};
- if(UNLIKELY(!aleffect))
+ if UNLIKELY(!aleffect)
context->setError(AL_INVALID_NAME, "Invalid effect ID %u", effect);
else
{
@@ -370,13 +364,13 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
ALeffect *aleffect{LookupEffect(device, effect)};
- if(UNLIKELY(!aleffect))
+ if UNLIKELY(!aleffect)
context->setError(AL_INVALID_NAME, "Invalid effect ID %u", effect);
else
{
@@ -390,13 +384,13 @@ AL_API ALvoid AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat value)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
ALeffect *aleffect{LookupEffect(device, effect)};
- if(UNLIKELY(!aleffect))
+ if UNLIKELY(!aleffect)
context->setError(AL_INVALID_NAME, "Invalid effect ID %u", effect);
else
{
@@ -410,13 +404,13 @@ AL_API ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, const ALfloat
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
ALeffect *aleffect{LookupEffect(device, effect)};
- if(UNLIKELY(!aleffect))
+ if UNLIKELY(!aleffect)
context->setError(AL_INVALID_NAME, "Invalid effect ID %u", effect);
else
{
@@ -430,13 +424,13 @@ AL_API ALvoid AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *value
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
const ALeffect *aleffect{LookupEffect(device, effect)};
- if(UNLIKELY(!aleffect))
+ if UNLIKELY(!aleffect)
context->setError(AL_INVALID_NAME, "Invalid effect ID %u", effect);
else
{
@@ -462,13 +456,13 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
const ALeffect *aleffect{LookupEffect(device, effect)};
- if(UNLIKELY(!aleffect))
+ if UNLIKELY(!aleffect)
context->setError(AL_INVALID_NAME, "Invalid effect ID %u", effect);
else
{
@@ -482,13 +476,13 @@ AL_API ALvoid AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *val
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
const ALeffect *aleffect{LookupEffect(device, effect)};
- if(UNLIKELY(!aleffect))
+ if UNLIKELY(!aleffect)
context->setError(AL_INVALID_NAME, "Invalid effect ID %u", effect);
else
{
@@ -502,13 +496,13 @@ AL_API ALvoid AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *va
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
const ALeffect *aleffect{LookupEffect(device, effect)};
- if(UNLIKELY(!aleffect))
+ if UNLIKELY(!aleffect)
context->setError(AL_INVALID_NAME, "Invalid effect ID %u", effect);
else
{
diff --git a/al/error.cpp b/al/error.cpp
index 8bd78fe2..a7080493 100644
--- a/al/error.cpp
+++ b/al/error.cpp
@@ -94,7 +94,7 @@ AL_API ALenum AL_APIENTRY alGetError(void)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context))
+ if UNLIKELY(!context)
{
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 06a2e008..530f9679 100644
--- a/al/event.cpp
+++ b/al/event.cpp
@@ -32,7 +32,7 @@ static int EventThread(ALCcontext *context)
{
RingBuffer *ring{context->mAsyncEvents.get()};
bool quitnow{false};
- while(LIKELY(!quitnow))
+ while LIKELY(!quitnow)
{
auto evt_data = ring->getReadVector().first;
if(evt_data.len == 0)
@@ -60,7 +60,7 @@ static int EventThread(ALCcontext *context)
} _{evt, ring};
quitnow = evt.EnumType == EventType_KillThread;
- if(UNLIKELY(quitnow)) break;
+ if UNLIKELY(quitnow) break;
if(evt.EnumType == EventType_ReleaseEffectState)
{
@@ -141,10 +141,10 @@ AL_API void AL_APIENTRY alEventControlSOFT(ALsizei count, const ALenum *types, A
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
- if(count < 0) SETERR_RETURN(context, AL_INVALID_VALUE,, "Controlling %d events", count);
- if(count == 0) return;
+ if(count < 0) context->setError(AL_INVALID_VALUE, "Controlling %d events", count);
+ if(count <= 0) return;
if(!types) SETERR_RETURN(context, AL_INVALID_VALUE,, "NULL pointer");
ALbitfieldSOFT flags{0};
@@ -202,7 +202,7 @@ AL_API void AL_APIENTRY alEventCallbackSOFT(ALEVENTPROCSOFT callback, void *user
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) 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 1b36e3db..ab759262 100644
--- a/al/extension.cpp
+++ b/al/extension.cpp
@@ -36,7 +36,7 @@ AL_API ALboolean AL_APIENTRY alIsExtensionPresent(const ALchar *extName)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return AL_FALSE;
+ if UNLIKELY(!context) return AL_FALSE;
if(!extName)
SETERR_RETURN(context, AL_INVALID_VALUE, AL_FALSE, "NULL pointer");
diff --git a/al/filter.cpp b/al/filter.cpp
index b52267f1..41a96513 100644
--- a/al/filter.cpp
+++ b/al/filter.cpp
@@ -288,7 +288,7 @@ ALfilter *AllocFilter(ALCcontext *context)
auto lidx = static_cast<ALsizei>(std::distance(device->FilterList.begin(), sublist));
ALfilter *filter{nullptr};
ALsizei slidx{0};
- if(LIKELY(sublist != device->FilterList.end()))
+ if LIKELY(sublist != device->FilterList.end())
{
slidx = CTZ64(sublist->FreeMask);
filter = sublist->Filters + slidx;
@@ -298,7 +298,7 @@ ALfilter *AllocFilter(ALCcontext *context)
/* Don't allocate so many list entries that the 32-bit ID could
* overflow...
*/
- if(UNLIKELY(device->FilterList.size() >= 1<<25))
+ if UNLIKELY(device->FilterList.size() >= 1<<25)
{
context->setError(AL_OUT_OF_MEMORY, "Too many filters allocated");
return nullptr;
@@ -307,7 +307,7 @@ ALfilter *AllocFilter(ALCcontext *context)
sublist = device->FilterList.end() - 1;
sublist->FreeMask = ~0_u64;
sublist->Filters = static_cast<ALfilter*>(al_calloc(16, sizeof(ALfilter)*64));
- if(UNLIKELY(!sublist->Filters))
+ if UNLIKELY(!sublist->Filters)
{
device->FilterList.pop_back();
context->setError(AL_OUT_OF_MEMORY, "Failed to allocate filter batch");
@@ -346,10 +346,10 @@ inline ALfilter *LookupFilter(ALCdevice *device, ALuint id)
ALuint lidx = (id-1) >> 6;
ALsizei slidx = (id-1) & 0x3f;
- if(UNLIKELY(lidx >= device->FilterList.size()))
+ if UNLIKELY(lidx >= device->FilterList.size())
return nullptr;
FilterSubList &sublist = device->FilterList[lidx];
- if(UNLIKELY(sublist.FreeMask & (1_u64 << slidx)))
+ if UNLIKELY(sublist.FreeMask & (1_u64 << slidx))
return nullptr;
return sublist.Filters + slidx;
}
@@ -360,21 +360,19 @@ AL_API ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
- if(UNLIKELY(n < 0))
- {
+ if UNLIKELY(n < 0)
context->setError(AL_INVALID_VALUE, "Generating %d filters", n);
- return;
- }
+ if UNLIKELY(n <= 0) return;
- if(LIKELY(n == 1))
+ if LIKELY(n == 1)
{
/* Special handling for the easy and normal case. */
ALfilter *filter = AllocFilter(context.get());
if(filter) filters[0] = filter->id;
}
- else if(n > 1)
+ else
{
/* Store the allocated buffer IDs in a separate local list, to avoid
* modifying the user storage in case of failure.
@@ -400,15 +398,11 @@ AL_API ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, const ALuint *filters)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
- if(UNLIKELY(n < 0))
- {
+ if UNLIKELY(n < 0)
context->setError(AL_INVALID_VALUE, "Deleting %d filters", n);
- return;
- }
- if(UNLIKELY(n == 0))
- return;
+ if UNLIKELY(n <= 0) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
@@ -420,7 +414,7 @@ START_API_FUNC
{
if(!fid) return false;
ALfilter *filter{LookupFilter(device, fid)};
- if(UNLIKELY(!filter))
+ if UNLIKELY(!filter)
{
context->setError(AL_INVALID_NAME, "Invalid filter ID %u", fid);
return true;
@@ -428,7 +422,7 @@ START_API_FUNC
return false;
}
);
- if(LIKELY(invflt == filters_end))
+ if LIKELY(invflt == filters_end)
{
/* All good. Delete non-0 filter IDs. */
std::for_each(filters, filters_end,
@@ -446,7 +440,7 @@ AL_API ALboolean AL_APIENTRY alIsFilter(ALuint filter)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(LIKELY(context))
+ if LIKELY(context)
{
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
@@ -462,13 +456,13 @@ AL_API ALvoid AL_APIENTRY alFilteri(ALuint filter, ALenum param, ALint value)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
ALfilter *alfilt{LookupFilter(device, filter)};
- if(UNLIKELY(!alfilt))
+ if UNLIKELY(!alfilt)
context->setError(AL_INVALID_NAME, "Invalid filter ID %u", filter);
else
{
@@ -500,13 +494,13 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
ALfilter *alfilt{LookupFilter(device, filter)};
- if(UNLIKELY(!alfilt))
+ if UNLIKELY(!alfilt)
context->setError(AL_INVALID_NAME, "Invalid filter ID %u", filter);
else
{
@@ -520,13 +514,13 @@ AL_API ALvoid AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat value)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
ALfilter *alfilt{LookupFilter(device, filter)};
- if(UNLIKELY(!alfilt))
+ if UNLIKELY(!alfilt)
context->setError(AL_INVALID_NAME, "Invalid filter ID %u", filter);
else
{
@@ -540,13 +534,13 @@ AL_API ALvoid AL_APIENTRY alFilterfv(ALuint filter, ALenum param, const ALfloat
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
ALfilter *alfilt{LookupFilter(device, filter)};
- if(UNLIKELY(!alfilt))
+ if UNLIKELY(!alfilt)
context->setError(AL_INVALID_NAME, "Invalid filter ID %u", filter);
else
{
@@ -560,13 +554,13 @@ AL_API ALvoid AL_APIENTRY alGetFilteri(ALuint filter, ALenum param, ALint *value
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
ALfilter *alfilt{LookupFilter(device, filter)};
- if(UNLIKELY(!alfilt))
+ if UNLIKELY(!alfilt)
context->setError(AL_INVALID_NAME, "Invalid filter ID %u", filter);
else
{
@@ -592,13 +586,13 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
ALfilter *alfilt{LookupFilter(device, filter)};
- if(UNLIKELY(!alfilt))
+ if UNLIKELY(!alfilt)
context->setError(AL_INVALID_NAME, "Invalid filter ID %u", filter);
else
{
@@ -612,13 +606,13 @@ AL_API ALvoid AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *val
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
ALfilter *alfilt{LookupFilter(device, filter)};
- if(UNLIKELY(!alfilt))
+ if UNLIKELY(!alfilt)
context->setError(AL_INVALID_NAME, "Invalid filter ID %u", filter);
else
{
@@ -632,13 +626,13 @@ AL_API ALvoid AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *va
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALCdevice *device{context->mDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
ALfilter *alfilt{LookupFilter(device, filter)};
- if(UNLIKELY(!alfilt))
+ if UNLIKELY(!alfilt)
context->setError(AL_INVALID_NAME, "Invalid filter ID %u", filter);
else
{
diff --git a/al/listener.cpp b/al/listener.cpp
index 3a1f32a4..aebf2aa5 100644
--- a/al/listener.cpp
+++ b/al/listener.cpp
@@ -46,7 +46,7 @@ AL_API ALvoid AL_APIENTRY alListenerf(ALenum param, ALfloat value)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
@@ -79,7 +79,7 @@ AL_API ALvoid AL_APIENTRY alListener3f(ALenum param, ALfloat value1, ALfloat val
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
@@ -129,7 +129,7 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
@@ -161,7 +161,7 @@ AL_API ALvoid AL_APIENTRY alListeneri(ALenum param, ALint /*value*/)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mPropLock};
switch(param)
@@ -184,7 +184,7 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mPropLock};
switch(param)
@@ -221,7 +221,7 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mPropLock};
if(!values)
@@ -239,7 +239,7 @@ AL_API ALvoid AL_APIENTRY alGetListenerf(ALenum param, ALfloat *value)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
@@ -265,7 +265,7 @@ AL_API ALvoid AL_APIENTRY alGetListener3f(ALenum param, ALfloat *value1, ALfloat
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
@@ -308,7 +308,7 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
@@ -337,7 +337,7 @@ AL_API ALvoid AL_APIENTRY alGetListeneri(ALenum param, ALint *value)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mPropLock};
if(!value)
@@ -354,7 +354,7 @@ AL_API void AL_APIENTRY alGetListener3i(ALenum param, ALint *value1, ALint *valu
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
@@ -392,7 +392,7 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
diff --git a/al/source.cpp b/al/source.cpp
index 69bdf6b5..9273a7a8 100644
--- a/al/source.cpp
+++ b/al/source.cpp
@@ -497,7 +497,7 @@ ALsource *AllocSource(ALCcontext *context)
auto lidx = static_cast<ALsizei>(std::distance(context->mSourceList.begin(), sublist));
ALsource *source;
ALsizei slidx;
- if(LIKELY(sublist != context->mSourceList.end()))
+ if LIKELY(sublist != context->mSourceList.end())
{
slidx = CTZ64(sublist->FreeMask);
source = sublist->Sources + slidx;
@@ -507,7 +507,7 @@ ALsource *AllocSource(ALCcontext *context)
/* Don't allocate so many list entries that the 32-bit ID could
* overflow...
*/
- if(UNLIKELY(context->mSourceList.size() >= 1<<25))
+ if UNLIKELY(context->mSourceList.size() >= 1<<25)
{
context->setError(AL_OUT_OF_MEMORY, "Too many sources allocated");
return nullptr;
@@ -517,7 +517,7 @@ ALsource *AllocSource(ALCcontext *context)
sublist->FreeMask = ~0_u64;
sublist->Sources = static_cast<ALsource*>(al_calloc(16, sizeof(ALsource)*64));
- if(UNLIKELY(!sublist->Sources))
+ if UNLIKELY(!sublist->Sources)
{
context->mSourceList.pop_back();
context->setError(AL_OUT_OF_MEMORY, "Failed to allocate source batch");
@@ -574,10 +574,10 @@ inline ALsource *LookupSource(ALCcontext *context, ALuint id) noexcept
ALuint lidx = (id-1) >> 6;
ALsizei slidx = (id-1) & 0x3f;
- if(UNLIKELY(lidx >= context->mSourceList.size()))
+ if UNLIKELY(lidx >= context->mSourceList.size())
return nullptr;
SourceSubList &sublist{context->mSourceList[lidx]};
- if(UNLIKELY(sublist.FreeMask & (1_u64 << slidx)))
+ if UNLIKELY(sublist.FreeMask & (1_u64 << slidx))
return nullptr;
return sublist.Sources + slidx;
}
@@ -587,10 +587,10 @@ inline ALbuffer *LookupBuffer(ALCdevice *device, ALuint id) noexcept
ALuint lidx = (id-1) >> 6;
ALsizei slidx = (id-1) & 0x3f;
- if(UNLIKELY(lidx >= device->BufferList.size()))
+ if UNLIKELY(lidx >= device->BufferList.size())
return nullptr;
BufferSubList &sublist = device->BufferList[lidx];
- if(UNLIKELY(sublist.FreeMask & (1_u64 << slidx)))
+ if UNLIKELY(sublist.FreeMask & (1_u64 << slidx))
return nullptr;
return sublist.Buffers + slidx;
}
@@ -600,10 +600,10 @@ inline ALfilter *LookupFilter(ALCdevice *device, ALuint id) noexcept
ALuint lidx = (id-1) >> 6;
ALsizei slidx = (id-1) & 0x3f;
- if(UNLIKELY(lidx >= device->FilterList.size()))
+ if UNLIKELY(lidx >= device->FilterList.size())
return nullptr;
FilterSubList &sublist = device->FilterList[lidx];
- if(UNLIKELY(sublist.FreeMask & (1_u64 << slidx)))
+ if UNLIKELY(sublist.FreeMask & (1_u64 << slidx))
return nullptr;
return sublist.Filters + slidx;
}
@@ -613,10 +613,10 @@ inline ALeffectslot *LookupEffectSlot(ALCcontext *context, ALuint id) noexcept
ALuint lidx = (id-1) >> 6;
ALsizei slidx = (id-1) & 0x3f;
- if(UNLIKELY(lidx >= context->mEffectSlotList.size()))
+ if UNLIKELY(lidx >= context->mEffectSlotList.size())
return nullptr;
EffectSlotSubList &sublist{context->mEffectSlotList[lidx]};
- if(UNLIKELY(sublist.FreeMask & (1_u64 << slidx)))
+ if UNLIKELY(sublist.FreeMask & (1_u64 << slidx))
return nullptr;
return sublist.EffectSlots + slidx;
}
@@ -870,7 +870,7 @@ bool SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, const a
bool SetSourcei64v(ALsource *Source, ALCcontext *Context, SourceProp prop, const al::span<const ALint64SOFT> values);
#define CHECKSIZE(v, s) do { \
- if(UNLIKELY((v).size() != INT_MAX && (v).size() != (s))) \
+ if UNLIKELY((v).size() != INT_MAX && (v).size() != (s)) \
{ \
Context->setError(AL_INVALID_ENUM, \
"Property 0x%04x expects %d value(s), got %zu", prop, (s), \
@@ -879,7 +879,7 @@ bool SetSourcei64v(ALsource *Source, ALCcontext *Context, SourceProp prop, const
} \
} while(0)
#define CHECKVAL(x) do { \
- if(UNLIKELY(!(x))) \
+ if UNLIKELY(!(x)) \
{ \
Context->setError(AL_INVALID_VALUE, "Value out of range"); \
return false; \
@@ -2077,9 +2077,9 @@ AL_API ALvoid AL_APIENTRY alGenSources(ALsizei n, ALuint *sources)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
- if(n < 0)
+ if UNLIKELY(n < 0)
context->setError(AL_INVALID_VALUE, "Generating %d sources", n);
else if(n == 1)
{
@@ -2111,9 +2111,9 @@ AL_API ALvoid AL_APIENTRY alDeleteSources(ALsizei n, const ALuint *sources)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
- if(n < 0)
+ if UNLIKELY(n < 0)
SETERR_RETURN(context, AL_INVALID_VALUE,, "Deleting %d sources", n);
std::lock_guard<std::mutex> _{context->mSourceLock};
@@ -2131,7 +2131,7 @@ START_API_FUNC
return true;
}
);
- if(LIKELY(invsrc == sources_end))
+ if LIKELY(invsrc == sources_end)
{
/* All good. Delete source IDs. */
std::for_each(sources, sources_end,
@@ -2149,7 +2149,7 @@ AL_API ALboolean AL_APIENTRY alIsSource(ALuint source)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(LIKELY(context))
+ if LIKELY(context)
{
std::lock_guard<std::mutex> _{context->mSourceLock};
if(LookupSource(context.get(), source) != nullptr)
@@ -2164,12 +2164,12 @@ AL_API ALvoid AL_APIENTRY alSourcef(ALuint source, ALenum param, ALfloat value)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mSourceLock};
ALsource *Source = LookupSource(context.get(), source);
- if(UNLIKELY(!Source))
+ if UNLIKELY(!Source)
context->setError(AL_INVALID_NAME, "Invalid source ID %u", source);
else
SetSourcefv(Source, context.get(), static_cast<SourceProp>(param), {&value, 1u});
@@ -2180,12 +2180,12 @@ AL_API ALvoid AL_APIENTRY alSource3f(ALuint source, ALenum param, ALfloat value1
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mSourceLock};
ALsource *Source = LookupSource(context.get(), source);
- if(UNLIKELY(!Source))
+ if UNLIKELY(!Source)
context->setError(AL_INVALID_NAME, "Invalid source ID %u", source);
else
{
@@ -2199,14 +2199,14 @@ AL_API ALvoid AL_APIENTRY alSourcefv(ALuint source, ALenum param, const ALfloat
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mSourceLock};
ALsource *Source = LookupSource(context.get(), source);
- if(UNLIKELY(!Source))
+ if UNLIKELY(!Source)
context->setError(AL_INVALID_NAME, "Invalid source ID %u", source);
- else if(!values)
+ else if UNLIKELY(!values)
context->setError(AL_INVALID_VALUE, "NULL pointer");
else
SetSourcefv(Source, context.get(), static_cast<SourceProp>(param), {values, INT_MAX});
@@ -2218,17 +2218,17 @@ AL_API ALvoid AL_APIENTRY alSourcedSOFT(ALuint source, ALenum param, ALdouble va
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mSourceLock};
ALsource *Source = LookupSource(context.get(), source);
- if(UNLIKELY(!Source))
+ if UNLIKELY(!Source)
context->setError(AL_INVALID_NAME, "Invalid source ID %u", source);
else
{
- const auto fval = static_cast<ALfloat>(value);
- SetSourcefv(Source, context.get(), static_cast<SourceProp>(param), {&fval, 1u});
+ const ALfloat fval[1]{static_cast<ALfloat>(value)};
+ SetSourcefv(Source, context.get(), static_cast<SourceProp>(param), fval);
}
}
END_API_FUNC
@@ -2237,12 +2237,12 @@ AL_API ALvoid AL_APIENTRY alSource3dSOFT(ALuint source, ALenum param, ALdouble v
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mSourceLock};
ALsource *Source = LookupSource(context.get(), source);
- if(UNLIKELY(!Source))
+ if UNLIKELY(!Source)
context->setError(AL_INVALID_NAME, "Invalid source ID %u", source);
else
{
@@ -2257,14 +2257,14 @@ AL_API ALvoid AL_APIENTRY alSourcedvSOFT(ALuint source, ALenum param, const ALdo
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mSourceLock};
ALsource *Source = LookupSource(context.get(), source);
- if(UNLIKELY(!Source))
+ if UNLIKELY(!Source)
context->setError(AL_INVALID_NAME, "Invalid source ID %u", source);
- else if(!values)
+ else if UNLIKELY(!values)
context->setError(AL_INVALID_VALUE, "NULL pointer");
else
{
@@ -2282,12 +2282,12 @@ AL_API ALvoid AL_APIENTRY alSourcei(ALuint source, ALenum param, ALint value)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mSourceLock};
ALsource *Source = LookupSource(context.get(), source);
- if(UNLIKELY(!Source))
+ if UNLIKELY(!Source)
context->setError(AL_INVALID_NAME, "Invalid source ID %u", source);
else
SetSourceiv(Source, context.get(), static_cast<SourceProp>(param), {&value, 1u});
@@ -2298,12 +2298,12 @@ AL_API void AL_APIENTRY alSource3i(ALuint source, ALenum param, ALint value1, AL
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mSourceLock};
ALsource *Source = LookupSource(context.get(), source);
- if(UNLIKELY(!Source))
+ if UNLIKELY(!Source)
context->setError(AL_INVALID_NAME, "Invalid source ID %u", source);
else
{
@@ -2317,14 +2317,14 @@ AL_API void AL_APIENTRY alSourceiv(ALuint source, ALenum param, const ALint *val
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mSourceLock};
ALsource *Source = LookupSource(context.get(), source);
- if(UNLIKELY(!Source))
+ if UNLIKELY(!Source)
context->setError(AL_INVALID_NAME, "Invalid source ID %u", source);
- else if(!values)
+ else if UNLIKELY(!values)
context->setError(AL_INVALID_VALUE, "NULL pointer");
else
SetSourceiv(Source, context.get(), static_cast<SourceProp>(param), {values, INT_MAX});
@@ -2336,12 +2336,12 @@ AL_API ALvoid AL_APIENTRY alSourcei64SOFT(ALuint source, ALenum param, ALint64SO
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mSourceLock};
ALsource *Source{LookupSource(context.get(), source)};
- if(UNLIKELY(!Source))
+ if UNLIKELY(!Source)
context->setError(AL_INVALID_NAME, "Invalid source ID %u", source);
else
SetSourcei64v(Source, context.get(), static_cast<SourceProp>(param), {&value, 1u});
@@ -2352,12 +2352,12 @@ AL_API void AL_APIENTRY alSource3i64SOFT(ALuint source, ALenum param, ALint64SOF
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mSourceLock};
ALsource *Source{LookupSource(context.get(), source)};
- if(UNLIKELY(!Source))
+ if UNLIKELY(!Source)
context->setError(AL_INVALID_NAME, "Invalid source ID %u", source);
else
{
@@ -2371,14 +2371,14 @@ AL_API void AL_APIENTRY alSourcei64vSOFT(ALuint source, ALenum param, const ALin
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mSourceLock};
ALsource *Source{LookupSource(context.get(), source)};
- if(UNLIKELY(!Source))
+ if UNLIKELY(!Source)
context->setError(AL_INVALID_NAME, "Invalid source ID %u", source);
- else if(!values)
+ else if UNLIKELY(!values)
context->setError(AL_INVALID_VALUE, "NULL pointer");
else
SetSourcei64v(Source, context.get(), static_cast<SourceProp>(param), {values, INT_MAX});
@@ -2390,19 +2390,19 @@ AL_API ALvoid AL_APIENTRY alGetSourcef(ALuint source, ALenum param, ALfloat *val
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mSourceLock};
ALsource *Source{LookupSource(context.get(), source)};
- if(UNLIKELY(!Source))
+ if UNLIKELY(!Source)
context->setError(AL_INVALID_NAME, "Invalid source ID %u", source);
- else if(!value)
+ else if UNLIKELY(!value)
context->setError(AL_INVALID_VALUE, "NULL pointer");
else
{
- ALdouble dval;
- if(GetSourcedv(Source, context.get(), static_cast<SourceProp>(param), {&dval, 1u}))
- *value = static_cast<ALfloat>(dval);
+ ALdouble dval[1];
+ if(GetSourcedv(Source, context.get(), static_cast<SourceProp>(param), dval))
+ *value = static_cast<ALfloat>(dval[1]);
}
}
END_API_FUNC
@@ -2411,13 +2411,13 @@ AL_API ALvoid AL_APIENTRY alGetSource3f(ALuint source, ALenum param, ALfloat *va
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mSourceLock};
ALsource *Source{LookupSource(context.get(), source)};
- if(UNLIKELY(!Source))
+ if UNLIKELY(!Source)
context->setError(AL_INVALID_NAME, "Invalid source ID %u", source);
- else if(!(value1 && value2 && value3))
+ else if UNLIKELY(!(value1 && value2 && value3))
context->setError(AL_INVALID_VALUE, "NULL pointer");
else
{
@@ -2436,13 +2436,13 @@ AL_API ALvoid AL_APIENTRY alGetSourcefv(ALuint source, ALenum param, ALfloat *va
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mSourceLock};
ALsource *Source{LookupSource(context.get(), source)};
- if(UNLIKELY(!Source))
+ if UNLIKELY(!Source)
context->setError(AL_INVALID_NAME, "Invalid source ID %u", source);
- else if(!values)
+ else if UNLIKELY(!values)
context->setError(AL_INVALID_VALUE, "NULL pointer");
else
{
@@ -2462,13 +2462,13 @@ AL_API void AL_APIENTRY alGetSourcedSOFT(ALuint source, ALenum param, ALdouble *
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mSourceLock};
ALsource *Source{LookupSource(context.get(), source)};
- if(UNLIKELY(!Source))
+ if UNLIKELY(!Source)
context->setError(AL_INVALID_NAME, "Invalid source ID %u", source);
- else if(!value)
+ else if UNLIKELY(!value)
context->setError(AL_INVALID_VALUE, "NULL pointer");
else
GetSourcedv(Source, context.get(), static_cast<SourceProp>(param), {value, 1u});
@@ -2479,13 +2479,13 @@ AL_API void AL_APIENTRY alGetSource3dSOFT(ALuint source, ALenum param, ALdouble
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mSourceLock};
ALsource *Source{LookupSource(context.get(), source)};
- if(UNLIKELY(!Source))
+ if UNLIKELY(!Source)
context->setError(AL_INVALID_NAME, "Invalid source ID %u", source);
- else if(!(value1 && value2 && value3))
+ else if UNLIKELY(!(value1 && value2 && value3))
context->setError(AL_INVALID_VALUE, "NULL pointer");
else
{
@@ -2504,13 +2504,13 @@ AL_API void AL_APIENTRY alGetSourcedvSOFT(ALuint source, ALenum param, ALdouble
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mSourceLock};
ALsource *Source{LookupSource(context.get(), source)};
- if(UNLIKELY(!Source))
+ if UNLIKELY(!Source)
context->setError(AL_INVALID_NAME, "Invalid source ID %u", source);
- else if(!values)
+ else if UNLIKELY(!values)
context->setError(AL_INVALID_VALUE, "NULL pointer");
else
GetSourcedv(Source, context.get(), static_cast<SourceProp>(param), {values, INT_MAX});
@@ -2522,13 +2522,13 @@ AL_API ALvoid AL_APIENTRY alGetSourcei(ALuint source, ALenum param, ALint *value
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mSourceLock};
ALsource *Source{LookupSource(context.get(), source)};
- if(UNLIKELY(!Source))
+ if UNLIKELY(!Source)
context->setError(AL_INVALID_NAME, "Invalid source ID %u", source);
- else if(!value)
+ else if UNLIKELY(!value)
context->setError(AL_INVALID_VALUE, "NULL pointer");
else
GetSourceiv(Source, context.get(), static_cast<SourceProp>(param), {value, 1u});
@@ -2539,13 +2539,13 @@ AL_API void AL_APIENTRY alGetSource3i(ALuint source, ALenum param, ALint *value1
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mSourceLock};
ALsource *Source{LookupSource(context.get(), source)};
- if(UNLIKELY(!Source))
+ if UNLIKELY(!Source)
context->setError(AL_INVALID_NAME, "Invalid source ID %u", source);
- else if(!(value1 && value2 && value3))
+ else if UNLIKELY(!(value1 && value2 && value3))
context->setError(AL_INVALID_VALUE, "NULL pointer");
else
{
@@ -2564,13 +2564,13 @@ AL_API void AL_APIENTRY alGetSourceiv(ALuint source, ALenum param, ALint *values
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mSourceLock};
ALsource *Source{LookupSource(context.get(), source)};
- if(UNLIKELY(!Source))
+ if UNLIKELY(!Source)
context->setError(AL_INVALID_NAME, "Invalid source ID %u", source);
- else if(!values)
+ else if UNLIKELY(!values)
context->setError(AL_INVALID_VALUE, "NULL pointer");
else
GetSourceiv(Source, context.get(), static_cast<SourceProp>(param), {values, INT_MAX});
@@ -2582,13 +2582,13 @@ AL_API void AL_APIENTRY alGetSourcei64SOFT(ALuint source, ALenum param, ALint64S
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mSourceLock};
ALsource *Source{LookupSource(context.get(), source)};
- if(UNLIKELY(!Source))
+ if UNLIKELY(!Source)
context->setError(AL_INVALID_NAME, "Invalid source ID %u", source);
- else if(!value)
+ else if UNLIKELY(!value)
context->setError(AL_INVALID_VALUE, "NULL pointer");
else
GetSourcei64v(Source, context.get(), static_cast<SourceProp>(param), {value, 1u});
@@ -2599,13 +2599,13 @@ AL_API void AL_APIENTRY alGetSource3i64SOFT(ALuint source, ALenum param, ALint64
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mSourceLock};
ALsource *Source{LookupSource(context.get(), source)};
- if(UNLIKELY(!Source))
+ if UNLIKELY(!Source)
context->setError(AL_INVALID_NAME, "Invalid source ID %u", source);
- else if(!(value1 && value2 && value3))
+ else if UNLIKELY(!(value1 && value2 && value3))
context->setError(AL_INVALID_VALUE, "NULL pointer");
else
{
@@ -2624,13 +2624,13 @@ AL_API void AL_APIENTRY alGetSourcei64vSOFT(ALuint source, ALenum param, ALint64
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mSourceLock};
ALsource *Source{LookupSource(context.get(), source)};
- if(UNLIKELY(!Source))
+ if UNLIKELY(!Source)
context->setError(AL_INVALID_NAME, "Invalid source ID %u", source);
- else if(!values)
+ else if UNLIKELY(!values)
context->setError(AL_INVALID_VALUE, "NULL pointer");
else
GetSourcei64v(Source, context.get(), static_cast<SourceProp>(param), {values, INT_MAX});
@@ -2647,16 +2647,16 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
- if(n < 0)
- SETERR_RETURN(context, AL_INVALID_VALUE,, "Playing %d sources", n);
- if(n == 0) return;
+ if UNLIKELY(n < 0)
+ context->setError(AL_INVALID_VALUE, "Playing %d sources", n);
+ if UNLIKELY(n <= 0) return;
al::vector<ALsource*> extra_sources;
std::array<ALsource*,16> source_storage;
ALsource **srchandles{source_storage.data()};
- if(UNLIKELY(static_cast<ALuint>(n) > source_storage.size()))
+ if UNLIKELY(static_cast<ALuint>(n) > source_storage.size())
{
extra_sources.resize(n);
srchandles = extra_sources.data();
@@ -2673,7 +2673,7 @@ START_API_FUNC
ALCdevice *device{context->mDevice.get()};
BackendLockGuard __{*device->Backend};
/* If the device is disconnected, go right to stopped. */
- if(UNLIKELY(!device->Connected.load(std::memory_order_acquire)))
+ if UNLIKELY(!device->Connected.load(std::memory_order_acquire))
{
/* TODO: Send state change event? */
std::for_each(srchandles, srchandles+n,
@@ -2699,18 +2699,18 @@ START_API_FUNC
return count;
}
);
- if(UNLIKELY(n > free_voices))
+ if UNLIKELY(n > free_voices)
{
/* Increment the number of voices to handle the request. */
const ALuint need_voices{static_cast<ALuint>(n) - free_voices};
const size_t rem_voices{context->mVoices->size() -
context->mVoiceCount.load(std::memory_order_relaxed)};
- if(UNLIKELY(need_voices > rem_voices))
+ if UNLIKELY(need_voices > rem_voices)
{
/* Allocate more voices to get enough. */
const size_t alloc_count{need_voices - rem_voices};
- if(UNLIKELY(context->mVoices->size() > std::numeric_limits<ALsizei>::max()-alloc_count))
+ if UNLIKELY(context->mVoices->size() > std::numeric_limits<ALsizei>::max()-alloc_count)
SETERR_RETURN(context, AL_OUT_OF_MEMORY,,
"Overflow increasing voice count to %zu + %zu", context->mVoices->size(),
alloc_count);
@@ -2732,7 +2732,7 @@ START_API_FUNC
BufferList = BufferList->mNext.load(std::memory_order_relaxed);
/* If there's nothing to play, go right to stopped. */
- if(UNLIKELY(!BufferList))
+ if UNLIKELY(!BufferList)
{
/* NOTE: A source without any playable buffers should not have an
* ALvoice since it shouldn't be in a playing or paused state. So
@@ -2908,16 +2908,16 @@ AL_API ALvoid AL_APIENTRY alSourcePausev(ALsizei n, const ALuint *sources)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
- if(n < 0)
- SETERR_RETURN(context, AL_INVALID_VALUE,, "Pausing %d sources", n);
- if(n == 0) return;
+ if UNLIKELY(n < 0)
+ context->setError(AL_INVALID_VALUE, "Pausing %d sources", n);
+ if UNLIKELY(n <= 0) return;
al::vector<ALsource*> extra_sources;
std::array<ALsource*,16> source_storage;
ALsource **srchandles{source_storage.data()};
- if(UNLIKELY(static_cast<ALuint>(n) > source_storage.size()))
+ if UNLIKELY(static_cast<ALuint>(n) > source_storage.size())
{
extra_sources.resize(n);
srchandles = extra_sources.data();
@@ -2963,16 +2963,16 @@ AL_API ALvoid AL_APIENTRY alSourceStopv(ALsizei n, const ALuint *sources)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
- if(n < 0)
- SETERR_RETURN(context, AL_INVALID_VALUE,, "Stopping %d sources", n);
- if(n == 0) return;
+ if UNLIKELY(n < 0)
+ context->setError(AL_INVALID_VALUE, "Stopping %d sources", n);
+ if UNLIKELY(n <= 0) return;
al::vector<ALsource*> extra_sources;
std::array<ALsource*,16> source_storage;
ALsource **srchandles{source_storage.data()};
- if(UNLIKELY(static_cast<ALuint>(n) > source_storage.size()))
+ if UNLIKELY(static_cast<ALuint>(n) > source_storage.size())
{
extra_sources.resize(n);
srchandles = extra_sources.data();
@@ -3025,16 +3025,16 @@ AL_API ALvoid AL_APIENTRY alSourceRewindv(ALsizei n, const ALuint *sources)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
- if(n < 0)
- SETERR_RETURN(context, AL_INVALID_VALUE,, "Rewinding %d sources", n);
- if(n == 0) return;
+ if UNLIKELY(n < 0)
+ context->setError(AL_INVALID_VALUE, "Rewinding %d sources", n);
+ if UNLIKELY(n <= 0) return;
al::vector<ALsource*> extra_sources;
std::array<ALsource*,16> source_storage;
ALsource **srchandles{source_storage.data()};
- if(UNLIKELY(static_cast<ALuint>(n) > source_storage.size()))
+ if UNLIKELY(static_cast<ALuint>(n) > source_storage.size())
{
extra_sources.resize(n);
srchandles = extra_sources.data();
@@ -3081,19 +3081,19 @@ AL_API ALvoid AL_APIENTRY alSourceQueueBuffers(ALuint src, ALsizei nb, const ALu
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
- if(nb < 0)
- SETERR_RETURN(context, AL_INVALID_VALUE,, "Queueing %d buffers", nb);
- if(nb == 0) return;
+ if UNLIKELY(nb < 0)
+ context->setError(AL_INVALID_VALUE, "Queueing %d buffers", nb);
+ if UNLIKELY(nb <= 0) return;
std::lock_guard<std::mutex> _{context->mSourceLock};
ALsource *source{LookupSource(context.get(),src)};
- if(UNLIKELY(!source))
+ if UNLIKELY(!source)
SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid source ID %u", src);
/* Can't queue on a Static Source */
- if(UNLIKELY(source->SourceType == AL_STATIC))
+ if UNLIKELY(source->SourceType == AL_STATIC)
SETERR_RETURN(context, AL_INVALID_OPERATION,, "Queueing onto static source %u", src);
/* Check for a valid Buffer, for its frequency and format */
@@ -3193,19 +3193,19 @@ AL_API void AL_APIENTRY alSourceQueueBufferLayersSOFT(ALuint src, ALsizei nb, co
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
- if(nb < 0)
- SETERR_RETURN(context, AL_INVALID_VALUE,, "Queueing %d buffer layers", nb);
- if(nb == 0) return;
+ if UNLIKELY(nb < 0)
+ context->setError(AL_INVALID_VALUE, "Queueing %d buffer layers", nb);
+ if UNLIKELY(nb <= 0) return;
std::lock_guard<std::mutex> _{context->mSourceLock};
ALsource *source{LookupSource(context.get(),src)};
- if(UNLIKELY(!source))
+ if UNLIKELY(!source)
SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid source ID %u", src);
/* Can't queue on a Static Source */
- if(UNLIKELY(source->SourceType == AL_STATIC))
+ if UNLIKELY(source->SourceType == AL_STATIC)
SETERR_RETURN(context, AL_INVALID_OPERATION,, "Queueing onto static source %u", src);
/* Check for a valid Buffer, for its frequency and format */
@@ -3296,20 +3296,20 @@ AL_API ALvoid AL_APIENTRY alSourceUnqueueBuffers(ALuint src, ALsizei nb, ALuint
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
- if(nb < 0)
- SETERR_RETURN(context, AL_INVALID_VALUE,, "Unqueueing %d buffers", nb);
- if(nb == 0) return;
+ if UNLIKELY(nb < 0)
+ context->setError(AL_INVALID_VALUE, "Unqueueing %d buffers", nb);
+ if UNLIKELY(nb <= 0) return;
std::lock_guard<std::mutex> _{context->mSourceLock};
ALsource *source{LookupSource(context.get(),src)};
- if(UNLIKELY(!source))
+ if UNLIKELY(!source)
SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid source ID %u", src);
- if(UNLIKELY(source->Looping))
+ if UNLIKELY(source->Looping)
SETERR_RETURN(context, AL_INVALID_VALUE,, "Unqueueing from looping source %u", src);
- if(UNLIKELY(source->SourceType != AL_STREAMING))
+ if UNLIKELY(source->SourceType != AL_STREAMING)
SETERR_RETURN(context, AL_INVALID_VALUE,, "Unqueueing from a non-streaming source %u",
src);
@@ -3321,7 +3321,7 @@ START_API_FUNC
Current = voice->mCurrentBuffer.load(std::memory_order_relaxed);
else if(source->state == AL_INITIAL)
Current = BufferList;
- if(UNLIKELY(BufferList == Current))
+ if UNLIKELY(BufferList == Current)
SETERR_RETURN(context, AL_INVALID_VALUE,, "Unqueueing pending buffers");
ALuint i{BufferList->mNumBuffers};
@@ -3331,7 +3331,7 @@ START_API_FUNC
* trying to unqueue pending buffers.
*/
ALbufferlistitem *next{BufferList->mNext.load(std::memory_order_relaxed)};
- if(UNLIKELY(!next) || UNLIKELY(next == Current))
+ if UNLIKELY(!next || next == Current)
SETERR_RETURN(context, AL_INVALID_VALUE,, "Unqueueing pending buffers");
BufferList = next;
diff --git a/al/state.cpp b/al/state.cpp
index 3e8f4d18..b0338296 100644
--- a/al/state.cpp
+++ b/al/state.cpp
@@ -90,7 +90,7 @@ AL_API ALvoid AL_APIENTRY alEnable(ALenum capability)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mPropLock};
switch(capability)
@@ -110,7 +110,7 @@ AL_API ALvoid AL_APIENTRY alDisable(ALenum capability)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
std::lock_guard<std::mutex> _{context->mPropLock};
switch(capability)
@@ -130,7 +130,7 @@ AL_API ALboolean AL_APIENTRY alIsEnabled(ALenum capability)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return AL_FALSE;
+ if UNLIKELY(!context) return AL_FALSE;
std::lock_guard<std::mutex> _{context->mPropLock};
ALboolean value{AL_FALSE};
@@ -152,7 +152,7 @@ AL_API ALboolean AL_APIENTRY alGetBoolean(ALenum pname)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return AL_FALSE;
+ if UNLIKELY(!context) return AL_FALSE;
std::lock_guard<std::mutex> _{context->mPropLock};
ALboolean value{AL_FALSE};
@@ -209,7 +209,7 @@ AL_API ALdouble AL_APIENTRY alGetDouble(ALenum pname)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return 0.0;
+ if UNLIKELY(!context) return 0.0;
std::lock_guard<std::mutex> _{context->mPropLock};
ALdouble value{0.0};
@@ -260,7 +260,7 @@ AL_API ALfloat AL_APIENTRY alGetFloat(ALenum pname)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return 0.0f;
+ if UNLIKELY(!context) return 0.0f;
std::lock_guard<std::mutex> _{context->mPropLock};
ALfloat value{0.0f};
@@ -311,7 +311,7 @@ AL_API ALint AL_APIENTRY alGetInteger(ALenum pname)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return 0;
+ if UNLIKELY(!context) return 0;
std::lock_guard<std::mutex> _{context->mPropLock};
ALint value{0};
@@ -362,7 +362,7 @@ extern "C" AL_API ALint64SOFT AL_APIENTRY alGetInteger64SOFT(ALenum pname)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return 0;
+ if UNLIKELY(!context) return 0_i64;
std::lock_guard<std::mutex> _{context->mPropLock};
ALint64SOFT value{0};
@@ -413,7 +413,7 @@ AL_API void* AL_APIENTRY alGetPointerSOFT(ALenum pname)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return nullptr;
+ if UNLIKELY(!context) return nullptr;
std::lock_guard<std::mutex> _{context->mPropLock};
void *value{nullptr};
@@ -456,7 +456,7 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
if(!values)
context->setError(AL_INVALID_VALUE, "NULL pointer");
@@ -489,7 +489,7 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
if(!values)
context->setError(AL_INVALID_VALUE, "NULL pointer");
@@ -522,7 +522,7 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
if(!values)
context->setError(AL_INVALID_VALUE, "NULL pointer");
@@ -555,7 +555,7 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
if(!values)
context->setError(AL_INVALID_VALUE, "NULL pointer");
@@ -588,7 +588,7 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
if(!values)
context->setError(AL_INVALID_VALUE, "NULL pointer");
@@ -615,7 +615,7 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
if(!values)
context->setError(AL_INVALID_VALUE, "NULL pointer");
@@ -631,7 +631,7 @@ AL_API const ALchar* AL_APIENTRY alGetString(ALenum pname)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return nullptr;
+ if UNLIKELY(!context) return nullptr;
const ALchar *value{nullptr};
switch(pname)
@@ -687,7 +687,7 @@ AL_API ALvoid AL_APIENTRY alDopplerFactor(ALfloat value)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
if(!(value >= 0.0f && std::isfinite(value)))
context->setError(AL_INVALID_VALUE, "Doppler factor %f out of range", value);
@@ -704,7 +704,7 @@ AL_API ALvoid AL_APIENTRY alDopplerVelocity(ALfloat value)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
if((context->mEnabledEvts.load(std::memory_order_relaxed)&EventType_Deprecated))
{
@@ -733,7 +733,7 @@ AL_API ALvoid AL_APIENTRY alSpeedOfSound(ALfloat value)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
if(!(value > 0.0f && std::isfinite(value)))
context->setError(AL_INVALID_VALUE, "Speed of sound %f out of range", value);
@@ -750,7 +750,7 @@ AL_API ALvoid AL_APIENTRY alDistanceModel(ALenum value)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
if(!(value == AL_INVERSE_DISTANCE || value == AL_INVERSE_DISTANCE_CLAMPED ||
value == AL_LINEAR_DISTANCE || value == AL_LINEAR_DISTANCE_CLAMPED ||
@@ -772,7 +772,7 @@ AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
context->deferUpdates();
}
@@ -782,7 +782,7 @@ AL_API ALvoid AL_APIENTRY alProcessUpdatesSOFT(void)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return;
+ if UNLIKELY(!context) return;
context->processUpdates();
}
@@ -800,7 +800,7 @@ START_API_FUNC
static_assert(al::size(ResamplerNames) == ResamplerMax+1, "Incorrect ResamplerNames list");
ContextRef context{GetContextRef()};
- if(UNLIKELY(!context)) return nullptr;
+ if UNLIKELY(!context) return nullptr;
const ALchar *value{nullptr};
switch(pname)