Move the meters per unit property to the listener

This commit is contained in:
Chris Robinson
2019-08-05 12:15:14 -07:00
parent 3154a915b1
commit d24401c3f3
6 changed files with 9 additions and 13 deletions
+4 -6
View File
@@ -62,11 +62,8 @@ START_API_FUNC
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");
context->mMetersPerUnit = value;
if(!context->mDeferUpdates.load(std::memory_order_acquire))
UpdateContextProps(context.get());
else
context->mPropsClean.clear(std::memory_order_release);
listener.mMetersPerUnit = value;
DO_UPDATEPROPS();
break;
default:
@@ -252,7 +249,7 @@ START_API_FUNC
break;
case AL_METERS_PER_UNIT:
*value = context->mMetersPerUnit;
*value = listener.mMetersPerUnit;
break;
default:
@@ -439,6 +436,7 @@ void UpdateListenerProps(ALCcontext *context)
props->OrientAt = listener.OrientAt;
props->OrientUp = listener.OrientUp;
props->Gain = listener.Gain;
props->MetersPerUnit = listener.mMetersPerUnit;
/* Set the new container for updating internal parameters. */
props = listener.Update.exchange(props, std::memory_order_acq_rel);
+3
View File
@@ -6,6 +6,7 @@
#include "AL/al.h"
#include "AL/alc.h"
#include "AL/alext.h"
#include "vecmat.h"
@@ -18,6 +19,7 @@ struct ALlistenerProps {
std::array<ALfloat,3> OrientAt;
std::array<ALfloat,3> OrientUp;
ALfloat Gain;
ALfloat MetersPerUnit;
std::atomic<ALlistenerProps*> next;
};
@@ -28,6 +30,7 @@ struct ALlistener {
std::array<ALfloat,3> OrientAt{{0.0f, 0.0f, -1.0f}};
std::array<ALfloat,3> OrientUp{{0.0f, 1.0f, 0.0f}};
ALfloat Gain{1.0f};
ALfloat mMetersPerUnit{AL_DEFAULT_METERS_PER_UNIT};
std::atomic_flag PropsClean;
-2
View File
@@ -836,8 +836,6 @@ void UpdateContextProps(ALCcontext *context)
}
/* Copy in current property values. */
props->MetersPerUnit = context->mMetersPerUnit;
props->DopplerFactor = context->mDopplerFactor;
props->DopplerVelocity = context->mDopplerVelocity;
props->SpeedOfSound = context->mSpeedOfSound;
+1 -1
View File
@@ -2445,7 +2445,7 @@ void ALCcontext::init()
mListener.Params.Matrix = alu::Matrix::Identity();
mListener.Params.Velocity = alu::Vector{};
mListener.Params.Gain = mListener.Gain;
mListener.Params.MetersPerUnit = mMetersPerUnit;
mListener.Params.MetersPerUnit = mListener.mMetersPerUnit;
mListener.Params.DopplerFactor = mDopplerFactor;
mListener.Params.SpeedOfSound = mSpeedOfSound * mDopplerVelocity;
mListener.Params.SourceDistanceModel = mSourceDistanceModel;
-2
View File
@@ -48,7 +48,6 @@ struct ALcontextProps {
ALfloat SpeedOfSound;
ALboolean SourceDistanceModel;
DistanceModel mDistanceModel;
ALfloat MetersPerUnit;
std::atomic<ALcontextProps*> next;
};
@@ -102,7 +101,6 @@ struct ALCcontext : public al::intrusive_ref<ALCcontext> {
ALfloat mDopplerFactor{1.0f};
ALfloat mDopplerVelocity{1.0f};
ALfloat mSpeedOfSound{SPEEDOFSOUNDMETRESPERSEC};
ALfloat mMetersPerUnit{AL_DEFAULT_METERS_PER_UNIT};
std::atomic_flag mPropsClean;
std::atomic<bool> mDeferUpdates{false};
+1 -2
View File
@@ -271,8 +271,6 @@ bool CalcContextParams(ALCcontext *Context)
if(!props) return false;
ALlistener &Listener = Context->mListener;
Listener.Params.MetersPerUnit = props->MetersPerUnit;
Listener.Params.DopplerFactor = props->DopplerFactor;
Listener.Params.SpeedOfSound = props->SpeedOfSound * props->DopplerVelocity;
@@ -314,6 +312,7 @@ bool CalcListenerParams(ALCcontext *Context)
Listener.Params.Velocity = Listener.Params.Matrix * vel;
Listener.Params.Gain = props->Gain * Context->mGainBoost;
Listener.Params.MetersPerUnit = props->MetersPerUnit;
AtomicReplaceHead(Context->mFreeListenerProps, props);
return true;