diff options
Diffstat (limited to 'al/listener.cpp')
-rw-r--r-- | al/listener.cpp | 149 |
1 files changed, 74 insertions, 75 deletions
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*) |