From 3b8f54d572b586cd60e6b0c8d839c71edeabbdae Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 16 Dec 2014 07:20:27 -0800 Subject: Use aluVector in some more places --- OpenAL32/Include/alListener.h | 4 ++-- OpenAL32/Include/alSource.h | 6 +++--- OpenAL32/alListener.c | 32 ++++++++++++++------------------ OpenAL32/alSource.c | 42 +++++++++++++++--------------------------- 4 files changed, 34 insertions(+), 50 deletions(-) (limited to 'OpenAL32') diff --git a/OpenAL32/Include/alListener.h b/OpenAL32/Include/alListener.h index d7e495fe..42b5a11f 100644 --- a/OpenAL32/Include/alListener.h +++ b/OpenAL32/Include/alListener.h @@ -9,8 +9,8 @@ extern "C" { #endif typedef struct ALlistener { - volatile ALfloat Position[3]; - volatile ALfloat Velocity[3]; + aluVector Position; + aluVector Velocity; volatile ALfloat Forward[3]; volatile ALfloat Up[3]; volatile ALfloat Gain; diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h index 96216b87..fe2867b1 100644 --- a/OpenAL32/Include/alSource.h +++ b/OpenAL32/Include/alSource.h @@ -57,9 +57,9 @@ typedef struct ALsource { volatile ALfloat RefDistance; volatile ALfloat MaxDistance; volatile ALfloat RollOffFactor; - volatile ALfloat Position[3]; - volatile ALfloat Velocity[3]; - volatile ALfloat Direction[3]; + aluVector Position; + aluVector Velocity; + aluVector Direction; volatile ALfloat Orientation[2][3]; volatile ALboolean HeadRelative; volatile ALboolean Looping; diff --git a/OpenAL32/alListener.c b/OpenAL32/alListener.c index c30d6f84..66865473 100644 --- a/OpenAL32/alListener.c +++ b/OpenAL32/alListener.c @@ -74,9 +74,7 @@ AL_API ALvoid AL_APIENTRY alListener3f(ALenum param, ALfloat value1, ALfloat val SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); LockContext(context); - context->Listener->Position[0] = value1; - context->Listener->Position[1] = value2; - context->Listener->Position[2] = value3; + aluVectorSet(&context->Listener->Position, value1, value2, value3, 1.0f); ATOMIC_STORE(&context->UpdateSources, AL_TRUE); UnlockContext(context); break; @@ -86,9 +84,7 @@ AL_API ALvoid AL_APIENTRY alListener3f(ALenum param, ALfloat value1, ALfloat val SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); LockContext(context); - context->Listener->Velocity[0] = value1; - context->Listener->Velocity[1] = value2; - context->Listener->Velocity[2] = value3; + aluVectorSet(&context->Listener->Velocity, value1, value2, value3, 0.0f); ATOMIC_STORE(&context->UpdateSources, AL_TRUE); UnlockContext(context); break; @@ -282,17 +278,17 @@ AL_API ALvoid AL_APIENTRY alGetListener3f(ALenum param, ALfloat *value1, ALfloat { case AL_POSITION: LockContext(context); - *value1 = context->Listener->Position[0]; - *value2 = context->Listener->Position[1]; - *value3 = context->Listener->Position[2]; + *value1 = context->Listener->Position.v[0]; + *value2 = context->Listener->Position.v[1]; + *value3 = context->Listener->Position.v[2]; UnlockContext(context); break; case AL_VELOCITY: LockContext(context); - *value1 = context->Listener->Velocity[0]; - *value2 = context->Listener->Velocity[1]; - *value3 = context->Listener->Velocity[2]; + *value1 = context->Listener->Velocity.v[0]; + *value2 = context->Listener->Velocity.v[1]; + *value3 = context->Listener->Velocity.v[2]; UnlockContext(context); break; @@ -383,17 +379,17 @@ AL_API void AL_APIENTRY alGetListener3i(ALenum param, ALint *value1, ALint *valu { case AL_POSITION: LockContext(context); - *value1 = (ALint)context->Listener->Position[0]; - *value2 = (ALint)context->Listener->Position[1]; - *value3 = (ALint)context->Listener->Position[2]; + *value1 = (ALint)context->Listener->Position.v[0]; + *value2 = (ALint)context->Listener->Position.v[1]; + *value3 = (ALint)context->Listener->Position.v[2]; UnlockContext(context); break; case AL_VELOCITY: LockContext(context); - *value1 = (ALint)context->Listener->Velocity[0]; - *value2 = (ALint)context->Listener->Velocity[1]; - *value3 = (ALint)context->Listener->Velocity[2]; + *value1 = (ALint)context->Listener->Velocity.v[0]; + *value2 = (ALint)context->Listener->Velocity.v[1]; + *value3 = (ALint)context->Listener->Velocity.v[2]; UnlockContext(context); break; diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index be3768f3..b05b85c5 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -519,9 +519,7 @@ static ALboolean SetSourcefv(ALsource *Source, ALCcontext *Context, SrcFloatProp CHECKVAL(isfinite(values[0]) && isfinite(values[1]) && isfinite(values[2])); LockContext(Context); - Source->Position[0] = values[0]; - Source->Position[1] = values[1]; - Source->Position[2] = values[2]; + aluVectorSet(&Source->Position, values[0], values[1], values[2], 1.0f); UnlockContext(Context); ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); return AL_TRUE; @@ -530,9 +528,7 @@ static ALboolean SetSourcefv(ALsource *Source, ALCcontext *Context, SrcFloatProp CHECKVAL(isfinite(values[0]) && isfinite(values[1]) && isfinite(values[2])); LockContext(Context); - Source->Velocity[0] = values[0]; - Source->Velocity[1] = values[1]; - Source->Velocity[2] = values[2]; + aluVectorSet(&Source->Velocity, values[0], values[1], values[2], 0.0f); UnlockContext(Context); ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); return AL_TRUE; @@ -541,9 +537,7 @@ static ALboolean SetSourcefv(ALsource *Source, ALCcontext *Context, SrcFloatProp CHECKVAL(isfinite(values[0]) && isfinite(values[1]) && isfinite(values[2])); LockContext(Context); - Source->Direction[0] = values[0]; - Source->Direction[1] = values[1]; - Source->Direction[2] = values[2]; + aluVectorSet(&Source->Direction, values[0], values[1], values[2], 0.0f); UnlockContext(Context); ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); return AL_TRUE; @@ -1054,25 +1048,25 @@ static ALboolean GetSourcedv(ALsource *Source, ALCcontext *Context, SrcFloatProp case AL_POSITION: LockContext(Context); - values[0] = Source->Position[0]; - values[1] = Source->Position[1]; - values[2] = Source->Position[2]; + values[0] = Source->Position.v[0]; + values[1] = Source->Position.v[1]; + values[2] = Source->Position.v[2]; UnlockContext(Context); return AL_TRUE; case AL_VELOCITY: LockContext(Context); - values[0] = Source->Velocity[0]; - values[1] = Source->Velocity[1]; - values[2] = Source->Velocity[2]; + values[0] = Source->Velocity.v[0]; + values[1] = Source->Velocity.v[1]; + values[2] = Source->Velocity.v[2]; UnlockContext(Context); return AL_TRUE; case AL_DIRECTION: LockContext(Context); - values[0] = Source->Direction[0]; - values[1] = Source->Direction[1]; - values[2] = Source->Direction[2]; + values[0] = Source->Direction.v[0]; + values[1] = Source->Direction.v[1]; + values[2] = Source->Direction.v[2]; UnlockContext(Context); return AL_TRUE; @@ -2464,15 +2458,9 @@ static ALvoid InitSourceParams(ALsource *Source) Source->InnerAngle = 360.0f; Source->OuterAngle = 360.0f; Source->Pitch = 1.0f; - Source->Position[0] = 0.0f; - Source->Position[1] = 0.0f; - Source->Position[2] = 0.0f; - Source->Velocity[0] = 0.0f; - Source->Velocity[1] = 0.0f; - Source->Velocity[2] = 0.0f; - Source->Direction[0] = 0.0f; - Source->Direction[1] = 0.0f; - Source->Direction[2] = 0.0f; + aluVectorSet(&Source->Position, 0.0f, 0.0f, 0.0f, 1.0f); + aluVectorSet(&Source->Velocity, 0.0f, 0.0f, 0.0f, 0.0f); + aluVectorSet(&Source->Direction, 0.0f, 0.0f, 0.0f, 0.0f); Source->Orientation[0][0] = 0.0f; Source->Orientation[0][1] = 0.0f; Source->Orientation[0][2] = -1.0f; -- cgit v1.2.3