aboutsummaryrefslogtreecommitdiffstats
path: root/al
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-05-14 19:39:25 -0700
committerChris Robinson <[email protected]>2023-05-14 19:39:25 -0700
commit5d89ea32c2bb6d5a137cb345bec616b0d6708789 (patch)
tree6e914a89d45d2cacce34c265e03d9ab3b02024ef /al
parent5ab9ce58808a6c92bbb92c8f58d7694cb86e5414 (diff)
Don't check for a null context in direct functions
Diffstat (limited to 'al')
-rw-r--r--al/auxeffectslot.cpp39
-rw-r--r--al/buffer.cpp89
-rw-r--r--al/debug.cpp51
-rw-r--r--al/direct_defs.h62
-rw-r--r--al/effect.cpp41
-rw-r--r--al/error.cpp11
-rw-r--r--al/event.cpp6
-rw-r--r--al/extension.cpp3
-rw-r--r--al/filter.cpp41
-rw-r--r--al/listener.cpp36
-rw-r--r--al/source.cpp130
-rw-r--r--al/state.cpp50
12 files changed, 125 insertions, 434 deletions
diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp
index 5fa8fe55..d4f80ca2 100644
--- a/al/auxeffectslot.cpp
+++ b/al/auxeffectslot.cpp
@@ -313,9 +313,6 @@ inline void UpdateProps(ALeffectslot *slot, ALCcontext *context)
FORCE_ALIGN void AL_APIENTRY alGenAuxiliaryEffectSlotsDirect(ALCcontext *context, ALsizei n,
ALuint *effectslots) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(n < 0) UNLIKELY
context->setError(AL_INVALID_VALUE, "Generating %d effect slots", n);
if(n <= 0) UNLIKELY return;
@@ -356,9 +353,6 @@ FORCE_ALIGN void AL_APIENTRY alGenAuxiliaryEffectSlotsDirect(ALCcontext *context
FORCE_ALIGN void AL_APIENTRY alDeleteAuxiliaryEffectSlotsDirect(ALCcontext *context, ALsizei n,
const ALuint *effectslots) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(n < 0) UNLIKELY
context->setError(AL_INVALID_VALUE, "Deleting %d effect slots", n);
if(n <= 0) UNLIKELY return;
@@ -419,12 +413,9 @@ FORCE_ALIGN void AL_APIENTRY alDeleteAuxiliaryEffectSlotsDirect(ALCcontext *cont
FORCE_ALIGN ALboolean AL_APIENTRY alIsAuxiliaryEffectSlotDirect(ALCcontext *context,
ALuint effectslot) noexcept
{
- if(context) LIKELY
- {
- std::lock_guard<std::mutex> _{context->mEffectSlotLock};
- if(LookupEffectSlot(context, effectslot) != nullptr)
- return AL_TRUE;
- }
+ std::lock_guard<std::mutex> _{context->mEffectSlotLock};
+ if(LookupEffectSlot(context, effectslot) != nullptr)
+ return AL_TRUE;
return AL_FALSE;
}
@@ -541,9 +532,6 @@ END_API_FUNC
FORCE_ALIGN void AL_APIENTRY alAuxiliaryEffectSlotiDirect(ALCcontext *context, ALuint effectslot,
ALenum param, ALint value) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mEffectSlotLock};
ALeffectslot *slot = LookupEffectSlot(context, effectslot);
@@ -691,9 +679,6 @@ FORCE_ALIGN void AL_APIENTRY alAuxiliaryEffectSlotivDirect(ALCcontext *context,
return;
}
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mEffectSlotLock};
ALeffectslot *slot = LookupEffectSlot(context, effectslot);
if(!slot) UNLIKELY
@@ -710,9 +695,6 @@ FORCE_ALIGN void AL_APIENTRY alAuxiliaryEffectSlotivDirect(ALCcontext *context,
FORCE_ALIGN void AL_APIENTRY alAuxiliaryEffectSlotfDirect(ALCcontext *context, ALuint effectslot,
ALenum param, ALfloat value) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mEffectSlotLock};
ALeffectslot *slot = LookupEffectSlot(context, effectslot);
@@ -746,9 +728,6 @@ FORCE_ALIGN void AL_APIENTRY alAuxiliaryEffectSlotfvDirect(ALCcontext *context,
return;
}
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mEffectSlotLock};
ALeffectslot *slot = LookupEffectSlot(context, effectslot);
if(!slot) UNLIKELY
@@ -766,9 +745,6 @@ FORCE_ALIGN void AL_APIENTRY alAuxiliaryEffectSlotfvDirect(ALCcontext *context,
FORCE_ALIGN void AL_APIENTRY alGetAuxiliaryEffectSlotiDirect(ALCcontext *context,
ALuint effectslot, ALenum param, ALint *value) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mEffectSlotLock};
ALeffectslot *slot = LookupEffectSlot(context, effectslot);
if(!slot) UNLIKELY
@@ -817,9 +793,6 @@ FORCE_ALIGN void AL_APIENTRY alGetAuxiliaryEffectSlotivDirect(ALCcontext *contex
return;
}
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mEffectSlotLock};
ALeffectslot *slot = LookupEffectSlot(context, effectslot);
if(!slot) UNLIKELY
@@ -836,9 +809,6 @@ FORCE_ALIGN void AL_APIENTRY alGetAuxiliaryEffectSlotivDirect(ALCcontext *contex
FORCE_ALIGN void AL_APIENTRY alGetAuxiliaryEffectSlotfDirect(ALCcontext *context,
ALuint effectslot, ALenum param, ALfloat *value) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mEffectSlotLock};
ALeffectslot *slot = LookupEffectSlot(context, effectslot);
if(!slot) UNLIKELY
@@ -865,9 +835,6 @@ FORCE_ALIGN void AL_APIENTRY alGetAuxiliaryEffectSlotfvDirect(ALCcontext *contex
return;
}
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mEffectSlotLock};
ALeffectslot *slot = LookupEffectSlot(context, effectslot);
if(!slot) UNLIKELY
diff --git a/al/buffer.cpp b/al/buffer.cpp
index 291871e5..6d0eec7f 100644
--- a/al/buffer.cpp
+++ b/al/buffer.cpp
@@ -638,9 +638,6 @@ std::optional<DecompResult> DecomposeUserFormat(ALenum format)
FORCE_ALIGN void AL_APIENTRY alGenBuffersDirect(ALCcontext *context, ALsizei n, ALuint *buffers) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(n < 0) UNLIKELY
context->setError(AL_INVALID_VALUE, "Generating %d buffers", n);
if(n <= 0) UNLIKELY return;
@@ -677,9 +674,6 @@ FORCE_ALIGN void AL_APIENTRY alGenBuffersDirect(ALCcontext *context, ALsizei n,
FORCE_ALIGN void AL_APIENTRY alDeleteBuffersDirect(ALCcontext *context, ALsizei n,
const ALuint *buffers) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(n < 0) UNLIKELY
context->setError(AL_INVALID_VALUE, "Deleting %d buffers", n);
if(n <= 0) UNLIKELY return;
@@ -719,20 +713,21 @@ FORCE_ALIGN void AL_APIENTRY alDeleteBuffersDirect(ALCcontext *context, ALsizei
FORCE_ALIGN ALboolean AL_APIENTRY alIsBufferDirect(ALCcontext *context, ALuint buffer) noexcept
{
- if(context) LIKELY
- {
- ALCdevice *device{context->mALDevice.get()};
- std::lock_guard<std::mutex> _{device->BufferLock};
- if(!buffer || LookupBuffer(device, buffer))
- return AL_TRUE;
- }
+ ALCdevice *device{context->mALDevice.get()};
+ std::lock_guard<std::mutex> _{device->BufferLock};
+ if(!buffer || LookupBuffer(device, buffer))
+ return AL_TRUE;
return AL_FALSE;
}
AL_API void AL_APIENTRY alBufferData(ALuint buffer, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq)
START_API_FUNC
-{ alBufferStorageDirectSOFT(GetContextRef().get(), buffer, format, data, size, freq, 0); }
+{
+ auto context = GetContextRef();
+ if(!context) UNLIKELY return;
+ alBufferStorageDirectSOFT(context.get(), buffer, format, data, size, freq, 0);
+}
END_API_FUNC
FORCE_ALIGN void AL_APIENTRY alBufferDataDirect(ALCcontext *context, ALuint buffer, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq) noexcept
@@ -741,9 +736,6 @@ FORCE_ALIGN void AL_APIENTRY alBufferDataDirect(ALCcontext *context, ALuint buff
FORCE_ALIGN void AL_APIENTRY alBufferStorageDirectSOFT(ALCcontext *context, ALuint buffer,
ALenum format, const ALvoid *data, ALsizei size, ALsizei freq, ALbitfieldSOFT flags) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
@@ -776,9 +768,6 @@ FORCE_ALIGN void AL_APIENTRY alBufferStorageDirectSOFT(ALCcontext *context, ALui
FORCE_ALIGN void AL_APIENTRY alBufferDataStaticDirect(ALCcontext *context, const ALuint buffer,
ALenum format, ALvoid *data, ALsizei size, ALsizei freq) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
@@ -801,9 +790,6 @@ FORCE_ALIGN void AL_APIENTRY alBufferDataStaticDirect(ALCcontext *context, const
FORCE_ALIGN void* AL_APIENTRY alMapBufferDirectSOFT(ALCcontext *context, ALuint buffer,
ALsizei offset, ALsizei length, ALbitfieldSOFT access) noexcept
{
- if(!context) UNLIKELY
- return nullptr;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
@@ -853,9 +839,6 @@ FORCE_ALIGN void* AL_APIENTRY alMapBufferDirectSOFT(ALCcontext *context, ALuint
FORCE_ALIGN void AL_APIENTRY alUnmapBufferDirectSOFT(ALCcontext *context, ALuint buffer) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
@@ -875,9 +858,6 @@ FORCE_ALIGN void AL_APIENTRY alUnmapBufferDirectSOFT(ALCcontext *context, ALuint
FORCE_ALIGN void AL_APIENTRY alFlushMappedBufferDirectSOFT(ALCcontext *context, ALuint buffer,
ALsizei offset, ALsizei length) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
@@ -906,9 +886,6 @@ FORCE_ALIGN void AL_APIENTRY alFlushMappedBufferDirectSOFT(ALCcontext *context,
FORCE_ALIGN void AL_APIENTRY alBufferSubDataDirectSOFT(ALCcontext *context, ALuint buffer,
ALenum format, const ALvoid *data, ALsizei offset, ALsizei length) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
@@ -965,9 +942,6 @@ FORCE_ALIGN void AL_APIENTRY alBufferSubDataDirectSOFT(ALCcontext *context, ALui
FORCE_ALIGN void AL_APIENTRY alBufferfDirect(ALCcontext *context, ALuint buffer, ALenum param,
ALfloat /*value*/) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
@@ -983,9 +957,6 @@ FORCE_ALIGN void AL_APIENTRY alBufferfDirect(ALCcontext *context, ALuint buffer,
FORCE_ALIGN void AL_APIENTRY alBuffer3fDirect(ALCcontext *context, ALuint buffer, ALenum param,
ALfloat /*value1*/, ALfloat /*value2*/, ALfloat /*value3*/) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
@@ -1001,9 +972,6 @@ FORCE_ALIGN void AL_APIENTRY alBuffer3fDirect(ALCcontext *context, ALuint buffer
FORCE_ALIGN void AL_APIENTRY alBufferfvDirect(ALCcontext *context, ALuint buffer, ALenum param,
const ALfloat *values) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
@@ -1022,9 +990,6 @@ FORCE_ALIGN void AL_APIENTRY alBufferfvDirect(ALCcontext *context, ALuint buffer
FORCE_ALIGN void AL_APIENTRY alBufferiDirect(ALCcontext *context, ALuint buffer, ALenum param,
ALint value) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
@@ -1082,9 +1047,6 @@ FORCE_ALIGN void AL_APIENTRY alBufferiDirect(ALCcontext *context, ALuint buffer,
FORCE_ALIGN void AL_APIENTRY alBuffer3iDirect(ALCcontext *context, ALuint buffer, ALenum param,
ALint /*value1*/, ALint /*value2*/, ALint /*value3*/) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
@@ -1114,9 +1076,6 @@ FORCE_ALIGN void AL_APIENTRY alBufferivDirect(ALCcontext *context, ALuint buffer
}
}
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
@@ -1151,9 +1110,6 @@ FORCE_ALIGN void AL_APIENTRY alBufferivDirect(ALCcontext *context, ALuint buffer
FORCE_ALIGN void AL_APIENTRY alGetBufferfDirect(ALCcontext *context, ALuint buffer, ALenum param,
ALfloat *value) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
@@ -1177,9 +1133,6 @@ FORCE_ALIGN void AL_APIENTRY alGetBufferfDirect(ALCcontext *context, ALuint buff
FORCE_ALIGN void AL_APIENTRY alGetBuffer3fDirect(ALCcontext *context, ALuint buffer, ALenum param,
ALfloat *value1, ALfloat *value2, ALfloat *value3) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
@@ -1204,9 +1157,6 @@ FORCE_ALIGN void AL_APIENTRY alGetBufferfvDirect(ALCcontext *context, ALuint buf
return;
}
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
@@ -1225,9 +1175,6 @@ FORCE_ALIGN void AL_APIENTRY alGetBufferfvDirect(ALCcontext *context, ALuint buf
FORCE_ALIGN void AL_APIENTRY alGetBufferiDirect(ALCcontext *context, ALuint buffer, ALenum param,
ALint *value) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
@@ -1291,9 +1238,6 @@ FORCE_ALIGN void AL_APIENTRY alGetBufferiDirect(ALCcontext *context, ALuint buff
FORCE_ALIGN void AL_APIENTRY alGetBuffer3iDirect(ALCcontext *context, ALuint buffer, ALenum param,
ALint *value1, ALint *value2, ALint *value3) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
if(LookupBuffer(device, buffer) == nullptr) UNLIKELY
@@ -1328,9 +1272,6 @@ FORCE_ALIGN void AL_APIENTRY alGetBufferivDirect(ALCcontext *context, ALuint buf
return;
}
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
@@ -1354,9 +1295,6 @@ FORCE_ALIGN void AL_APIENTRY alGetBufferivDirect(ALCcontext *context, ALuint buf
FORCE_ALIGN void AL_APIENTRY alBufferCallbackDirectSOFT(ALCcontext *context, ALuint buffer,
ALenum format, ALsizei freq, ALBUFFERCALLBACKTYPESOFT callback, ALvoid *userptr) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
@@ -1381,9 +1319,6 @@ FORCE_ALIGN void AL_APIENTRY alBufferCallbackDirectSOFT(ALCcontext *context, ALu
FORCE_ALIGN void AL_APIENTRY alGetBufferPtrDirectSOFT(ALCcontext *context, ALuint buffer,
ALenum param, ALvoid **value) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
@@ -1408,9 +1343,6 @@ FORCE_ALIGN void AL_APIENTRY alGetBufferPtrDirectSOFT(ALCcontext *context, ALuin
FORCE_ALIGN void AL_APIENTRY alGetBuffer3PtrDirectSOFT(ALCcontext *context, ALuint buffer,
ALenum param, ALvoid **value1, ALvoid **value2, ALvoid **value3) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
if(LookupBuffer(device, buffer) == nullptr) UNLIKELY
@@ -1435,9 +1367,6 @@ FORCE_ALIGN void AL_APIENTRY alGetBufferPtrvDirectSOFT(ALCcontext *context, ALui
return;
}
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
if(LookupBuffer(device, buffer) == nullptr) UNLIKELY
diff --git a/al/debug.cpp b/al/debug.cpp
index e28df917..9c0a63ef 100644
--- a/al/debug.cpp
+++ b/al/debug.cpp
@@ -234,14 +234,15 @@ void ALCcontext::sendDebugMessage(std::unique_lock<std::mutex> &debuglock, Debug
FORCE_ALIGN void AL_APIENTRY alDebugMessageCallbackEXT(ALDEBUGPROCEXT callback, void *userParam) noexcept
-{ return alDebugMessageCallbackDirectEXT(GetContextRef().get(), callback, userParam); }
+{
+ auto context = GetContextRef();
+ if(!context) UNLIKELY return;
+ return alDebugMessageCallbackDirectEXT(context.get(), callback, userParam);
+}
FORCE_ALIGN void AL_APIENTRY alDebugMessageCallbackDirectEXT(ALCcontext *context,
ALDEBUGPROCEXT callback, void *userParam) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mDebugCbLock};
context->mDebugCb = callback;
context->mDebugParam = userParam;
@@ -249,7 +250,11 @@ FORCE_ALIGN void AL_APIENTRY alDebugMessageCallbackDirectEXT(ALCcontext *context
FORCE_ALIGN void AL_APIENTRY alDebugMessageInsertEXT(ALenum source, ALenum type, ALuint id, ALenum severity, ALsizei length, const ALchar *message) noexcept
-{ return alDebugMessageInsertDirectEXT(GetContextRef().get(), source, type, id, severity, length, message); }
+{
+ auto context = GetContextRef();
+ if(!context) UNLIKELY return;
+ return alDebugMessageInsertDirectEXT(context.get(), source, type, id, severity, length, message);
+}
FORCE_ALIGN void AL_APIENTRY alDebugMessageInsertDirectEXT(ALCcontext *context, ALenum source,
ALenum type, ALuint id, ALenum severity, ALsizei length, const ALchar *message) noexcept
@@ -294,14 +299,15 @@ FORCE_ALIGN void AL_APIENTRY alDebugMessageInsertDirectEXT(ALCcontext *context,
FORCE_ALIGN void AL_APIENTRY alDebugMessageControlEXT(ALenum source, ALenum type, ALenum severity, ALsizei count, const ALuint *ids, ALboolean enable) noexcept
-{ return alDebugMessageControlDirectEXT(GetContextRef().get(), source, type, severity, count, ids, enable); }
+{
+ auto context = GetContextRef();
+ if(!context) UNLIKELY return;
+ return alDebugMessageControlDirectEXT(context.get(), source, type, severity, count, ids, enable);
+}
FORCE_ALIGN void AL_APIENTRY alDebugMessageControlDirectEXT(ALCcontext *context, ALenum source,
ALenum type, ALenum severity, ALsizei count, const ALuint *ids, ALboolean enable) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(count > 0)
{
if(!ids)
@@ -395,14 +401,15 @@ FORCE_ALIGN void AL_APIENTRY alDebugMessageControlDirectEXT(ALCcontext *context,
FORCE_ALIGN void AL_APIENTRY alPushDebugGroupEXT(ALenum source, ALuint id, ALsizei length, const ALchar *message) noexcept
-{ return alPushDebugGroupDirectEXT(GetContextRef().get(), source, id, length, message); }
+{
+ auto context = GetContextRef();
+ if(!context) UNLIKELY return;
+ return alPushDebugGroupDirectEXT(context.get(), source, id, length, message);
+}
FORCE_ALIGN void AL_APIENTRY alPushDebugGroupDirectEXT(ALCcontext *context, ALenum source,
ALuint id, ALsizei length, const ALchar *message) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(length < 0)
{
size_t newlen{std::strlen(message)};
@@ -442,13 +449,14 @@ FORCE_ALIGN void AL_APIENTRY alPushDebugGroupDirectEXT(ALCcontext *context, ALen
}
FORCE_ALIGN void AL_APIENTRY alPopDebugGroupEXT(void) noexcept
-{ return alPopDebugGroupDirectEXT(GetContextRef().get()); }
+{
+ auto context = GetContextRef();
+ if(!context) UNLIKELY return;
+ return alPopDebugGroupDirectEXT(context.get());
+}
FORCE_ALIGN void AL_APIENTRY alPopDebugGroupDirectEXT(ALCcontext *context) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::unique_lock<std::mutex> debuglock{context->mDebugCbLock};
if(context->mDebugGroups.size() <= 1)
{
@@ -470,15 +478,16 @@ FORCE_ALIGN void AL_APIENTRY alPopDebugGroupDirectEXT(ALCcontext *context) noexc
FORCE_ALIGN ALuint AL_APIENTRY alGetDebugMessageLogEXT(ALuint count, ALsizei logBufSize, ALenum *sources, ALenum *types, ALuint *ids, ALenum *severities, ALsizei *lengths, ALchar *logBuf) noexcept
-{ return alGetDebugMessageLogDirectEXT(GetContextRef().get(), count, logBufSize, sources, types, ids, severities, lengths, logBuf); }
+{
+ auto context = GetContextRef();
+ if(!context) UNLIKELY return 0;
+ return alGetDebugMessageLogDirectEXT(context.get(), count, logBufSize, sources, types, ids, severities, lengths, logBuf);
+}
FORCE_ALIGN ALuint AL_APIENTRY alGetDebugMessageLogDirectEXT(ALCcontext *context, ALuint count,
ALsizei logBufSize, ALenum *sources, ALenum *types, ALuint *ids, ALenum *severities,
ALsizei *lengths, ALchar *logBuf) noexcept
{
- if(!context) UNLIKELY
- return 0;
-
if(logBufSize < 0)
{
context->setError(AL_INVALID_VALUE, "Negative debug log buffer size");
diff --git a/al/direct_defs.h b/al/direct_defs.h
index c36211ae..4ab72730 100644
--- a/al/direct_defs.h
+++ b/al/direct_defs.h
@@ -1,83 +1,119 @@
#ifndef AL_DIRECT_DEFS_H
#define AL_DIRECT_DEFS_H
+namespace detail_ {
+
+template<typename T>
+constexpr T DefaultVal() noexcept { return T{}; }
+
+template<>
+constexpr void DefaultVal() noexcept { }
+
+} // namespace detail_
+
#define DECL_FUNC(R, Name) \
R AL_API Name(void) START_API_FUNC \
{ \
- return Name##Direct(GetContextRef().get()); \
+ auto context = GetContextRef(); \
+ if(!context) UNLIKELY return detail_::DefaultVal<R>(); \
+ return Name##Direct(context.get()); \
} END_API_FUNC
#define DECL_FUNC1(R, Name, T1) \
R AL_API Name(T1 a) START_API_FUNC \
{ \
- return Name##Direct(GetContextRef().get(), a); \
+ auto context = GetContextRef(); \
+ if(!context) UNLIKELY return detail_::DefaultVal<R>(); \
+ return Name##Direct(context.get(), a); \
} END_API_FUNC
#define DECL_FUNC2(R, Name, T1, T2) \
R AL_API Name(T1 a, T2 b) START_API_FUNC \
{ \
- return Name##Direct(GetContextRef().get(), a, b); \
+ auto context = GetContextRef(); \
+ if(!context) UNLIKELY return detail_::DefaultVal<R>(); \
+ return Name##Direct(context.get(), a, b); \
} END_API_FUNC
#define DECL_FUNC3(R, Name, T1, T2, T3) \
R AL_API Name(T1 a, T2 b, T3 c) START_API_FUNC \
{ \
- return Name##Direct(GetContextRef().get(), a, b, c); \
+ auto context = GetContextRef(); \
+ if(!context) UNLIKELY return detail_::DefaultVal<R>(); \
+ return Name##Direct(context.get(), a, b, c); \
} END_API_FUNC
#define DECL_FUNC4(R, Name, T1, T2, T3, T4) \
R AL_API Name(T1 a, T2 b, T3 c, T4 d) START_API_FUNC \
{ \
- return Name##Direct(GetContextRef().get(), a, b, c, d); \
+ auto context = GetContextRef(); \
+ if(!context) UNLIKELY return detail_::DefaultVal<R>(); \
+ return Name##Direct(context.get(), a, b, c, d); \
} END_API_FUNC
#define DECL_FUNC5(R, Name, T1, T2, T3, T4, T5) \
R AL_API Name(T1 a, T2 b, T3 c, T4 d, T5 e) START_API_FUNC \
{ \
- return Name##Direct(GetContextRef().get(), a, b, c, d, e); \
+ auto context = GetContextRef(); \
+ if(!context) UNLIKELY return detail_::DefaultVal<R>(); \
+ return Name##Direct(context.get(), a, b, c, d, e); \
} END_API_FUNC
#define DECL_FUNCEXT(R, Name,Ext) \
R AL_API Name##Ext(void) START_API_FUNC \
{ \
- return Name##Direct##Ext(GetContextRef().get()); \
+ auto context = GetContextRef(); \
+ if(!context) UNLIKELY return detail_::DefaultVal<R>(); \
+ return Name##Direct##Ext(context.get()); \
} END_API_FUNC
#define DECL_FUNCEXT1(R, Name,Ext, T1) \
R AL_API Name##Ext(T1 a) START_API_FUNC \
{ \
- return Name##Direct##Ext(GetContextRef().get(), a); \
+ auto context = GetContextRef(); \
+ if(!context) UNLIKELY return detail_::DefaultVal<R>(); \
+ return Name##Direct##Ext(context.get(), a); \
} END_API_FUNC
#define DECL_FUNCEXT2(R, Name,Ext, T1, T2) \
R AL_API Name##Ext(T1 a, T2 b) START_API_FUNC \
{ \
- return Name##Direct##Ext(GetContextRef().get(), a, b); \
+ auto context = GetContextRef(); \
+ if(!context) UNLIKELY return detail_::DefaultVal<R>(); \
+ return Name##Direct##Ext(context.get(), a, b); \
} END_API_FUNC
#define DECL_FUNCEXT3(R, Name,Ext, T1, T2, T3) \
R AL_API Name##Ext(T1 a, T2 b, T3 c) START_API_FUNC \
{ \
- return Name##Direct##Ext(GetContextRef().get(), a, b, c); \
+ auto context = GetContextRef(); \
+ if(!context) UNLIKELY return detail_::DefaultVal<R>(); \
+ return Name##Direct##Ext(context.get(), a, b, c); \
} END_API_FUNC
#define DECL_FUNCEXT4(R, Name,Ext, T1, T2, T3, T4) \
R AL_API Name##Ext(T1 a, T2 b, T3 c, T4 d) START_API_FUNC \
{ \
- return Name##Direct##Ext(GetContextRef().get(), a, b, c, d); \
+ auto context = GetContextRef(); \
+ if(!context) UNLIKELY return detail_::DefaultVal<R>(); \
+ return Name##Direct##Ext(context.get(), a, b, c, d); \
} END_API_FUNC
#define DECL_FUNCEXT5(R, Name,Ext, T1, T2, T3, T4, T5) \
R AL_API Name##Ext(T1 a, T2 b, T3 c, T4 d, T5 e) START_API_FUNC \
{ \
- return Name##Direct##Ext(GetContextRef().get(), a, b, c, d, e); \
+ auto context = GetContextRef(); \
+ if(!context) UNLIKELY return detail_::DefaultVal<R>(); \
+ return Name##Direct##Ext(context.get(), a, b, c, d, e); \
} END_API_FUNC
#define DECL_FUNCEXT6(R, Name,Ext, T1, T2, T3, T4, T5, T6) \
R AL_API Name##Ext(T1 a, T2 b, T3 c, T4 d, T5 e, T6 f) START_API_FUNC \
{ \
- return Name##Direct##Ext(GetContextRef().get(), a, b, c, d, e, f); \
+ auto context = GetContextRef(); \
+ if(!context) UNLIKELY return detail_::DefaultVal<R>(); \
+ return Name##Direct##Ext(context.get(), a, b, c, d, e, f); \
} END_API_FUNC
#endif /* AL_DIRECT_DEFS_H */
diff --git a/al/effect.cpp b/al/effect.cpp
index a0ec2135..9032fdb3 100644
--- a/al/effect.cpp
+++ b/al/effect.cpp
@@ -233,9 +233,6 @@ inline ALeffect *LookupEffect(ALCdevice *device, ALuint id)
FORCE_ALIGN void AL_APIENTRY alGenEffectsDirect(ALCcontext *context, ALsizei n, ALuint *effects) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(n < 0) UNLIKELY
context->setError(AL_INVALID_VALUE, "Generating %d effects", n);
if(n <= 0) UNLIKELY return;
@@ -272,9 +269,6 @@ FORCE_ALIGN void AL_APIENTRY alGenEffectsDirect(ALCcontext *context, ALsizei n,
FORCE_ALIGN void AL_APIENTRY alDeleteEffectsDirect(ALCcontext *context, ALsizei n,
const ALuint *effects) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(n < 0) UNLIKELY
context->setError(AL_INVALID_VALUE, "Deleting %d effects", n);
if(n <= 0) UNLIKELY return;
@@ -305,22 +299,16 @@ FORCE_ALIGN void AL_APIENTRY alDeleteEffectsDirect(ALCcontext *context, ALsizei
FORCE_ALIGN ALboolean AL_APIENTRY alIsEffectDirect(ALCcontext *context, ALuint effect) noexcept
{
- if(context) LIKELY
- {
- ALCdevice *device{context->mALDevice.get()};
- std::lock_guard<std::mutex> _{device->EffectLock};
- if(!effect || LookupEffect(device, effect))
- return AL_TRUE;
- }
+ ALCdevice *device{context->mALDevice.get()};
+ std::lock_guard<std::mutex> _{device->EffectLock};
+ if(!effect || LookupEffect(device, effect))
+ return AL_TRUE;
return AL_FALSE;
}
FORCE_ALIGN void AL_APIENTRY alEffectiDirect(ALCcontext *context, ALuint effect, ALenum param,
ALint value) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
@@ -367,9 +355,6 @@ FORCE_ALIGN void AL_APIENTRY alEffectivDirect(ALCcontext *context, ALuint effect
return;
}
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
@@ -389,9 +374,6 @@ FORCE_ALIGN void AL_APIENTRY alEffectivDirect(ALCcontext *context, ALuint effect
FORCE_ALIGN void AL_APIENTRY alEffectfDirect(ALCcontext *context, ALuint effect, ALenum param,
ALfloat value) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
@@ -411,9 +393,6 @@ FORCE_ALIGN void AL_APIENTRY alEffectfDirect(ALCcontext *context, ALuint effect,
FORCE_ALIGN void AL_APIENTRY alEffectfvDirect(ALCcontext *context, ALuint effect, ALenum param,
const ALfloat *values) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
@@ -433,9 +412,6 @@ FORCE_ALIGN void AL_APIENTRY alEffectfvDirect(ALCcontext *context, ALuint effect
FORCE_ALIGN void AL_APIENTRY alGetEffectiDirect(ALCcontext *context, ALuint effect, ALenum param,
ALint *value) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
@@ -464,9 +440,6 @@ FORCE_ALIGN void AL_APIENTRY alGetEffectivDirect(ALCcontext *context, ALuint eff
return;
}
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
@@ -486,9 +459,6 @@ FORCE_ALIGN void AL_APIENTRY alGetEffectivDirect(ALCcontext *context, ALuint eff
FORCE_ALIGN void AL_APIENTRY alGetEffectfDirect(ALCcontext *context, ALuint effect, ALenum param,
ALfloat *value) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
@@ -508,9 +478,6 @@ FORCE_ALIGN void AL_APIENTRY alGetEffectfDirect(ALCcontext *context, ALuint effe
FORCE_ALIGN void AL_APIENTRY alGetEffectfvDirect(ALCcontext *context, ALuint effect, ALenum param,
ALfloat *values) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
diff --git a/al/error.cpp b/al/error.cpp
index e33ee161..8e6bb3b8 100644
--- a/al/error.cpp
+++ b/al/error.cpp
@@ -90,9 +90,12 @@ void ALCcontext::setError(ALenum errorCode, const char *msg, ...)
debugMessage(DebugSource::API, DebugType::Error, 0, DebugSeverity::High, msglen, msg);
}
-AL_API DECL_FUNC(ALenum, alGetError)
-FORCE_ALIGN ALenum AL_APIENTRY alGetErrorDirect(ALCcontext *context) noexcept
+/* Special-case alGetError since it (potentially) raises a debug signal and
+ * returns a non-default value for a null context.
+ */
+AL_API ALenum AL_APIENTRY alGetError(void) START_API_FUNC
{
+ auto context = GetContextRef();
if(!context) UNLIKELY
{
static constexpr ALenum deferror{AL_INVALID_OPERATION};
@@ -108,6 +111,10 @@ FORCE_ALIGN ALenum AL_APIENTRY alGetErrorDirect(ALCcontext *context) noexcept
}
return deferror;
}
+ return alGetErrorDirect(context.get());
+} END_API_FUNC
+FORCE_ALIGN ALenum AL_APIENTRY alGetErrorDirect(ALCcontext *context) noexcept
+{
return context->mLastError.exchange(AL_NO_ERROR);
}
diff --git a/al/event.cpp b/al/event.cpp
index f7ef7b50..dffd76d0 100644
--- a/al/event.cpp
+++ b/al/event.cpp
@@ -176,9 +176,6 @@ void StopEventThrd(ALCcontext *ctx)
FORCE_ALIGN void AL_APIENTRY alEventControlDirectSOFT(ALCcontext *context, ALsizei count,
const ALenum *types, ALboolean enable) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(count < 0) context->setError(AL_INVALID_VALUE, "Controlling %d events", count);
if(count <= 0) return;
if(!types) return context->setError(AL_INVALID_VALUE, "NULL pointer");
@@ -230,9 +227,6 @@ FORCE_ALIGN void AL_APIENTRY alEventControlDirectSOFT(ALCcontext *context, ALsiz
FORCE_ALIGN void AL_APIENTRY alEventCallbackDirectSOFT(ALCcontext *context,
ALEVENTPROCSOFT callback, void *userParam) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mEventCbLock};
context->mEventCb = callback;
diff --git a/al/extension.cpp b/al/extension.cpp
index 077e3324..edd30f88 100644
--- a/al/extension.cpp
+++ b/al/extension.cpp
@@ -37,9 +37,6 @@
AL_API DECL_FUNC1(ALboolean, alIsExtensionPresent, const ALchar*)
FORCE_ALIGN ALboolean AL_APIENTRY alIsExtensionPresentDirect(ALCcontext *context, const ALchar *extName) noexcept
{
- if(!context) UNLIKELY
- return AL_FALSE;
-
if(!extName) UNLIKELY
{
context->setError(AL_INVALID_VALUE, "NULL pointer");
diff --git a/al/filter.cpp b/al/filter.cpp
index 9176a516..fb12ef48 100644
--- a/al/filter.cpp
+++ b/al/filter.cpp
@@ -404,9 +404,6 @@ inline ALfilter *LookupFilter(ALCdevice *device, ALuint id)
FORCE_ALIGN void AL_APIENTRY alGenFiltersDirect(ALCcontext *context, ALsizei n, ALuint *filters) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(n < 0) UNLIKELY
context->setError(AL_INVALID_VALUE, "Generating %d filters", n);
if(n <= 0) UNLIKELY return;
@@ -443,9 +440,6 @@ FORCE_ALIGN void AL_APIENTRY alGenFiltersDirect(ALCcontext *context, ALsizei n,
FORCE_ALIGN void AL_APIENTRY alDeleteFiltersDirect(ALCcontext *context, ALsizei n,
const ALuint *filters) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(n < 0) UNLIKELY
context->setError(AL_INVALID_VALUE, "Deleting %d filters", n);
if(n <= 0) UNLIKELY return;
@@ -476,13 +470,10 @@ FORCE_ALIGN void AL_APIENTRY alDeleteFiltersDirect(ALCcontext *context, ALsizei
FORCE_ALIGN ALboolean AL_APIENTRY alIsFilterDirect(ALCcontext *context, ALuint filter) noexcept
{
- if(context) LIKELY
- {
- ALCdevice *device{context->mALDevice.get()};
- std::lock_guard<std::mutex> _{device->FilterLock};
- if(!filter || LookupFilter(device, filter))
- return AL_TRUE;
- }
+ ALCdevice *device{context->mALDevice.get()};
+ std::lock_guard<std::mutex> _{device->FilterLock};
+ if(!filter || LookupFilter(device, filter))
+ return AL_TRUE;
return AL_FALSE;
}
@@ -490,9 +481,6 @@ FORCE_ALIGN ALboolean AL_APIENTRY alIsFilterDirect(ALCcontext *context, ALuint f
FORCE_ALIGN void AL_APIENTRY alFilteriDirect(ALCcontext *context, ALuint filter, ALenum param,
ALint value) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
@@ -530,9 +518,6 @@ FORCE_ALIGN void AL_APIENTRY alFilterivDirect(ALCcontext *context, ALuint filter
return;
}
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
@@ -552,9 +537,6 @@ FORCE_ALIGN void AL_APIENTRY alFilterivDirect(ALCcontext *context, ALuint filter
FORCE_ALIGN void AL_APIENTRY alFilterfDirect(ALCcontext *context, ALuint filter, ALenum param,
ALfloat value) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
@@ -574,9 +556,6 @@ FORCE_ALIGN void AL_APIENTRY alFilterfDirect(ALCcontext *context, ALuint filter,
FORCE_ALIGN void AL_APIENTRY alFilterfvDirect(ALCcontext *context, ALuint filter, ALenum param,
const ALfloat *values) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
@@ -596,9 +575,6 @@ FORCE_ALIGN void AL_APIENTRY alFilterfvDirect(ALCcontext *context, ALuint filter
FORCE_ALIGN void AL_APIENTRY alGetFilteriDirect(ALCcontext *context, ALuint filter, ALenum param,
ALint *value) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
@@ -630,9 +606,6 @@ FORCE_ALIGN void AL_APIENTRY alGetFilterivDirect(ALCcontext *context, ALuint fil
return;
}
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
@@ -652,9 +625,6 @@ FORCE_ALIGN void AL_APIENTRY alGetFilterivDirect(ALCcontext *context, ALuint fil
FORCE_ALIGN void AL_APIENTRY alGetFilterfDirect(ALCcontext *context, ALuint filter, ALenum param,
ALfloat *value) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
@@ -674,9 +644,6 @@ FORCE_ALIGN void AL_APIENTRY alGetFilterfDirect(ALCcontext *context, ALuint filt
FORCE_ALIGN void AL_APIENTRY alGetFilterfvDirect(ALCcontext *context, ALuint filter, ALenum param,
ALfloat *values) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
diff --git a/al/listener.cpp b/al/listener.cpp
index 4ee4f8d7..25cb162e 100644
--- a/al/listener.cpp
+++ b/al/listener.cpp
@@ -71,9 +71,6 @@ inline void CommitAndUpdateProps(ALCcontext *context)
FORCE_ALIGN void AL_APIENTRY alListenerfDirect(ALCcontext *context, ALenum param, ALfloat value) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
switch(param)
@@ -100,9 +97,6 @@ FORCE_ALIGN void AL_APIENTRY alListenerfDirect(ALCcontext *context, ALenum param
FORCE_ALIGN void AL_APIENTRY alListener3fDirect(ALCcontext *context, ALenum param, ALfloat value1,
ALfloat value2, ALfloat value3) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
switch(param)
@@ -149,9 +143,6 @@ FORCE_ALIGN void AL_APIENTRY alListenerfvDirect(ALCcontext *context, ALenum para
}
}
- if(!context) UNLIKELY
- return;
-
if(!values) UNLIKELY
return context->setError(AL_INVALID_VALUE, "NULL pointer");
@@ -181,9 +172,6 @@ FORCE_ALIGN void AL_APIENTRY alListenerfvDirect(ALCcontext *context, ALenum para
FORCE_ALIGN void AL_APIENTRY alListeneriDirect(ALCcontext *context, ALenum param, ALint /*value*/) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mPropLock};
switch(param)
{
@@ -204,9 +192,6 @@ FORCE_ALIGN void AL_APIENTRY alListener3iDirect(ALCcontext *context, ALenum para
return;
}
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mPropLock};
switch(param)
{
@@ -241,9 +226,6 @@ FORCE_ALIGN void AL_APIENTRY alListenerivDirect(ALCcontext *context, ALenum para
}
}
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mPropLock};
if(!values) UNLIKELY
context->setError(AL_INVALID_VALUE, "NULL pointer");
@@ -258,9 +240,6 @@ FORCE_ALIGN void AL_APIENTRY alListenerivDirect(ALCcontext *context, ALenum para
FORCE_ALIGN void AL_APIENTRY alGetListenerfDirect(ALCcontext *context, ALenum param,
ALfloat *value) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
if(!value)
@@ -283,9 +262,6 @@ FORCE_ALIGN void AL_APIENTRY alGetListenerfDirect(ALCcontext *context, ALenum pa
FORCE_ALIGN void AL_APIENTRY alGetListener3fDirect(ALCcontext *context, ALenum param,
ALfloat *value1, ALfloat *value2, ALfloat *value3) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
if(!value1 || !value2 || !value3)
@@ -325,9 +301,6 @@ FORCE_ALIGN void AL_APIENTRY alGetListenerfvDirect(ALCcontext *context, ALenum p
return;
}
- if(!context) UNLIKELY
- return;
-
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
if(!values)
@@ -352,9 +325,6 @@ FORCE_ALIGN void AL_APIENTRY alGetListenerfvDirect(ALCcontext *context, ALenum p
FORCE_ALIGN void AL_APIENTRY alGetListeneriDirect(ALCcontext *context, ALenum param, ALint *value) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mPropLock};
if(!value)
context->setError(AL_INVALID_VALUE, "NULL pointer");
@@ -368,9 +338,6 @@ FORCE_ALIGN void AL_APIENTRY alGetListeneriDirect(ALCcontext *context, ALenum pa
FORCE_ALIGN void AL_APIENTRY alGetListener3iDirect(ALCcontext *context, ALenum param,
ALint *value1, ALint *value2, ALint *value3) noexcept
{
- if(!context) UNLIKELY
- return;
-
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
if(!value1 || !value2 || !value3)
@@ -405,9 +372,6 @@ FORCE_ALIGN void AL_APIENTRY alGetListenerivDirect(ALCcontext *context, ALenum p
return;
}
- if(!context) UNLIKELY
- return;
-
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
if(!values)
diff --git a/al/source.cpp b/al/source.cpp
index 1e251a45..8b73ddf0 100644
--- a/al/source.cpp
+++ b/al/source.cpp
@@ -2628,9 +2628,6 @@ void StartSources(ALCcontext *const context, const al::span<ALsource*> srchandle
FORCE_ALIGN void AL_APIENTRY alGenSourcesDirect(ALCcontext *context, ALsizei n, ALuint *sources) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(n < 0) UNLIKELY
context->setError(AL_INVALID_VALUE, "Generating %d sources", n);
if(n <= 0) UNLIKELY return;
@@ -2677,9 +2674,6 @@ FORCE_ALIGN void AL_APIENTRY alGenSourcesDirect(ALCcontext *context, ALsizei n,
FORCE_ALIGN void AL_APIENTRY alDeleteSourcesDirect(ALCcontext *context, ALsizei n,
const ALuint *sources) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(n < 0) UNLIKELY
context->setError(AL_INVALID_VALUE, "Deleting %d sources", n);
if(n <= 0) UNLIKELY return;
@@ -2706,12 +2700,9 @@ FORCE_ALIGN void AL_APIENTRY alDeleteSourcesDirect(ALCcontext *context, ALsizei
FORCE_ALIGN ALboolean AL_APIENTRY alIsSourceDirect(ALCcontext *context, ALuint source) noexcept
{
- if(context) LIKELY
- {
- std::lock_guard<std::mutex> _{context->mSourceLock};
- if(LookupSource(context, source) != nullptr)
- return AL_TRUE;
- }
+ std::lock_guard<std::mutex> _{context->mSourceLock};
+ if(LookupSource(context, source) != nullptr)
+ return AL_TRUE;
return AL_FALSE;
}
@@ -2719,9 +2710,6 @@ FORCE_ALIGN ALboolean AL_APIENTRY alIsSourceDirect(ALCcontext *context, ALuint s
FORCE_ALIGN void AL_APIENTRY alSourcefDirect(ALCcontext *context, ALuint source, ALenum param,
ALfloat value) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mSourceLock};
ALsource *Source = LookupSource(context, source);
@@ -2735,9 +2723,6 @@ FORCE_ALIGN void AL_APIENTRY alSourcefDirect(ALCcontext *context, ALuint source,
FORCE_ALIGN void AL_APIENTRY alSource3fDirect(ALCcontext *context, ALuint source, ALenum param,
ALfloat value1, ALfloat value2, ALfloat value3) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mSourceLock};
ALsource *Source = LookupSource(context, source);
@@ -2751,9 +2736,6 @@ FORCE_ALIGN void AL_APIENTRY alSource3fDirect(ALCcontext *context, ALuint source
FORCE_ALIGN void AL_APIENTRY alSourcefvDirect(ALCcontext *context, ALuint source, ALenum param,
const ALfloat *values) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mSourceLock};
ALsource *Source = LookupSource(context, source);
@@ -2770,9 +2752,6 @@ FORCE_ALIGN void AL_APIENTRY alSourcefvDirect(ALCcontext *context, ALuint source
FORCE_ALIGN void AL_APIENTRY alSourcedDirectSOFT(ALCcontext *context, ALuint source, ALenum param,
ALdouble value) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mSourceLock};
ALsource *Source = LookupSource(context, source);
@@ -2786,9 +2765,6 @@ FORCE_ALIGN void AL_APIENTRY alSourcedDirectSOFT(ALCcontext *context, ALuint sou
FORCE_ALIGN void AL_APIENTRY alSource3dDirectSOFT(ALCcontext *context, ALuint source, ALenum param,
ALdouble value1, ALdouble value2, ALdouble value3) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mSourceLock};
ALsource *Source = LookupSource(context, source);
@@ -2802,9 +2778,6 @@ FORCE_ALIGN void AL_APIENTRY alSource3dDirectSOFT(ALCcontext *context, ALuint so
FORCE_ALIGN void AL_APIENTRY alSourcedvDirectSOFT(ALCcontext *context, ALuint source, ALenum param,
const ALdouble *values) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mSourceLock};
ALsource *Source = LookupSource(context, source);
@@ -2821,9 +2794,6 @@ FORCE_ALIGN void AL_APIENTRY alSourcedvDirectSOFT(ALCcontext *context, ALuint so
FORCE_ALIGN void AL_APIENTRY alSourceiDirect(ALCcontext *context, ALuint source, ALenum param,
ALint value) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mSourceLock};
ALsource *Source = LookupSource(context, source);
@@ -2837,9 +2807,6 @@ FORCE_ALIGN void AL_APIENTRY alSourceiDirect(ALCcontext *context, ALuint source,
FORCE_ALIGN void AL_APIENTRY alSource3iDirect(ALCcontext *context, ALuint source, ALenum param,
ALint value1, ALint value2, ALint value3) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mSourceLock};
ALsource *Source = LookupSource(context, source);
@@ -2853,9 +2820,6 @@ FORCE_ALIGN void AL_APIENTRY alSource3iDirect(ALCcontext *context, ALuint source
FORCE_ALIGN void AL_APIENTRY alSourceivDirect(ALCcontext *context, ALuint source, ALenum param,
const ALint *values) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mSourceLock};
ALsource *Source = LookupSource(context, source);
@@ -2872,9 +2836,6 @@ FORCE_ALIGN void AL_APIENTRY alSourceivDirect(ALCcontext *context, ALuint source
FORCE_ALIGN void AL_APIENTRY alSourcei64DirectSOFT(ALCcontext *context, ALuint source,
ALenum param, ALint64SOFT value) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mSourceLock};
ALsource *Source{LookupSource(context, source)};
@@ -2888,9 +2849,6 @@ FORCE_ALIGN void AL_APIENTRY alSourcei64DirectSOFT(ALCcontext *context, ALuint s
FORCE_ALIGN void AL_APIENTRY alSource3i64DirectSOFT(ALCcontext *context, ALuint source,
ALenum param, ALint64SOFT value1, ALint64SOFT value2, ALint64SOFT value3) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mSourceLock};
ALsource *Source{LookupSource(context, source)};
@@ -2904,9 +2862,6 @@ FORCE_ALIGN void AL_APIENTRY alSource3i64DirectSOFT(ALCcontext *context, ALuint
FORCE_ALIGN void AL_APIENTRY alSourcei64vDirectSOFT(ALCcontext *context, ALuint source,
ALenum param, const ALint64SOFT *values) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mSourceLock};
ALsource *Source{LookupSource(context, source)};
@@ -2923,9 +2878,6 @@ FORCE_ALIGN void AL_APIENTRY alSourcei64vDirectSOFT(ALCcontext *context, ALuint
FORCE_ALIGN void AL_APIENTRY alGetSourcefDirect(ALCcontext *context, ALuint source, ALenum param,
ALfloat *value) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mSourceLock};
ALsource *Source{LookupSource(context, source)};
if(!Source) UNLIKELY
@@ -2940,9 +2892,6 @@ FORCE_ALIGN void AL_APIENTRY alGetSourcefDirect(ALCcontext *context, ALuint sour
FORCE_ALIGN void AL_APIENTRY alGetSource3fDirect(ALCcontext *context, ALuint source, ALenum param,
ALfloat *value1, ALfloat *value2, ALfloat *value3) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mSourceLock};
ALsource *Source{LookupSource(context, source)};
if(!Source) UNLIKELY
@@ -2962,9 +2911,6 @@ FORCE_ALIGN void AL_APIENTRY alGetSource3fDirect(ALCcontext *context, ALuint sou
FORCE_ALIGN void AL_APIENTRY alGetSourcefvDirect(ALCcontext *context, ALuint source, ALenum param,
ALfloat *values) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mSourceLock};
ALsource *Source{LookupSource(context, source)};
if(!Source) UNLIKELY
@@ -2981,9 +2927,6 @@ FORCE_ALIGN void AL_APIENTRY alGetSourcefvDirect(ALCcontext *context, ALuint sou
FORCE_ALIGN void AL_APIENTRY alGetSourcedDirectSOFT(ALCcontext *context, ALuint source,
ALenum param, ALdouble *value) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mSourceLock};
ALsource *Source{LookupSource(context, source)};
if(!Source) UNLIKELY
@@ -2998,9 +2941,6 @@ FORCE_ALIGN void AL_APIENTRY alGetSourcedDirectSOFT(ALCcontext *context, ALuint
FORCE_ALIGN void AL_APIENTRY alGetSource3dDirectSOFT(ALCcontext *context, ALuint source,
ALenum param, ALdouble *value1, ALdouble *value2, ALdouble *value3) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mSourceLock};
ALsource *Source{LookupSource(context, source)};
if(!Source) UNLIKELY
@@ -3020,9 +2960,6 @@ FORCE_ALIGN void AL_APIENTRY alGetSource3dDirectSOFT(ALCcontext *context, ALuint
FORCE_ALIGN void AL_APIENTRY alGetSourcedvDirectSOFT(ALCcontext *context, ALuint source,
ALenum param, ALdouble *values) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mSourceLock};
ALsource *Source{LookupSource(context, source)};
if(!Source) UNLIKELY
@@ -3039,9 +2976,6 @@ FORCE_ALIGN void AL_APIENTRY alGetSourcedvDirectSOFT(ALCcontext *context, ALuint
FORCE_ALIGN void AL_APIENTRY alGetSourceiDirect(ALCcontext *context, ALuint source, ALenum param,
ALint *value) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mSourceLock};
ALsource *Source{LookupSource(context, source)};
if(!Source) UNLIKELY
@@ -3056,9 +2990,6 @@ FORCE_ALIGN void AL_APIENTRY alGetSourceiDirect(ALCcontext *context, ALuint sour
FORCE_ALIGN void AL_APIENTRY alGetSource3iDirect(ALCcontext *context, ALuint source, ALenum param,
ALint *value1, ALint *value2, ALint *value3) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mSourceLock};
ALsource *Source{LookupSource(context, source)};
if(!Source) UNLIKELY
@@ -3078,9 +3009,6 @@ FORCE_ALIGN void AL_APIENTRY alGetSource3iDirect(ALCcontext *context, ALuint sou
FORCE_ALIGN void AL_APIENTRY alGetSourceivDirect(ALCcontext *context, ALuint source, ALenum param,
ALint *values) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mSourceLock};
ALsource *Source{LookupSource(context, source)};
if(!Source) UNLIKELY
@@ -3096,9 +3024,6 @@ FORCE_ALIGN void AL_APIENTRY alGetSourceivDirect(ALCcontext *context, ALuint sou
FORCE_ALIGN void AL_APIENTRY alGetSourcei64DirectSOFT(ALCcontext *context, ALuint source, ALenum param, ALint64SOFT *value) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mSourceLock};
ALsource *Source{LookupSource(context, source)};
if(!Source) UNLIKELY
@@ -3113,9 +3038,6 @@ FORCE_ALIGN void AL_APIENTRY alGetSourcei64DirectSOFT(ALCcontext *context, ALuin
FORCE_ALIGN void AL_APIENTRY alGetSource3i64DirectSOFT(ALCcontext *context, ALuint source,
ALenum param, ALint64SOFT *value1, ALint64SOFT *value2, ALint64SOFT *value3) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mSourceLock};
ALsource *Source{LookupSource(context, source)};
if(!Source) UNLIKELY
@@ -3135,9 +3057,6 @@ FORCE_ALIGN void AL_APIENTRY alGetSource3i64DirectSOFT(ALCcontext *context, ALui
FORCE_ALIGN void AL_APIENTRY alGetSourcei64vDirectSOFT(ALCcontext *context, ALuint source,
ALenum param, ALint64SOFT *values) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mSourceLock};
ALsource *Source{LookupSource(context, source)};
if(!Source) UNLIKELY
@@ -3153,9 +3072,6 @@ FORCE_ALIGN void AL_APIENTRY alGetSourcei64vDirectSOFT(ALCcontext *context, ALui
FORCE_ALIGN void AL_APIENTRY alSourcePlayDirect(ALCcontext *context, ALuint source) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mSourceLock};
ALsource *srchandle{LookupSource(context, source)};
if(!srchandle)
@@ -3167,9 +3083,6 @@ FORCE_ALIGN void AL_APIENTRY alSourcePlayDirect(ALCcontext *context, ALuint sour
FORCE_ALIGN void AL_APIENTRY alSourcePlayAtTimeDirectSOFT(ALCcontext *context, ALuint source,
ALint64SOFT start_time) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(start_time < 0) UNLIKELY
return context->setError(AL_INVALID_VALUE, "Invalid time point %" PRId64, start_time);
@@ -3184,9 +3097,6 @@ FORCE_ALIGN void AL_APIENTRY alSourcePlayAtTimeDirectSOFT(ALCcontext *context, A
FORCE_ALIGN void AL_APIENTRY alSourcePlayvDirect(ALCcontext *context, ALsizei n,
const ALuint *sources) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(n < 0) UNLIKELY
context->setError(AL_INVALID_VALUE, "Playing %d sources", n);
if(n <= 0) UNLIKELY return;
@@ -3217,9 +3127,6 @@ FORCE_ALIGN void AL_APIENTRY alSourcePlayvDirect(ALCcontext *context, ALsizei n,
FORCE_ALIGN void AL_APIENTRY alSourcePlayAtTimevDirectSOFT(ALCcontext *context, ALsizei n,
const ALuint *sources, ALint64SOFT start_time) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(n < 0) UNLIKELY
context->setError(AL_INVALID_VALUE, "Playing %d sources", n);
if(n <= 0) UNLIKELY return;
@@ -3257,9 +3164,6 @@ FORCE_ALIGN void AL_APIENTRY alSourcePauseDirect(ALCcontext *context, ALuint sou
FORCE_ALIGN void AL_APIENTRY alSourcePausevDirect(ALCcontext *context, ALsizei n,
const ALuint *sources) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(n < 0) UNLIKELY
context->setError(AL_INVALID_VALUE, "Pausing %d sources", n);
if(n <= 0) UNLIKELY return;
@@ -3330,9 +3234,6 @@ FORCE_ALIGN void AL_APIENTRY alSourceStopDirect(ALCcontext *context, ALuint sour
FORCE_ALIGN void AL_APIENTRY alSourceStopvDirect(ALCcontext *context, ALsizei n,
const ALuint *sources) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(n < 0) UNLIKELY
context->setError(AL_INVALID_VALUE, "Stopping %d sources", n);
if(n <= 0) UNLIKELY return;
@@ -3390,9 +3291,6 @@ FORCE_ALIGN void AL_APIENTRY alSourceRewindDirect(ALCcontext *context, ALuint so
FORCE_ALIGN void AL_APIENTRY alSourceRewindvDirect(ALCcontext *context, ALsizei n,
const ALuint *sources) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(n < 0) UNLIKELY
context->setError(AL_INVALID_VALUE, "Rewinding %d sources", n);
if(n <= 0) UNLIKELY return;
@@ -3449,9 +3347,6 @@ FORCE_ALIGN void AL_APIENTRY alSourceRewindvDirect(ALCcontext *context, ALsizei
FORCE_ALIGN void AL_APIENTRY alSourceQueueBuffersDirect(ALCcontext *context, ALuint src,
ALsizei nb, const ALuint *buffers) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(nb < 0) UNLIKELY
context->setError(AL_INVALID_VALUE, "Queueing %d buffers", nb);
if(nb <= 0) UNLIKELY return;
@@ -3576,9 +3471,6 @@ FORCE_ALIGN void AL_APIENTRY alSourceQueueBuffersDirect(ALCcontext *context, ALu
FORCE_ALIGN void AL_APIENTRY alSourceUnqueueBuffersDirect(ALCcontext *context, ALuint src,
ALsizei nb, ALuint *buffers) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(nb < 0) UNLIKELY
context->setError(AL_INVALID_VALUE, "Unqueueing %d buffers", nb);
if(nb <= 0) UNLIKELY return;
@@ -3663,10 +3555,18 @@ DECL_FUNCEXT5(void, alGetSource3i64,SOFT, ALuint, ALenum, ALint64SOFT*, ALint64S
DECL_FUNCEXT3(void, alGetSourcei64v,SOFT, ALuint, ALenum, ALint64SOFT*)
DECL_FUNC3(void, alSourceQueueBuffers, ALuint, ALsizei, const ALuint*)
DECL_FUNC3(void, alSourceUnqueueBuffers, ALuint, ALsizei, ALuint*)
-FORCE_ALIGN void AL_APIENTRY alSourcePlayAtTimeSOFT(ALuint source, ALint64SOFT time)
-START_API_FUNC { return alSourcePlayAtTimeDirectSOFT(GetContextRef().get(), source, time); } END_API_FUNC
-FORCE_ALIGN void AL_APIENTRY alSourcePlayAtTimevSOFT(ALsizei n, const ALuint *sources, ALint64SOFT time)
-START_API_FUNC { return alSourcePlayAtTimevDirectSOFT(GetContextRef().get(), n, sources, time); } END_API_FUNC
+FORCE_ALIGN void AL_APIENTRY alSourcePlayAtTimeSOFT(ALuint source, ALint64SOFT time) START_API_FUNC
+{
+ auto context = GetContextRef();
+ if(!context) UNLIKELY return;
+ return alSourcePlayAtTimeDirectSOFT(context.get(), source, time);
+} END_API_FUNC
+FORCE_ALIGN void AL_APIENTRY alSourcePlayAtTimevSOFT(ALsizei n, const ALuint *sources, ALint64SOFT time) START_API_FUNC
+{
+ auto context = GetContextRef();
+ if(!context) UNLIKELY return;
+ return alSourcePlayAtTimevDirectSOFT(context.get(), n, sources, time);
+} END_API_FUNC
AL_API void AL_APIENTRY alSourceQueueBufferLayersSOFT(ALuint, ALsizei, const ALuint*)
START_API_FUNC
diff --git a/al/state.cpp b/al/state.cpp
index e1b50af0..2367dbe4 100644
--- a/al/state.cpp
+++ b/al/state.cpp
@@ -306,9 +306,6 @@ END_API_FUNC
FORCE_ALIGN void AL_APIENTRY alEnableDirect(ALCcontext *context, ALenum capability) noexcept
{
- if(!context) UNLIKELY
- return;
-
switch(capability)
{
case AL_SOURCE_DISTANCE_MODEL:
@@ -334,9 +331,6 @@ FORCE_ALIGN void AL_APIENTRY alEnableDirect(ALCcontext *context, ALenum capabili
FORCE_ALIGN void AL_APIENTRY alDisableDirect(ALCcontext *context, ALenum capability) noexcept
{
- if(!context) UNLIKELY
- return;
-
switch(capability)
{
case AL_SOURCE_DISTANCE_MODEL:
@@ -362,9 +356,6 @@ FORCE_ALIGN void AL_APIENTRY alDisableDirect(ALCcontext *context, ALenum capabil
FORCE_ALIGN ALboolean AL_APIENTRY alIsEnabledDirect(ALCcontext *context, ALenum capability) noexcept
{
- if(!context) UNLIKELY
- return AL_FALSE;
-
std::lock_guard<std::mutex> _{context->mPropLock};
ALboolean value{AL_FALSE};
switch(capability)
@@ -393,6 +384,8 @@ AL_API R AL_APIENTRY Name##Ext(ALenum pname) \
START_API_FUNC \
{ \
R value{}; \
+ auto context = GetContextRef(); \
+ if(!context) UNLIKELY return value; \
Name##vDirect##Ext(GetContextRef().get(), pname, &value); \
return value; \
} \
@@ -417,9 +410,6 @@ DECL_GETFUNC(ALvoid*, alGetPointer,SOFT)
FORCE_ALIGN void AL_APIENTRY alGetBooleanvDirect(ALCcontext *context, ALenum pname, ALboolean *values) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(!values) UNLIKELY
return context->setError(AL_INVALID_VALUE, "NULL pointer");
GetValue(context, pname, values);
@@ -427,9 +417,6 @@ FORCE_ALIGN void AL_APIENTRY alGetBooleanvDirect(ALCcontext *context, ALenum pna
FORCE_ALIGN void AL_APIENTRY alGetDoublevDirect(ALCcontext *context, ALenum pname, ALdouble *values) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(!values) UNLIKELY
return context->setError(AL_INVALID_VALUE, "NULL pointer");
GetValue(context, pname, values);
@@ -437,9 +424,6 @@ FORCE_ALIGN void AL_APIENTRY alGetDoublevDirect(ALCcontext *context, ALenum pnam
FORCE_ALIGN void AL_APIENTRY alGetFloatvDirect(ALCcontext *context, ALenum pname, ALfloat *values) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(!values) UNLIKELY
return context->setError(AL_INVALID_VALUE, "NULL pointer");
GetValue(context, pname, values);
@@ -447,9 +431,6 @@ FORCE_ALIGN void AL_APIENTRY alGetFloatvDirect(ALCcontext *context, ALenum pname
FORCE_ALIGN void AL_APIENTRY alGetIntegervDirect(ALCcontext *context, ALenum pname, ALint *values) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(!values) UNLIKELY
return context->setError(AL_INVALID_VALUE, "NULL pointer");
GetValue(context, pname, values);
@@ -457,9 +438,6 @@ FORCE_ALIGN void AL_APIENTRY alGetIntegervDirect(ALCcontext *context, ALenum pna
FORCE_ALIGN void AL_APIENTRY alGetInteger64vDirectSOFT(ALCcontext *context, ALenum pname, ALint64SOFT *values) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(!values) UNLIKELY
return context->setError(AL_INVALID_VALUE, "NULL pointer");
GetValue(context, pname, values);
@@ -467,9 +445,6 @@ FORCE_ALIGN void AL_APIENTRY alGetInteger64vDirectSOFT(ALCcontext *context, ALen
FORCE_ALIGN void AL_APIENTRY alGetPointervDirectSOFT(ALCcontext *context, ALenum pname, ALvoid **values) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(!values) UNLIKELY
return context->setError(AL_INVALID_VALUE, "NULL pointer");
@@ -498,9 +473,6 @@ FORCE_ALIGN void AL_APIENTRY alGetPointervDirectSOFT(ALCcontext *context, ALenum
FORCE_ALIGN const ALchar* AL_APIENTRY alGetStringDirect(ALCcontext *context, ALenum pname) noexcept
{
- if(!context) UNLIKELY
- return nullptr;
-
const ALchar *value{nullptr};
switch(pname)
{
@@ -560,9 +532,6 @@ FORCE_ALIGN const ALchar* AL_APIENTRY alGetStringDirect(ALCcontext *context, ALe
FORCE_ALIGN void AL_APIENTRY alDopplerFactorDirect(ALCcontext *context, ALfloat value) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(!(value >= 0.0f && std::isfinite(value)))
context->setError(AL_INVALID_VALUE, "Doppler factor %f out of range", value);
else
@@ -575,9 +544,6 @@ FORCE_ALIGN void AL_APIENTRY alDopplerFactorDirect(ALCcontext *context, ALfloat
FORCE_ALIGN void AL_APIENTRY alSpeedOfSoundDirect(ALCcontext *context, ALfloat value) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(!(value > 0.0f && std::isfinite(value)))
context->setError(AL_INVALID_VALUE, "Speed of sound %f out of range", value);
else
@@ -590,9 +556,6 @@ FORCE_ALIGN void AL_APIENTRY alSpeedOfSoundDirect(ALCcontext *context, ALfloat v
FORCE_ALIGN void AL_APIENTRY alDistanceModelDirect(ALCcontext *context, ALenum value) noexcept
{
- if(!context) UNLIKELY
- return;
-
if(auto model = DistanceModelFromALenum(value))
{
std::lock_guard<std::mutex> _{context->mPropLock};
@@ -607,18 +570,12 @@ FORCE_ALIGN void AL_APIENTRY alDistanceModelDirect(ALCcontext *context, ALenum v
FORCE_ALIGN void AL_APIENTRY alDeferUpdatesDirectSOFT(ALCcontext *context) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mPropLock};
context->deferUpdates();
}
FORCE_ALIGN void AL_APIENTRY alProcessUpdatesDirectSOFT(ALCcontext *context) noexcept
{
- if(!context) UNLIKELY
- return;
-
std::lock_guard<std::mutex> _{context->mPropLock};
context->processUpdates();
}
@@ -626,9 +583,6 @@ FORCE_ALIGN void AL_APIENTRY alProcessUpdatesDirectSOFT(ALCcontext *context) noe
FORCE_ALIGN const ALchar* AL_APIENTRY alGetStringiDirectSOFT(ALCcontext *context, ALenum pname, ALsizei index) noexcept
{
- if(!context) UNLIKELY
- return nullptr;
-
const ALchar *value{nullptr};
switch(pname)
{