aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--al/direct_defs.h6
-rw-r--r--al/event.cpp22
-rw-r--r--al/listener.cpp149
-rw-r--r--alc/alc.cpp15
4 files changed, 107 insertions, 85 deletions
diff --git a/al/direct_defs.h b/al/direct_defs.h
index be92e759..c36211ae 100644
--- a/al/direct_defs.h
+++ b/al/direct_defs.h
@@ -25,6 +25,12 @@ R AL_API Name(T1 a, T2 b, T3 c) START_API_FUNC \
return Name##Direct(GetContextRef().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); \
+} 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 \
{ \
diff --git a/al/event.cpp b/al/event.cpp
index eb6af45c..f7ef7b50 100644
--- a/al/event.cpp
+++ b/al/event.cpp
@@ -27,6 +27,7 @@
#include "core/logging.h"
#include "core/voice_change.h"
#include "debug.h"
+#include "direct_defs.h"
#include "opthelpers.h"
#include "ringbuffer.h"
#include "threads.h"
@@ -172,11 +173,11 @@ void StopEventThrd(ALCcontext *ctx)
ctx->mEventThread.join();
}
-AL_API void AL_APIENTRY alEventControlSOFT(ALsizei count, const ALenum *types, ALboolean enable)
-START_API_FUNC
+FORCE_ALIGN void AL_APIENTRY alEventControlDirectSOFT(ALCcontext *context, ALsizei count,
+ const ALenum *types, ALboolean enable) noexcept
{
- ContextRef context{GetContextRef()};
- if(!context) UNLIKELY return;
+ if(!context) UNLIKELY
+ return;
if(count < 0) context->setError(AL_INVALID_VALUE, "Controlling %d events", count);
if(count <= 0) return;
@@ -225,17 +226,18 @@ START_API_FUNC
std::lock_guard<std::mutex> _{context->mEventCbLock};
}
}
-END_API_FUNC
-AL_API void AL_APIENTRY alEventCallbackSOFT(ALEVENTPROCSOFT callback, void *userParam)
-START_API_FUNC
+FORCE_ALIGN void AL_APIENTRY alEventCallbackDirectSOFT(ALCcontext *context,
+ ALEVENTPROCSOFT callback, void *userParam) noexcept
{
- ContextRef context{GetContextRef()};
- if(!context) UNLIKELY return;
+ if(!context) UNLIKELY
+ return;
std::lock_guard<std::mutex> _{context->mPropLock};
std::lock_guard<std::mutex> __{context->mEventCbLock};
context->mEventCb = callback;
context->mEventParam = userParam;
}
-END_API_FUNC
+
+DECL_FUNCEXT3(void, alEventControl,SOFT, ALsizei, const ALenum*, ALboolean)
+DECL_FUNCEXT2(void, alEventCallback,SOFT, ALEVENTPROCSOFT, void*)
diff --git a/al/listener.cpp b/al/listener.cpp
index 06d7c370..4ee4f8d7 100644
--- a/al/listener.cpp
+++ b/al/listener.cpp
@@ -33,6 +33,7 @@
#include "almalloc.h"
#include "atomic.h"
#include "core/except.h"
+#include "direct_defs.h"
#include "opthelpers.h"
@@ -68,11 +69,10 @@ inline void CommitAndUpdateProps(ALCcontext *context)
} // namespace
-AL_API void AL_APIENTRY alListenerf(ALenum param, ALfloat value)
-START_API_FUNC
+FORCE_ALIGN void AL_APIENTRY alListenerfDirect(ALCcontext *context, ALenum param, ALfloat value) noexcept
{
- ContextRef context{GetContextRef()};
- if(!context) UNLIKELY return;
+ if(!context) UNLIKELY
+ return;
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
@@ -82,27 +82,26 @@ START_API_FUNC
if(!(value >= 0.0f && std::isfinite(value)))
return context->setError(AL_INVALID_VALUE, "Listener gain out of range");
listener.Gain = value;
- UpdateProps(context.get());
+ UpdateProps(context);
break;
case AL_METERS_PER_UNIT:
if(!(value >= AL_MIN_METERS_PER_UNIT && value <= AL_MAX_METERS_PER_UNIT))
return context->setError(AL_INVALID_VALUE, "Listener meters per unit out of range");
listener.mMetersPerUnit = value;
- UpdateProps(context.get());
+ UpdateProps(context);
break;
default:
context->setError(AL_INVALID_ENUM, "Invalid listener float property");
}
}
-END_API_FUNC
-AL_API void AL_APIENTRY alListener3f(ALenum param, ALfloat value1, ALfloat value2, ALfloat value3)
-START_API_FUNC
+FORCE_ALIGN void AL_APIENTRY alListener3fDirect(ALCcontext *context, ALenum param, ALfloat value1,
+ ALfloat value2, ALfloat value3) noexcept
{
- ContextRef context{GetContextRef()};
- if(!context) UNLIKELY return;
+ if(!context) UNLIKELY
+ return;
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
@@ -114,7 +113,7 @@ START_API_FUNC
listener.Position[0] = value1;
listener.Position[1] = value2;
listener.Position[2] = value3;
- CommitAndUpdateProps(context.get());
+ CommitAndUpdateProps(context);
break;
case AL_VELOCITY:
@@ -123,17 +122,16 @@ START_API_FUNC
listener.Velocity[0] = value1;
listener.Velocity[1] = value2;
listener.Velocity[2] = value3;
- CommitAndUpdateProps(context.get());
+ CommitAndUpdateProps(context);
break;
default:
context->setError(AL_INVALID_ENUM, "Invalid listener 3-float property");
}
}
-END_API_FUNC
-AL_API void AL_APIENTRY alListenerfv(ALenum param, const ALfloat *values)
-START_API_FUNC
+FORCE_ALIGN void AL_APIENTRY alListenerfvDirect(ALCcontext *context, ALenum param,
+ const ALfloat *values) noexcept
{
if(values)
{
@@ -141,18 +139,18 @@ START_API_FUNC
{
case AL_GAIN:
case AL_METERS_PER_UNIT:
- alListenerf(param, values[0]);
+ alListenerfDirect(context, param, values[0]);
return;
case AL_POSITION:
case AL_VELOCITY:
- alListener3f(param, values[0], values[1], values[2]);
+ alListener3fDirect(context, param, values[0], values[1], values[2]);
return;
}
}
- ContextRef context{GetContextRef()};
- if(!context) UNLIKELY return;
+ if(!context) UNLIKELY
+ return;
if(!values) UNLIKELY
return context->setError(AL_INVALID_VALUE, "NULL pointer");
@@ -172,21 +170,19 @@ START_API_FUNC
listener.OrientUp[0] = values[3];
listener.OrientUp[1] = values[4];
listener.OrientUp[2] = values[5];
- CommitAndUpdateProps(context.get());
+ CommitAndUpdateProps(context);
break;
default:
context->setError(AL_INVALID_ENUM, "Invalid listener float-vector property");
}
}
-END_API_FUNC
-AL_API void AL_APIENTRY alListeneri(ALenum param, ALint /*value*/)
-START_API_FUNC
+FORCE_ALIGN void AL_APIENTRY alListeneriDirect(ALCcontext *context, ALenum param, ALint /*value*/) noexcept
{
- ContextRef context{GetContextRef()};
- if(!context) UNLIKELY return;
+ if(!context) UNLIKELY
+ return;
std::lock_guard<std::mutex> _{context->mPropLock};
switch(param)
@@ -195,22 +191,21 @@ START_API_FUNC
context->setError(AL_INVALID_ENUM, "Invalid listener integer property");
}
}
-END_API_FUNC
-AL_API void AL_APIENTRY alListener3i(ALenum param, ALint value1, ALint value2, ALint value3)
-START_API_FUNC
+FORCE_ALIGN void AL_APIENTRY alListener3iDirect(ALCcontext *context, ALenum param, ALint value1,
+ ALint value2, ALint value3) noexcept
{
switch(param)
{
case AL_POSITION:
case AL_VELOCITY:
- alListener3f(param, static_cast<ALfloat>(value1), static_cast<ALfloat>(value2),
- static_cast<ALfloat>(value3));
+ alListener3fDirect(context, param, static_cast<ALfloat>(value1),
+ static_cast<ALfloat>(value2), static_cast<ALfloat>(value3));
return;
}
- ContextRef context{GetContextRef()};
- if(!context) UNLIKELY return;
+ if(!context) UNLIKELY
+ return;
std::lock_guard<std::mutex> _{context->mPropLock};
switch(param)
@@ -219,10 +214,9 @@ START_API_FUNC
context->setError(AL_INVALID_ENUM, "Invalid listener 3-integer property");
}
}
-END_API_FUNC
-AL_API void AL_APIENTRY alListeneriv(ALenum param, const ALint *values)
-START_API_FUNC
+FORCE_ALIGN void AL_APIENTRY alListenerivDirect(ALCcontext *context, ALenum param,
+ const ALint *values) noexcept
{
if(values)
{
@@ -231,8 +225,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]));
+ alListener3fDirect(context, param, static_cast<ALfloat>(values[0]),
+ static_cast<ALfloat>(values[1]), static_cast<ALfloat>(values[2]));
return;
case AL_ORIENTATION:
@@ -242,13 +236,13 @@ START_API_FUNC
fvals[3] = static_cast<ALfloat>(values[3]);
fvals[4] = static_cast<ALfloat>(values[4]);
fvals[5] = static_cast<ALfloat>(values[5]);
- alListenerfv(param, fvals);
+ alListenerfvDirect(context, param, fvals);
return;
}
}
- ContextRef context{GetContextRef()};
- if(!context) UNLIKELY return;
+ if(!context) UNLIKELY
+ return;
std::lock_guard<std::mutex> _{context->mPropLock};
if(!values) UNLIKELY
@@ -259,14 +253,13 @@ START_API_FUNC
context->setError(AL_INVALID_ENUM, "Invalid listener integer-vector property");
}
}
-END_API_FUNC
-AL_API void AL_APIENTRY alGetListenerf(ALenum param, ALfloat *value)
-START_API_FUNC
+FORCE_ALIGN void AL_APIENTRY alGetListenerfDirect(ALCcontext *context, ALenum param,
+ ALfloat *value) noexcept
{
- ContextRef context{GetContextRef()};
- if(!context) UNLIKELY return;
+ if(!context) UNLIKELY
+ return;
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
@@ -286,13 +279,12 @@ START_API_FUNC
context->setError(AL_INVALID_ENUM, "Invalid listener float property");
}
}
-END_API_FUNC
-AL_API void AL_APIENTRY alGetListener3f(ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3)
-START_API_FUNC
+FORCE_ALIGN void AL_APIENTRY alGetListener3fDirect(ALCcontext *context, ALenum param,
+ ALfloat *value1, ALfloat *value2, ALfloat *value3) noexcept
{
- ContextRef context{GetContextRef()};
- if(!context) UNLIKELY return;
+ if(!context) UNLIKELY
+ return;
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
@@ -316,26 +308,25 @@ START_API_FUNC
context->setError(AL_INVALID_ENUM, "Invalid listener 3-float property");
}
}
-END_API_FUNC
-AL_API void AL_APIENTRY alGetListenerfv(ALenum param, ALfloat *values)
-START_API_FUNC
+FORCE_ALIGN void AL_APIENTRY alGetListenerfvDirect(ALCcontext *context, ALenum param,
+ ALfloat *values) noexcept
{
switch(param)
{
case AL_GAIN:
case AL_METERS_PER_UNIT:
- alGetListenerf(param, values);
+ alGetListenerfDirect(context, param, values);
return;
case AL_POSITION:
case AL_VELOCITY:
- alGetListener3f(param, values+0, values+1, values+2);
+ alGetListener3fDirect(context, param, values+0, values+1, values+2);
return;
}
- ContextRef context{GetContextRef()};
- if(!context) UNLIKELY return;
+ if(!context) UNLIKELY
+ return;
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
@@ -357,14 +348,12 @@ START_API_FUNC
context->setError(AL_INVALID_ENUM, "Invalid listener float-vector property");
}
}
-END_API_FUNC
-AL_API void AL_APIENTRY alGetListeneri(ALenum param, ALint *value)
-START_API_FUNC
+FORCE_ALIGN void AL_APIENTRY alGetListeneriDirect(ALCcontext *context, ALenum param, ALint *value) noexcept
{
- ContextRef context{GetContextRef()};
- if(!context) UNLIKELY return;
+ if(!context) UNLIKELY
+ return;
std::lock_guard<std::mutex> _{context->mPropLock};
if(!value)
@@ -375,13 +364,12 @@ START_API_FUNC
context->setError(AL_INVALID_ENUM, "Invalid listener integer property");
}
}
-END_API_FUNC
-AL_API void AL_APIENTRY alGetListener3i(ALenum param, ALint *value1, ALint *value2, ALint *value3)
-START_API_FUNC
+FORCE_ALIGN void AL_APIENTRY alGetListener3iDirect(ALCcontext *context, ALenum param,
+ ALint *value1, ALint *value2, ALint *value3) noexcept
{
- ContextRef context{GetContextRef()};
- if(!context) UNLIKELY return;
+ if(!context) UNLIKELY
+ return;
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
@@ -405,21 +393,20 @@ START_API_FUNC
context->setError(AL_INVALID_ENUM, "Invalid listener 3-integer property");
}
}
-END_API_FUNC
-AL_API void AL_APIENTRY alGetListeneriv(ALenum param, ALint* values)
-START_API_FUNC
+FORCE_ALIGN void AL_APIENTRY alGetListenerivDirect(ALCcontext *context, ALenum param,
+ ALint *values) noexcept
{
switch(param)
{
case AL_POSITION:
case AL_VELOCITY:
- alGetListener3i(param, values+0, values+1, values+2);
+ alGetListener3iDirect(context, param, values+0, values+1, values+2);
return;
}
- ContextRef context{GetContextRef()};
- if(!context) UNLIKELY return;
+ if(!context) UNLIKELY
+ return;
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
@@ -441,4 +428,16 @@ START_API_FUNC
context->setError(AL_INVALID_ENUM, "Invalid listener integer-vector property");
}
}
-END_API_FUNC
+
+DECL_FUNC2(void, alListenerf, ALenum, ALfloat)
+DECL_FUNC4(void, alListener3f, ALenum, ALfloat, ALfloat, ALfloat)
+DECL_FUNC2(void, alListenerfv, ALenum, const ALfloat*)
+DECL_FUNC2(void, alListeneri, ALenum, ALint)
+DECL_FUNC4(void, alListener3i, ALenum, ALint, ALint, ALint)
+DECL_FUNC2(void, alListeneriv, ALenum, const ALint*)
+DECL_FUNC2(void, alGetListenerf, ALenum, ALfloat*)
+DECL_FUNC4(void, alGetListener3f, ALenum, ALfloat*, ALfloat*, ALfloat*)
+DECL_FUNC2(void, alGetListenerfv, ALenum, ALfloat*)
+DECL_FUNC2(void, alGetListeneri, ALenum, ALint*)
+DECL_FUNC4(void, alGetListener3i, ALenum, ALint*, ALint*, ALint*)
+DECL_FUNC2(void, alGetListeneriv, ALenum, ALint*)
diff --git a/alc/alc.cpp b/alc/alc.cpp
index 91ac1842..c6a1a1fe 100644
--- a/alc/alc.cpp
+++ b/alc/alc.cpp
@@ -490,6 +490,19 @@ const struct {
DECL(alGetProcAddress),
DECL(alGetEnumValueDirect),
+ DECL(alListeneriDirect),
+ DECL(alListener3iDirect),
+ DECL(alListenerivDirect),
+ DECL(alListenerfDirect),
+ DECL(alListener3fDirect),
+ DECL(alListenerfvDirect),
+ DECL(alGetListeneriDirect),
+ DECL(alGetListener3iDirect),
+ DECL(alGetListenerivDirect),
+ DECL(alGetListenerfDirect),
+ DECL(alGetListener3fDirect),
+ DECL(alGetListenerfvDirect),
+
DECL(alGenBuffersDirect),
DECL(alDeleteBuffersDirect),
DECL(alIsBufferDirect),
@@ -560,6 +573,8 @@ const struct {
DECL(alSourcePlayAtTimeDirectSOFT),
DECL(alSourcePlayAtTimevDirectSOFT),
+ DECL(alEventControlDirectSOFT),
+ DECL(alEventCallbackDirectSOFT),
#ifdef ALSOFT_EAX
}, eaxFunctions[] = {
DECL(EAXGet),