diff options
-rw-r--r-- | al/auxeffectslot.cpp | 56 | ||||
-rw-r--r-- | al/buffer.cpp | 224 | ||||
-rw-r--r-- | al/effect.cpp | 70 | ||||
-rw-r--r-- | al/error.cpp | 2 | ||||
-rw-r--r-- | al/event.cpp | 12 | ||||
-rw-r--r-- | al/extension.cpp | 2 | ||||
-rw-r--r-- | al/filter.cpp | 70 | ||||
-rw-r--r-- | al/listener.cpp | 24 | ||||
-rw-r--r-- | al/source.cpp | 268 | ||||
-rw-r--r-- | al/state.cpp | 46 | ||||
-rw-r--r-- | alc/alc.cpp | 2 | ||||
-rw-r--r-- | alc/alu.cpp | 12 | ||||
-rw-r--r-- | alc/backends/opensl.cpp | 2 | ||||
-rw-r--r-- | alc/backends/pulseaudio.cpp | 22 | ||||
-rw-r--r-- | alc/bformatdec.cpp | 4 | ||||
-rw-r--r-- | alc/effects/pshifter.cpp | 4 | ||||
-rw-r--r-- | alc/effects/reverb.cpp | 2 | ||||
-rw-r--r-- | alc/helpers.cpp | 2 | ||||
-rw-r--r-- | alc/logging.h | 8 | ||||
-rw-r--r-- | alc/mastering.cpp | 2 | ||||
-rw-r--r-- | alc/mixer/mixer_neon.cpp | 6 | ||||
-rw-r--r-- | alc/mixer/mixer_sse.cpp | 6 | ||||
-rw-r--r-- | alc/mixvoice.cpp | 16 | ||||
-rw-r--r-- | common/alexcpt.cpp | 2 | ||||
-rw-r--r-- | common/alnumeric.h | 6 | ||||
-rw-r--r-- | common/intrusive_ptr.h | 2 | ||||
-rw-r--r-- | common/opthelpers.h | 4 |
27 files changed, 428 insertions, 448 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) diff --git a/alc/alc.cpp b/alc/alc.cpp index 615fc154..f66654c2 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -4193,7 +4193,7 @@ START_API_FUNC device->Connected.store(true); ALCenum err{UpdateDeviceParams(dev.get(), attribs)}; - if(LIKELY(err == ALC_NO_ERROR)) return ALC_TRUE; + if LIKELY(err == ALC_NO_ERROR) return ALC_TRUE; alcSetError(dev.get(), err); if(err == ALC_INVALID_DEVICE) diff --git a/alc/alu.cpp b/alc/alu.cpp index 253dbe48..412bfffa 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -383,7 +383,7 @@ bool CalcEffectSlotParams(ALeffectslot *slot, ALCcontext *context, bool force) */ RingBuffer *ring{context->mAsyncEvents.get()}; auto evt_vec = ring->getWriteVector(); - if(LIKELY(evt_vec.first.len > 0)) + if LIKELY(evt_vec.first.len > 0) { AsyncEvent *evt{new (evt_vec.first.buf) AsyncEvent{EventType_ReleaseEffectState}}; evt->u.mEffectState = oldstate; @@ -1347,7 +1347,7 @@ void ProcessParamUpdates(ALCcontext *ctx, const ALeffectslotArray &slots, const al::span<ALvoice> voices) { IncrementRef(ctx->mUpdateCount); - if(LIKELY(!ctx->mHoldUpdates.load(std::memory_order_acquire))) + if LIKELY(!ctx->mHoldUpdates.load(std::memory_order_acquire)) { bool cforce{CalcContextParams(ctx)}; bool force{CalcListenerParams(ctx) || cforce}; @@ -1463,7 +1463,7 @@ void ApplyStablizer(FrontStablizer *Stablizer, const al::span<FloatBufferLine> B auto &DelayBuf = Stablizer->DelayBuf[i]; auto buffer_end = Buffer[i].begin() + SamplesToDo; - if(LIKELY(SamplesToDo >= ALsizei{FrontStablizer::DelayLength})) + if LIKELY(SamplesToDo >= ALsizei{FrontStablizer::DelayLength}) { auto delay_end = std::rotate(Buffer[i].begin(), buffer_end - FrontStablizer::DelayLength, buffer_end); @@ -1556,7 +1556,7 @@ void ApplyDistanceComp(const al::span<FloatBufferLine> Samples, const ALsizei Sa ALfloat *inout{al::assume_aligned<16>(chanbuffer.data())}; auto inout_end = inout + SamplesToDo; - if(LIKELY(SamplesToDo >= base)) + if LIKELY(SamplesToDo >= base) { auto delay_end = std::rotate(inout, inout_end - base, inout_end); std::swap_ranges(inout, delay_end, distbuf); @@ -1690,7 +1690,7 @@ void aluMixData(ALCdevice *device, ALvoid *OutBuffer, ALsizei NumSamples) /* Apply any needed post-process for finalizing the Dry mix to the * RealOut (Ambisonic decode, UHJ encode, etc). */ - if(LIKELY(device->PostProcess)) + if LIKELY(device->PostProcess) device->PostProcess(device, SamplesToDo); const al::span<FloatBufferLine> RealOut{device->RealOut.Buffer}; @@ -1718,7 +1718,7 @@ void aluMixData(ALCdevice *device, ALvoid *OutBuffer, ALsizei NumSamples) if(device->DitherDepth > 0.0f) ApplyDither(RealOut, &device->DitherSeed, device->DitherDepth, SamplesToDo); - if(LIKELY(OutBuffer)) + if LIKELY(OutBuffer) { /* Finally, interleave and convert samples, writing to the device's * output buffer. diff --git a/alc/backends/opensl.cpp b/alc/backends/opensl.cpp index b34dc0cb..d9a7836e 100644 --- a/alc/backends/opensl.cpp +++ b/alc/backends/opensl.cpp @@ -136,7 +136,7 @@ const char *res_str(SLresult result) } #define PRINTERR(x, s) do { \ - if(UNLIKELY((x) != SL_RESULT_SUCCESS)) \ + if UNLIKELY((x) != SL_RESULT_SUCCESS) \ ERR("%s: %s\n", (s), res_str((x))); \ } while(0) diff --git a/alc/backends/pulseaudio.cpp b/alc/backends/pulseaudio.cpp index da209c8d..2ddcc86d 100644 --- a/alc/backends/pulseaudio.cpp +++ b/alc/backends/pulseaudio.cpp @@ -379,7 +379,7 @@ pa_context *connect_context(std::unique_lock<std::mutex> &plock) if(!binname.fname.empty()) name = binname.fname.c_str(); - if(UNLIKELY(!pulse_mainloop)) + if UNLIKELY(!pulse_mainloop) { std::thread{pulse_mainloop_thread}.detach(); while(!pulse_mainloop) @@ -744,7 +744,7 @@ void PulsePlayback::streamWriteCallback(pa_stream *stream, size_t nbytes) aluMixData(mDevice, buf, nbytes/mFrameSize); int ret{pa_stream_write(stream, buf, nbytes, pa_xfree, 0, PA_SEEK_RELATIVE)}; - if(UNLIKELY(ret != PA_OK)) + if UNLIKELY(ret != PA_OK) ERR("Failed to write to stream: %d, %s\n", ret, pa_strerror(ret)); } @@ -1064,7 +1064,7 @@ ClockLatency PulsePlayback::getClockLatency() err = pa_stream_get_latency(mStream, &latency, &neg); } - if(UNLIKELY(err != 0)) + if UNLIKELY(err != 0) { /* FIXME: if err = -PA_ERR_NODATA, it means we were called too soon * after starting the stream and no timing info has been received from @@ -1075,7 +1075,7 @@ ClockLatency PulsePlayback::getClockLatency() latency = 0; neg = 0; } - else if(UNLIKELY(neg)) + else if UNLIKELY(neg) latency = 0; ret.Latency = std::chrono::microseconds{latency}; @@ -1328,24 +1328,24 @@ ALCenum PulseCapture::captureSamples(ALCvoid *buffer, ALCuint samples) { if(mCapBuffer.empty()) { - if(UNLIKELY(!mDevice->Connected.load(std::memory_order_acquire))) + if UNLIKELY(!mDevice->Connected.load(std::memory_order_acquire)) break; const pa_stream_state_t state{pa_stream_get_state(mStream)}; - if(UNLIKELY(!PA_STREAM_IS_GOOD(state))) + if UNLIKELY(!PA_STREAM_IS_GOOD(state)) { aluHandleDisconnect(mDevice, "Bad capture state: %u", state); break; } const void *capbuf; size_t caplen; - if(UNLIKELY(pa_stream_peek(mStream, &capbuf, &caplen) < 0)) + if UNLIKELY(pa_stream_peek(mStream, &capbuf, &caplen) < 0) { aluHandleDisconnect(mDevice, "Failed retrieving capture samples: %s", pa_strerror(pa_context_errno(mContext))); break; } if(caplen == 0) break; - if(UNLIKELY(!capbuf)) + if UNLIKELY(!capbuf) mCapLen = -static_cast<ssize_t>(caplen); else mCapLen = static_cast<ssize_t>(caplen); @@ -1353,7 +1353,7 @@ ALCenum PulseCapture::captureSamples(ALCvoid *buffer, ALCuint samples) } const size_t rem{minz(dstbuf.size(), mCapBuffer.size())}; - if(UNLIKELY(mCapLen < 0)) + if UNLIKELY(mCapLen < 0) std::fill_n(dstbuf.begin(), rem, mSilentVal); else std::copy_n(mCapBuffer.begin(), rem, dstbuf.begin()); @@ -1409,13 +1409,13 @@ ClockLatency PulseCapture::getClockLatency() err = pa_stream_get_latency(mStream, &latency, &neg); } - if(UNLIKELY(err != 0)) + if UNLIKELY(err != 0) { ERR("Failed to get stream latency: 0x%x\n", err); latency = 0; neg = 0; } - else if(UNLIKELY(neg)) + else if UNLIKELY(neg) latency = 0; ret.Latency = std::chrono::microseconds{latency}; diff --git a/alc/bformatdec.cpp b/alc/bformatdec.cpp index 6b20dd84..8319600e 100644 --- a/alc/bformatdec.cpp +++ b/alc/bformatdec.cpp @@ -160,7 +160,7 @@ void BFormatDec::process(const al::span<FloatBufferLine> OutBuffer, ALuint enabled{mEnabled}; for(FloatBufferLine &outbuf : OutBuffer) { - if(LIKELY(enabled&1)) + if LIKELY(enabled&1) { MixRowSamples(outbuf, (*mixmtx)[sHFBand], hfsamples, 0, SamplesToDo); MixRowSamples(outbuf, (*mixmtx)[sLFBand], lfsamples, 0, SamplesToDo); @@ -176,7 +176,7 @@ void BFormatDec::process(const al::span<FloatBufferLine> OutBuffer, ALuint enabled{mEnabled}; for(FloatBufferLine &outbuf : OutBuffer) { - if(LIKELY(enabled&1)) + if LIKELY(enabled&1) MixRowSamples(outbuf, *mixmtx, insamples, 0, SamplesToDo); ++mixmtx; enabled >>= 1; diff --git a/alc/effects/pshifter.cpp b/alc/effects/pshifter.cpp index a08052b9..819e510c 100644 --- a/alc/effects/pshifter.cpp +++ b/alc/effects/pshifter.cpp @@ -68,11 +68,11 @@ inline int double2int(double d) shift = ((conv.i64>>52)&0x7ff) - (1023+52); /* Over/underflow */ - if(UNLIKELY(shift >= 63 || shift < -52)) + if UNLIKELY(shift >= 63 || shift < -52) return 0; mant = (conv.i64&0xfffffffffffff_i64) | 0x10000000000000_i64; - if(LIKELY(shift < 0)) + if LIKELY(shift < 0) return (int)(mant >> -shift) * sign; return (int)(mant << shift) * sign; diff --git a/alc/effects/reverb.cpp b/alc/effects/reverb.cpp index 51a57360..a8c4523e 100644 --- a/alc/effects/reverb.cpp +++ b/alc/effects/reverb.cpp @@ -1484,7 +1484,7 @@ void ReverbState::process(const ALsizei samplesToDo, const FloatBufferLine *REST mDelay.write(offset, c, afmt[c].data()+base, todo); /* Process the samples for reverb. */ - if(UNLIKELY(fadeCount < FADE_SAMPLES)) + if UNLIKELY(fadeCount < FADE_SAMPLES) { auto fade = static_cast<ALfloat>(fadeCount); diff --git a/alc/helpers.cpp b/alc/helpers.cpp index e86af6ce..7a547168 100644 --- a/alc/helpers.cpp +++ b/alc/helpers.cpp @@ -478,7 +478,7 @@ void al_print(FILE *logfile, const char *fmt, ...) va_start(args, fmt); va_copy(args2, args); int msglen{std::vsnprintf(str, sizeof(stcmsg), fmt, args)}; - if(UNLIKELY(msglen >= 0 && static_cast<size_t>(msglen) >= sizeof(stcmsg))) + if UNLIKELY(msglen >= 0 && static_cast<size_t>(msglen) >= sizeof(stcmsg)) { dynmsg.resize(static_cast<size_t>(msglen) + 1u); str = dynmsg.data(); diff --git a/alc/logging.h b/alc/logging.h index 0bb0c87b..8a3e75e6 100644 --- a/alc/logging.h +++ b/alc/logging.h @@ -39,24 +39,24 @@ enum LogLevel { extern LogLevel gLogLevel; #define TRACEREF(...) do { \ - if(UNLIKELY(gLogLevel >= LogRef)) \ + if UNLIKELY(gLogLevel >= LogRef) \ AL_PRINT("(--)", __VA_ARGS__); \ } while(0) #define TRACE(...) do { \ - if(UNLIKELY(gLogLevel >= LogTrace)) \ + if UNLIKELY(gLogLevel >= LogTrace) \ AL_PRINT("(II)", __VA_ARGS__); \ LOG_ANDROID(ANDROID_LOG_DEBUG, __VA_ARGS__); \ } while(0) #define WARN(...) do { \ - if(UNLIKELY(gLogLevel >= LogWarning)) \ + if UNLIKELY(gLogLevel >= LogWarning) \ AL_PRINT("(WW)", __VA_ARGS__); \ LOG_ANDROID(ANDROID_LOG_WARN, __VA_ARGS__); \ } while(0) #define ERR(...) do { \ - if(UNLIKELY(gLogLevel >= LogError)) \ + if UNLIKELY(gLogLevel >= LogError) \ AL_PRINT("(EE)", __VA_ARGS__); \ LOG_ANDROID(ANDROID_LOG_ERROR, __VA_ARGS__); \ } while(0) diff --git a/alc/mastering.cpp b/alc/mastering.cpp index ec40001b..d4d87c25 100644 --- a/alc/mastering.cpp +++ b/alc/mastering.cpp @@ -314,7 +314,7 @@ void SignalDelay(Compressor *Comp, const ALsizei SamplesToDo, FloatBufferLine *O ALfloat *delaybuf{al::assume_aligned<16>(Comp->mDelay[c].data())}; auto inout_end = inout + SamplesToDo; - if(LIKELY(SamplesToDo >= lookAhead)) + if LIKELY(SamplesToDo >= lookAhead) { auto delay_end = std::rotate(inout, inout_end - lookAhead, inout_end); std::swap_ranges(inout, delay_end, delaybuf); diff --git a/alc/mixer/mixer_neon.cpp b/alc/mixer/mixer_neon.cpp index b4ca61d7..f43063ce 100644 --- a/alc/mixer/mixer_neon.cpp +++ b/alc/mixer/mixer_neon.cpp @@ -209,7 +209,7 @@ void Mix_<NEONTag>(const ALfloat *data, const al::span<FloatBufferLine> OutBuffe const ALfloat step{diff * delta}; ALfloat step_count{0.0f}; /* Mix with applying gain steps in aligned multiples of 4. */ - if(LIKELY(minsize > 3)) + if LIKELY(minsize > 3) { const float32x4_t four4{vdupq_n_f32(4.0f)}; const float32x4_t step4{vdupq_n_f32(step)}; @@ -258,7 +258,7 @@ void Mix_<NEONTag>(const ALfloat *data, const al::span<FloatBufferLine> OutBuffe if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD)) continue; - if(LIKELY(BufferSize-pos > 3)) + if LIKELY(BufferSize-pos > 3) { ALsizei todo{(BufferSize-pos) >> 2}; const float32x4_t gain4 = vdupq_n_f32(gain); @@ -289,7 +289,7 @@ void MixRow_<NEONTag>(FloatBufferLine &OutBuffer, const ALfloat *Gains, continue; ALsizei pos{0}; - if(LIKELY(BufferSize > 3)) + if LIKELY(BufferSize > 3) { ALsizei todo{BufferSize >> 2}; float32x4_t gain4{vdupq_n_f32(gain)}; diff --git a/alc/mixer/mixer_sse.cpp b/alc/mixer/mixer_sse.cpp index b52ef256..cff37d2b 100644 --- a/alc/mixer/mixer_sse.cpp +++ b/alc/mixer/mixer_sse.cpp @@ -165,7 +165,7 @@ void Mix_<SSETag>(const ALfloat *data, const al::span<FloatBufferLine> OutBuffer const ALfloat step{diff * delta}; ALfloat step_count{0.0f}; /* Mix with applying gain steps in aligned multiples of 4. */ - if(LIKELY(minsize > 3)) + if LIKELY(minsize > 3) { const __m128 four4{_mm_set1_ps(4.0f)}; const __m128 step4{_mm_set1_ps(step)}; @@ -211,7 +211,7 @@ void Mix_<SSETag>(const ALfloat *data, const al::span<FloatBufferLine> OutBuffer if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD)) continue; - if(LIKELY(BufferSize-pos > 3)) + if LIKELY(BufferSize-pos > 3) { ALsizei todo{(BufferSize-pos) >> 2}; const __m128 gain4{_mm_set1_ps(gain)}; @@ -242,7 +242,7 @@ void MixRow_<SSETag>(FloatBufferLine &OutBuffer, const ALfloat *Gains, continue; ALsizei pos{0}; - if(LIKELY(BufferSize > 3)) + if LIKELY(BufferSize > 3) { ALsizei todo{BufferSize >> 2}; const __m128 gain4 = _mm_set1_ps(gain); diff --git a/alc/mixvoice.cpp b/alc/mixvoice.cpp index 06324397..df955719 100644 --- a/alc/mixvoice.cpp +++ b/alc/mixvoice.cpp @@ -635,7 +635,7 @@ void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCc SrcData.begin()); std::fill(srciter, SrcData.end(), 0.0f); - if(UNLIKELY(!BufferListItem)) + if UNLIKELY(!BufferListItem) srciter = std::copy(chandata.mPrevSamples.begin()+MAX_RESAMPLE_PADDING, chandata.mPrevSamples.end(), srciter); else if(isstatic) @@ -645,7 +645,7 @@ void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCc srciter = LoadBufferQueue(BufferListItem, BufferLoopItem, NumChannels, SampleSize, chan, DataPosInt, {srciter, SrcData.end()}); - if(UNLIKELY(srciter != SrcData.end())) + if UNLIKELY(srciter != SrcData.end()) { /* If the source buffer wasn't filled, copy the last sample for * the remaining buffer. Ideally it should have ended with @@ -734,7 +734,7 @@ void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCc * and new target gains given how much of the fade time * this mix handles. */ - if(LIKELY(Counter > fademix)) + if LIKELY(Counter > fademix) { const ALfloat a{static_cast<ALfloat>(fademix) / static_cast<ALfloat>(Counter)}; @@ -758,7 +758,7 @@ void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCc parms.Hrtf.Old.Gain = TargetGain; } - if(LIKELY(fademix < DstBufferSize)) + if LIKELY(fademix < DstBufferSize) { const ALsizei todo{DstBufferSize - fademix}; ALfloat gain{TargetGain}; @@ -856,7 +856,7 @@ void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCc OutPos += DstBufferSize; Counter = maxi(DstBufferSize, Counter) - DstBufferSize; - if(UNLIKELY(!BufferListItem)) + if UNLIKELY(!BufferListItem) { /* Do nothing extra when there's no buffers. */ } @@ -879,7 +879,7 @@ void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCc /* Handle non-looping static source */ if(DataPosInt >= BufferListItem->mMaxSamples) { - if(LIKELY(vstate == ALvoice::Playing)) + if LIKELY(vstate == ALvoice::Playing) vstate = ALvoice::Stopped; BufferListItem = nullptr; break; @@ -898,7 +898,7 @@ void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCc BufferListItem = BufferListItem->mNext.load(std::memory_order_relaxed); if(!BufferListItem && !(BufferListItem=BufferLoopItem)) { - if(LIKELY(vstate == ALvoice::Playing)) + if LIKELY(vstate == ALvoice::Playing) vstate = ALvoice::Stopped; break; } @@ -908,7 +908,7 @@ void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCc voice->mFlags |= VOICE_IS_FADING; /* Don't update positions and buffers if we were stopping. */ - if(UNLIKELY(vstate == ALvoice::Stopping)) + if UNLIKELY(vstate == ALvoice::Stopping) { voice->mPlayState.store(ALvoice::Stopped, std::memory_order_release); return; diff --git a/common/alexcpt.cpp b/common/alexcpt.cpp index 9e04bbaf..5055e34f 100644 --- a/common/alexcpt.cpp +++ b/common/alexcpt.cpp @@ -17,7 +17,7 @@ backend_exception::backend_exception(ALCenum code, const char *msg, ...) : mErro va_start(args, msg); va_copy(args2, args); int msglen{std::vsnprintf(nullptr, 0, msg, args)}; - if(LIKELY(msglen > 0)) + if LIKELY(msglen > 0) { mMessage.resize(static_cast<size_t>(msglen)+1); std::vsnprintf(&mMessage[0], mMessage.length(), msg, args2); diff --git a/common/alnumeric.h b/common/alnumeric.h index 950eebe1..7035715c 100644 --- a/common/alnumeric.h +++ b/common/alnumeric.h @@ -246,11 +246,11 @@ inline int float2int(float f) noexcept shift = ((conv.i>>23)&0xff) - (127+23); /* Over/underflow */ - if(UNLIKELY(shift >= 31 || shift < -23)) + if UNLIKELY(shift >= 31 || shift < -23) return 0; mant = (conv.i&0x7fffff) | 0x800000; - if(LIKELY(shift < 0)) + if LIKELY(shift < 0) return (mant >> -shift) * sign; return (mant << shift) * sign; @@ -293,7 +293,7 @@ inline float fast_roundf(float f) noexcept sign = (conv.i>>31)&0x01; expo = (conv.i>>23)&0xff; - if(UNLIKELY(expo >= 150/*+23*/)) + if UNLIKELY(expo >= 150/*+23*/) { /* An exponent (base-2) of 23 or higher is incapable of sub-integral * precision, so it's already an integral value. We don't need to worry diff --git a/common/intrusive_ptr.h b/common/intrusive_ptr.h index 831b8302..fa76ad48 100644 --- a/common/intrusive_ptr.h +++ b/common/intrusive_ptr.h @@ -16,7 +16,7 @@ public: unsigned int release() noexcept { auto ref = DecrementRef(mRef); - if(UNLIKELY(ref == 0)) + if UNLIKELY(ref == 0) delete static_cast<T*>(this); return ref; } diff --git a/common/opthelpers.h b/common/opthelpers.h index c83229f5..58578c15 100644 --- a/common/opthelpers.h +++ b/common/opthelpers.h @@ -12,9 +12,9 @@ * required to be true, but it can result in more optimal code for the true * path at the expense of a less optimal false path. */ -#define LIKELY(x) __builtin_expect(!!(x), !false) +#define LIKELY(x) (__builtin_expect(!!(x), !false)) /* The opposite of LIKELY, optimizing the case where the condition is false. */ -#define UNLIKELY(x) __builtin_expect(!!(x), false) +#define UNLIKELY(x) (__builtin_expect(!!(x), false)) /* Unlike LIKELY, ASSUME requires the condition to be true or else it invokes * undefined behavior. It's essentially an assert without actually checking the * condition at run-time, allowing for stronger optimizations than LIKELY. |