diff options
-rw-r--r-- | al/auxeffectslot.cpp | 42 | ||||
-rw-r--r-- | al/buffer.cpp | 34 | ||||
-rw-r--r-- | al/event.cpp | 4 | ||||
-rw-r--r-- | al/extension.cpp | 5 | ||||
-rw-r--r-- | al/listener.cpp | 22 | ||||
-rw-r--r-- | al/source.cpp | 66 | ||||
-rw-r--r-- | alc/context.h | 6 |
7 files changed, 89 insertions, 90 deletions
diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp index e5d75440..d777bc1f 100644 --- a/al/auxeffectslot.cpp +++ b/al/auxeffectslot.cpp @@ -558,7 +558,7 @@ START_API_FUNC std::lock_guard<std::mutex> __{context->mEffectSlotLock}; ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot); if(!slot) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot); + return context->setError(AL_INVALID_NAME, "Invalid effect slot ID %u", effectslot); ALeffectslot *target{}; ALCdevice *device{}; @@ -576,7 +576,7 @@ START_API_FUNC else { if(value != 0) - SETERR_RETURN(context, AL_INVALID_VALUE,, "Invalid effect ID %u", value); + return context->setError(AL_INVALID_VALUE, "Invalid effect ID %u", value); err = slot->initEffect(AL_EFFECT_NULL, EffectProps{}, context.get()); } } @@ -598,7 +598,7 @@ START_API_FUNC case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO: if(!(value == AL_TRUE || value == AL_FALSE)) - SETERR_RETURN(context, AL_INVALID_VALUE,, + return context->setError(AL_INVALID_VALUE, "Effect slot auxiliary send auto out of range"); if(slot->AuxSendAuto == !!value) [[unlikely]] return; @@ -608,7 +608,7 @@ START_API_FUNC case AL_EFFECTSLOT_TARGET_SOFT: target = LookupEffectSlot(context.get(), static_cast<ALuint>(value)); if(value && !target) - SETERR_RETURN(context, AL_INVALID_VALUE,, "Invalid effect slot target ID"); + return context->setError(AL_INVALID_VALUE, "Invalid effect slot target ID"); if(slot->Target == target) [[unlikely]] return; if(target) @@ -617,7 +617,7 @@ START_API_FUNC while(checker && checker != slot) checker = checker->Target; if(checker) - SETERR_RETURN(context, AL_INVALID_OPERATION,, + return context->setError(AL_INVALID_OPERATION, "Setting target of effect slot ID %u to %u creates circular chain", slot->id, target->id); } @@ -642,7 +642,7 @@ START_API_FUNC device = context->mALDevice.get(); if(slot->mState == SlotState::Playing) - SETERR_RETURN(context, AL_INVALID_OPERATION,, + return context->setError(AL_INVALID_OPERATION, "Setting buffer on playing effect slot %u", slot->id); if(ALbuffer *buffer{slot->Buffer}) @@ -659,9 +659,9 @@ START_API_FUNC if(value) { buffer = LookupBuffer(device, static_cast<ALuint>(value)); - if(!buffer) SETERR_RETURN(context, AL_INVALID_VALUE,, "Invalid buffer ID"); + if(!buffer) return context->setError(AL_INVALID_VALUE, "Invalid buffer ID"); if(buffer->mCallback) - SETERR_RETURN(context, AL_INVALID_OPERATION,, + return context->setError(AL_INVALID_OPERATION, "Callback buffer not valid for effects"); IncrementRef(buffer->ref); @@ -678,10 +678,10 @@ START_API_FUNC break; case AL_EFFECTSLOT_STATE_SOFT: - SETERR_RETURN(context, AL_INVALID_OPERATION,, "AL_EFFECTSLOT_STATE_SOFT is read-only"); + return context->setError(AL_INVALID_OPERATION, "AL_EFFECTSLOT_STATE_SOFT is read-only"); default: - SETERR_RETURN(context, AL_INVALID_ENUM,, "Invalid effect slot integer property 0x%04x", + return context->setError(AL_INVALID_ENUM, "Invalid effect slot integer property 0x%04x", param); } UpdateProps(slot, context.get()); @@ -708,12 +708,12 @@ START_API_FUNC std::lock_guard<std::mutex> _{context->mEffectSlotLock}; ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot); if(!slot) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot); + return context->setError(AL_INVALID_NAME, "Invalid effect slot ID %u", effectslot); switch(param) { default: - SETERR_RETURN(context, AL_INVALID_ENUM,, + return context->setError(AL_INVALID_ENUM, "Invalid effect slot integer-vector property 0x%04x", param); } } @@ -729,20 +729,20 @@ START_API_FUNC std::lock_guard<std::mutex> __{context->mEffectSlotLock}; ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot); if(!slot) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot); + return context->setError(AL_INVALID_NAME, "Invalid effect slot ID %u", effectslot); switch(param) { case AL_EFFECTSLOT_GAIN: if(!(value >= 0.0f && value <= 1.0f)) - SETERR_RETURN(context, AL_INVALID_VALUE,, "Effect slot gain out of range"); + return context->setError(AL_INVALID_VALUE, "Effect slot gain out of range"); if(slot->Gain == value) [[unlikely]] return; slot->Gain = value; break; default: - SETERR_RETURN(context, AL_INVALID_ENUM,, "Invalid effect slot float property 0x%04x", + return context->setError(AL_INVALID_ENUM, "Invalid effect slot float property 0x%04x", param); } UpdateProps(slot, context.get()); @@ -765,12 +765,12 @@ START_API_FUNC std::lock_guard<std::mutex> _{context->mEffectSlotLock}; ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot); if(!slot) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot); + return context->setError(AL_INVALID_NAME, "Invalid effect slot ID %u", effectslot); switch(param) { default: - SETERR_RETURN(context, AL_INVALID_ENUM,, + return context->setError(AL_INVALID_ENUM, "Invalid effect slot float-vector property 0x%04x", param); } } @@ -786,7 +786,7 @@ START_API_FUNC std::lock_guard<std::mutex> _{context->mEffectSlotLock}; ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot); if(!slot) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot); + return context->setError(AL_INVALID_NAME, "Invalid effect slot ID %u", effectslot); switch(param) { @@ -838,7 +838,7 @@ START_API_FUNC std::lock_guard<std::mutex> _{context->mEffectSlotLock}; ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot); if(!slot) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot); + return context->setError(AL_INVALID_NAME, "Invalid effect slot ID %u", effectslot); switch(param) { @@ -858,7 +858,7 @@ START_API_FUNC std::lock_guard<std::mutex> _{context->mEffectSlotLock}; ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot); if(!slot) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot); + return context->setError(AL_INVALID_NAME, "Invalid effect slot ID %u", effectslot); switch(param) { @@ -888,7 +888,7 @@ START_API_FUNC std::lock_guard<std::mutex> _{context->mEffectSlotLock}; ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot); if(!slot) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot); + return context->setError(AL_INVALID_NAME, "Invalid effect slot ID %u", effectslot); switch(param) { diff --git a/al/buffer.cpp b/al/buffer.cpp index 21520cec..93daf4f5 100644 --- a/al/buffer.cpp +++ b/al/buffer.cpp @@ -532,13 +532,13 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, ALuint size, ALbitfieldSOFT access) { if(ReadRef(ALBuf->ref) != 0 || ALBuf->MappedAccess != 0) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_OPERATION,, "Modifying storage for in-use buffer %u", - ALBuf->id); + return context->setError(AL_INVALID_OPERATION, "Modifying storage for in-use buffer %u", + ALBuf->id); /* Currently no channel configurations need to be converted. */ auto DstChannels = FmtFromUserFmt(SrcChannels); if(!DstChannels) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_ENUM, , "Invalid format"); + return context->setError(AL_INVALID_ENUM, "Invalid format"); /* IMA4 and MSADPCM convert to 16-bit short. * @@ -549,18 +549,18 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, ALuint size, if((access&MAP_READ_WRITE_FLAGS)) { if(SrcType == UserFmtIMA4 || SrcType == UserFmtMSADPCM) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_VALUE,, "%s samples cannot be mapped", + return context->setError(AL_INVALID_VALUE, "%s samples cannot be mapped", NameFromUserFmtType(SrcType)); } auto DstType = (SrcType == UserFmtIMA4 || SrcType == UserFmtMSADPCM) ? al::make_optional(FmtShort) : FmtFromUserFmt(SrcType); if(!DstType) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_ENUM, , "Invalid format"); + return context->setError(AL_INVALID_ENUM, "Invalid format"); const ALuint unpackalign{ALBuf->UnpackAlign}; const ALuint align{SanitizeAlignment(SrcType, unpackalign)}; if(align < 1) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_VALUE,, "Invalid unpack alignment %u for %s samples", + return context->setError(AL_INVALID_VALUE, "Invalid unpack alignment %u for %s samples", unpackalign, NameFromUserFmtType(SrcType)); const ALuint ambiorder{IsBFormat(*DstChannels) ? ALBuf->UnpackAmbiOrder : @@ -570,11 +570,11 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, ALuint size, { /* Can only preserve data with the same format and alignment. */ if(ALBuf->mChannels != *DstChannels || ALBuf->OriginalType != SrcType) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_VALUE,, "Preserving data of mismatched format"); + return context->setError(AL_INVALID_VALUE, "Preserving data of mismatched format"); if(ALBuf->OriginalAlign != align) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_VALUE,, "Preserving data of mismatched alignment"); - if(ALBuf->mAmbiOrder != ambiorder) - SETERR_RETURN(context, AL_INVALID_VALUE,, "Preserving data of mismatched order"); + return context->setError(AL_INVALID_VALUE, "Preserving data of mismatched alignment"); + if(ALBuf->mAmbiOrder != ambiorder) [[unlikely]] + return context->setError(AL_INVALID_VALUE, "Preserving data of mismatched order"); } /* Convert the input/source size in bytes to sample frames using the unpack @@ -585,12 +585,12 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, ALuint size, (SrcType == UserFmtMSADPCM) ? (align-2)/2 + 7 : (align * BytesFromUserFmt(SrcType)))}; if((size%SrcByteAlign) != 0) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_VALUE,, + return context->setError(AL_INVALID_VALUE, "Data size %d is not a multiple of frame size %d (%d unpack alignment)", size, SrcByteAlign, align); if(size/SrcByteAlign > std::numeric_limits<ALsizei>::max()/align) [[unlikely]] - SETERR_RETURN(context, AL_OUT_OF_MEMORY,, + return context->setError(AL_OUT_OF_MEMORY, "Buffer size overflow, %d blocks x %d samples per block", size/SrcByteAlign, align); const ALuint frames{size / SrcByteAlign * align}; @@ -600,7 +600,7 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, ALuint size, ALuint NumChannels{ChannelsFromFmt(*DstChannels, ambiorder)}; ALuint FrameSize{NumChannels * BytesFromFmt(*DstType)}; if(frames > std::numeric_limits<size_t>::max()/FrameSize) [[unlikely]] - SETERR_RETURN(context, AL_OUT_OF_MEMORY,, + return context->setError(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}; @@ -609,7 +609,7 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, ALuint size, { ALCdevice &device = *context->mALDevice; if(!eax_x_ram_check_availability(device, *ALBuf, size)) - SETERR_RETURN(context, AL_OUT_OF_MEMORY,, + return context->setError(AL_OUT_OF_MEMORY, "Out of X-RAM memory (avail: %u, needed: %u)", device.eax_x_ram_free_size, size); } #endif @@ -687,18 +687,18 @@ void PrepareCallback(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, void *userptr) { if(ReadRef(ALBuf->ref) != 0 || ALBuf->MappedAccess != 0) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_OPERATION,, "Modifying callback for in-use buffer %u", + return context->setError(AL_INVALID_OPERATION, "Modifying callback for in-use buffer %u", ALBuf->id); /* Currently no channel configurations need to be converted. */ auto DstChannels = FmtFromUserFmt(SrcChannels); if(!DstChannels) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_ENUM,, "Invalid format"); + return context->setError(AL_INVALID_ENUM, "Invalid format"); /* IMA4 and MSADPCM convert to 16-bit short. Not supported with callbacks. */ auto DstType = FmtFromUserFmt(SrcType); if(!DstType) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_ENUM,, "Unsupported callback format"); + return context->setError(AL_INVALID_ENUM, "Unsupported callback format"); const ALuint ambiorder{IsBFormat(*DstChannels) ? ALBuf->UnpackAmbiOrder : (IsUHJ(*DstChannels) ? 1 : 0)}; diff --git a/al/event.cpp b/al/event.cpp index 19509d2f..2aceba3a 100644 --- a/al/event.cpp +++ b/al/event.cpp @@ -154,7 +154,7 @@ START_API_FUNC 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"); + if(!types) return context->setError(AL_INVALID_VALUE, "NULL pointer"); ContextBase::AsyncEventBitset flags{}; const ALenum *types_end = types+count; @@ -173,7 +173,7 @@ START_API_FUNC } ); if(bad_type != types_end) - SETERR_RETURN(context, AL_INVALID_ENUM,, "Invalid event type 0x%04x", *bad_type); + return context->setError(AL_INVALID_ENUM, "Invalid event type 0x%04x", *bad_type); if(enable) { diff --git a/al/extension.cpp b/al/extension.cpp index 3d01d6c1..3a84ee08 100644 --- a/al/extension.cpp +++ b/al/extension.cpp @@ -40,7 +40,10 @@ START_API_FUNC if(!context) [[unlikely]] return AL_FALSE; if(!extName) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_VALUE, AL_FALSE, "NULL pointer"); + { + context->setError(AL_INVALID_VALUE, "NULL pointer"); + return AL_FALSE; + } size_t len{strlen(extName)}; const char *ptr{context->mExtensionList}; diff --git a/al/listener.cpp b/al/listener.cpp index fb17ad55..4aa261dd 100644 --- a/al/listener.cpp +++ b/al/listener.cpp @@ -89,14 +89,14 @@ START_API_FUNC { case AL_GAIN: if(!(value >= 0.0f && std::isfinite(value))) - SETERR_RETURN(context, AL_INVALID_VALUE,, "Listener gain out of range"); + return context->setError(AL_INVALID_VALUE, "Listener gain out of range"); listener.Gain = value; UpdateProps(context.get()); break; case AL_METERS_PER_UNIT: if(!(value >= AL_MIN_METERS_PER_UNIT && value <= AL_MAX_METERS_PER_UNIT)) - SETERR_RETURN(context, AL_INVALID_VALUE,, "Listener meters per unit out of range"); + return context->setError(AL_INVALID_VALUE, "Listener meters per unit out of range"); listener.mMetersPerUnit = value; UpdateProps(context.get()); break; @@ -119,7 +119,7 @@ START_API_FUNC { case AL_POSITION: if(!(std::isfinite(value1) && std::isfinite(value2) && std::isfinite(value3))) - SETERR_RETURN(context, AL_INVALID_VALUE,, "Listener position out of range"); + return context->setError(AL_INVALID_VALUE, "Listener position out of range"); listener.Position[0] = value1; listener.Position[1] = value2; listener.Position[2] = value3; @@ -128,7 +128,7 @@ START_API_FUNC case AL_VELOCITY: if(!(std::isfinite(value1) && std::isfinite(value2) && std::isfinite(value3))) - SETERR_RETURN(context, AL_INVALID_VALUE,, "Listener velocity out of range"); + return context->setError(AL_INVALID_VALUE, "Listener velocity out of range"); listener.Velocity[0] = value1; listener.Velocity[1] = value2; listener.Velocity[2] = value3; @@ -163,15 +163,17 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(!context) [[unlikely]] return; + if(!values) [[unlikely]] + return context->setError(AL_INVALID_VALUE, "NULL pointer"); + ALlistener &listener = context->mListener; std::lock_guard<std::mutex> _{context->mPropLock}; - if(!values) SETERR_RETURN(context, AL_INVALID_VALUE,, "NULL pointer"); switch(param) { case AL_ORIENTATION: if(!(std::isfinite(values[0]) && std::isfinite(values[1]) && std::isfinite(values[2]) && std::isfinite(values[3]) && std::isfinite(values[4]) && std::isfinite(values[5]))) - SETERR_RETURN(context, AL_INVALID_VALUE,, "Listener orientation out of range"); + return context->setError(AL_INVALID_VALUE, "Listener orientation out of range"); /* AT then UP */ listener.OrientAt[0] = values[0]; listener.OrientAt[1] = values[1]; @@ -211,7 +213,8 @@ START_API_FUNC { case AL_POSITION: case AL_VELOCITY: - alListener3f(param, static_cast<ALfloat>(value1), static_cast<ALfloat>(value2), static_cast<ALfloat>(value3)); + alListener3f(param, static_cast<ALfloat>(value1), static_cast<ALfloat>(value2), + static_cast<ALfloat>(value3)); return; } @@ -237,7 +240,8 @@ START_API_FUNC { case AL_POSITION: case AL_VELOCITY: - alListener3f(param, static_cast<ALfloat>(values[0]), static_cast<ALfloat>(values[1]), static_cast<ALfloat>(values[2])); + alListener3f(param, static_cast<ALfloat>(values[0]), static_cast<ALfloat>(values[1]), + static_cast<ALfloat>(values[2])); return; case AL_ORIENTATION: @@ -256,7 +260,7 @@ START_API_FUNC if(!context) [[unlikely]] return; std::lock_guard<std::mutex> _{context->mPropLock}; - if(!values) + if(!values) [[unlikely]] context->setError(AL_INVALID_VALUE, "NULL pointer"); else switch(param) { diff --git a/al/source.cpp b/al/source.cpp index c18df656..b15d14d1 100644 --- a/al/source.cpp +++ b/al/source.cpp @@ -1238,7 +1238,7 @@ try { case AL_SEC_OFFSET_LATENCY_SOFT: case AL_SEC_OFFSET_CLOCK_SOFT: /* Query only */ - SETERR_RETURN(Context, AL_INVALID_OPERATION,, + return Context->setError(AL_INVALID_OPERATION, "Setting read-only source property 0x%04x", prop); case AL_PITCH: @@ -1348,7 +1348,7 @@ try { if(Voice *voice{GetSourceVoice(Source, Context)}) { auto vpos = GetSampleOffset(Source->mQueue, prop, values[0]); - if(!vpos) SETERR_RETURN(Context, AL_INVALID_VALUE,, "Invalid offset"); + if(!vpos) return Context->setError(AL_INVALID_VALUE, "Invalid offset"); if(SetVoiceOffset(voice, *vpos, Source, Context, Context->mALDevice.get())) return; @@ -1480,7 +1480,7 @@ try { case AL_BYTE_LENGTH_SOFT: case AL_SAMPLE_LENGTH_SOFT: /* Query only */ - SETERR_RETURN(Context, AL_INVALID_OPERATION,, + return Context->setError(AL_INVALID_OPERATION, "Setting read-only source property 0x%04x", prop); case AL_SOURCE_RELATIVE: @@ -1514,7 +1514,7 @@ try { { const ALenum state{GetSourceState(Source, GetSourceVoice(Source, Context))}; if(state == AL_PLAYING || state == AL_PAUSED) - SETERR_RETURN(Context, AL_INVALID_OPERATION,, + return Context->setError(AL_INVALID_OPERATION, "Setting buffer on playing or paused source %u", Source->id); } if(values[0]) @@ -1522,13 +1522,13 @@ try { std::lock_guard<std::mutex> _{device->BufferLock}; ALbuffer *buffer{LookupBuffer(device, static_cast<ALuint>(values[0]))}; if(!buffer) - SETERR_RETURN(Context, AL_INVALID_VALUE,, "Invalid buffer ID %u", + return Context->setError(AL_INVALID_VALUE, "Invalid buffer ID %u", static_cast<ALuint>(values[0])); if(buffer->MappedAccess && !(buffer->MappedAccess&AL_MAP_PERSISTENT_BIT_SOFT)) - SETERR_RETURN(Context, AL_INVALID_OPERATION,, + return Context->setError(AL_INVALID_OPERATION, "Setting non-persistently mapped buffer %u", buffer->id); if(buffer->mCallback && ReadRef(buffer->ref) != 0) - SETERR_RETURN(Context, AL_INVALID_OPERATION,, + return Context->setError(AL_INVALID_OPERATION, "Setting already-set callback buffer %u", buffer->id); /* Add the selected buffer to a one-item queue */ @@ -1571,7 +1571,7 @@ try { if(Voice *voice{GetSourceVoice(Source, Context)}) { auto vpos = GetSampleOffset(Source->mQueue, prop, values[0]); - if(!vpos) SETERR_RETURN(Context, AL_INVALID_VALUE,, "Invalid source offset"); + if(!vpos) return Context->setError(AL_INVALID_VALUE, "Invalid source offset"); if(SetVoiceOffset(voice, *vpos, Source, Context, device)) return; @@ -1587,7 +1587,7 @@ try { std::lock_guard<std::mutex> _{device->FilterLock}; ALfilter *filter{LookupFilter(device, static_cast<ALuint>(values[0]))}; if(!filter) - SETERR_RETURN(Context, AL_INVALID_VALUE,, "Invalid filter ID %u", + return Context->setError(AL_INVALID_VALUE, "Invalid filter ID %u", static_cast<ALuint>(values[0])); Source->Direct.Gain = filter->Gain; Source->Direct.GainHF = filter->GainHF; @@ -1672,7 +1672,7 @@ try { { const ALenum state{GetSourceState(Source, GetSourceVoice(Source, Context))}; if(state == AL_PLAYING || state == AL_PAUSED) - SETERR_RETURN(Context, AL_INVALID_OPERATION,, + return Context->setError(AL_INVALID_OPERATION, "Modifying stereo mode on playing or paused source %u", Source->id); } if(auto mode = StereoModeFromEnum(values[0])) @@ -1688,16 +1688,16 @@ try { CheckSize(3); slotlock = std::unique_lock<std::mutex>{Context->mEffectSlotLock}; if(values[0] && (slot=LookupEffectSlot(Context, static_cast<ALuint>(values[0]))) == nullptr) - SETERR_RETURN(Context, AL_INVALID_VALUE,, "Invalid effect ID %u", values[0]); + return Context->setError(AL_INVALID_VALUE, "Invalid effect ID %u", values[0]); if(static_cast<ALuint>(values[1]) >= device->NumAuxSends) - SETERR_RETURN(Context, AL_INVALID_VALUE,, "Invalid send %u", values[1]); + return Context->setError(AL_INVALID_VALUE, "Invalid send %u", values[1]); if(values[2]) { std::lock_guard<std::mutex> _{device->FilterLock}; ALfilter *filter{LookupFilter(device, static_cast<ALuint>(values[2]))}; if(!filter) - SETERR_RETURN(Context, AL_INVALID_VALUE,, "Invalid filter ID %u", values[2]); + return Context->setError(AL_INVALID_VALUE, "Invalid filter ID %u", values[2]); auto &send = Source->Send[static_cast<ALuint>(values[1])]; send.Gain = filter->Gain; @@ -1820,7 +1820,7 @@ try { case AL_SAMPLE_OFFSET_LATENCY_SOFT: case AL_SAMPLE_OFFSET_CLOCK_SOFT: /* Query only */ - SETERR_RETURN(Context, AL_INVALID_OPERATION,, + return Context->setError(AL_INVALID_OPERATION, "Setting read-only source property 0x%04x", prop); /* 1x int */ @@ -2741,7 +2741,8 @@ START_API_FUNC if(!context) [[unlikely]] return; if(n < 0) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_VALUE,, "Deleting %d sources", n); + context->setError(AL_INVALID_VALUE, "Deleting %d sources", n); + if(n <= 0) [[unlikely]] return; std::lock_guard<std::mutex> _{context->mSourceLock}; @@ -2752,10 +2753,7 @@ START_API_FUNC const ALuint *sources_end = sources + n; auto invsrc = std::find_if_not(sources, sources_end, validate_source); if(invsrc != sources_end) [[unlikely]] - { - context->setError(AL_INVALID_NAME, "Invalid source ID %u", *invsrc); - return; - } + return context->setError(AL_INVALID_NAME, "Invalid source ID %u", *invsrc); /* All good. Delete source IDs. */ auto delete_source = [&context](const ALuint sid) -> void @@ -3269,7 +3267,7 @@ START_API_FUNC std::lock_guard<std::mutex> _{context->mSourceLock}; ALsource *srchandle{LookupSource(context.get(), source)}; if(!srchandle) - SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid source ID %u", source); + return context->setError(AL_INVALID_NAME, "Invalid source ID %u", source); StartSources(context.get(), {&srchandle, 1}); } @@ -3282,12 +3280,12 @@ START_API_FUNC if(!context) [[unlikely]] return; if(start_time < 0) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_VALUE,, "Invalid time point %" PRId64, start_time); + return context->setError(AL_INVALID_VALUE, "Invalid time point %" PRId64, start_time); std::lock_guard<std::mutex> _{context->mSourceLock}; ALsource *srchandle{LookupSource(context.get(), source)}; if(!srchandle) - SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid source ID %u", source); + return context->setError(AL_INVALID_NAME, "Invalid source ID %u", source); StartSources(context.get(), {&srchandle, 1}, nanoseconds{start_time}); } @@ -3319,7 +3317,7 @@ START_API_FUNC { srchdl = LookupSource(context.get(), *sources); if(!srchdl) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid source ID %u", *sources); + return context->setError(AL_INVALID_NAME, "Invalid source ID %u", *sources); ++sources; } @@ -3338,7 +3336,7 @@ START_API_FUNC if(n <= 0) [[unlikely]] return; if(start_time < 0) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_VALUE,, "Invalid time point %" PRId64, start_time); + return context->setError(AL_INVALID_VALUE, "Invalid time point %" PRId64, start_time); al::vector<ALsource*> extra_sources; std::array<ALsource*,8> source_storage; @@ -3356,7 +3354,7 @@ START_API_FUNC { srchdl = LookupSource(context.get(), *sources); if(!srchdl) - SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid source ID %u", *sources); + return context->setError(AL_INVALID_NAME, "Invalid source ID %u", *sources); ++sources; } @@ -3396,7 +3394,7 @@ START_API_FUNC { srchdl = LookupSource(context.get(), *sources); if(!srchdl) - SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid source ID %u", *sources); + return context->setError(AL_INVALID_NAME, "Invalid source ID %u", *sources); ++sources; } @@ -3472,7 +3470,7 @@ START_API_FUNC { srchdl = LookupSource(context.get(), *sources); if(!srchdl) - SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid source ID %u", *sources); + return context->setError(AL_INVALID_NAME, "Invalid source ID %u", *sources); ++sources; } @@ -3535,7 +3533,7 @@ START_API_FUNC { srchdl = LookupSource(context.get(), *sources); if(!srchdl) - SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid source ID %u", *sources); + return context->setError(AL_INVALID_NAME, "Invalid source ID %u", *sources); ++sources; } @@ -3582,11 +3580,11 @@ START_API_FUNC std::lock_guard<std::mutex> _{context->mSourceLock}; ALsource *source{LookupSource(context.get(),src)}; if(!source) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid source ID %u", src); + return context->setError(AL_INVALID_NAME, "Invalid source ID %u", src); /* Can't queue on a Static Source */ if(source->SourceType == AL_STATIC) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_OPERATION,, "Queueing onto static source %u", src); + return context->setError(AL_INVALID_OPERATION, "Queueing onto static source %u", src); /* Check for a valid Buffer, for its frequency and format */ ALCdevice *device{context->mALDevice.get()}; @@ -3697,13 +3695,13 @@ START_API_FUNC std::lock_guard<std::mutex> _{context->mSourceLock}; ALsource *source{LookupSource(context.get(),src)}; if(!source) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid source ID %u", src); + return context->setError(AL_INVALID_NAME, "Invalid source ID %u", src); if(source->SourceType != AL_STREAMING) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_VALUE,, "Unqueueing from a non-streaming source %u", + return context->setError(AL_INVALID_VALUE, "Unqueueing from a non-streaming source %u", src); if(source->Looping) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_VALUE,, "Unqueueing from looping source %u", src); + return context->setError(AL_INVALID_VALUE, "Unqueueing from looping source %u", src); /* Make sure enough buffers have been processed to unqueue. */ uint processed{0u}; @@ -3720,7 +3718,7 @@ START_API_FUNC } } if(processed < static_cast<ALuint>(nb)) [[unlikely]] - SETERR_RETURN(context, AL_INVALID_VALUE,, "Unqueueing %d buffer%s (only %u processed)", + return context->setError(AL_INVALID_VALUE, "Unqueueing %d buffer%s (only %u processed)", nb, (nb==1)?"":"s", processed); do { diff --git a/alc/context.h b/alc/context.h index 448ae980..58a70184 100644 --- a/alc/context.h +++ b/alc/context.h @@ -514,12 +514,6 @@ private: #endif // ALSOFT_EAX }; -#define SETERR_RETURN(ctx, err, retval, ...) do { \ - (ctx)->setError((err), __VA_ARGS__); \ - return retval; \ -} while(0) - - using ContextRef = al::intrusive_ptr<ALCcontext>; ContextRef GetContextRef(void); |