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