aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2012-10-09 04:44:27 -0700
committerChris Robinson <[email protected]>2012-10-09 04:44:27 -0700
commitc22408cb2af607ce65846a4ade31251b714c183b (patch)
tree3bfea812a9c297b4991cfcf77cb883dda8fe220e
parent8c3419ed48b0221816314f605b0a7c6e045d95dc (diff)
Store a pointer to the listener in the context
-rw-r--r--Alc/ALc.c33
-rw-r--r--Alc/ALu.c20
-rw-r--r--OpenAL32/Include/alMain.h2
-rw-r--r--OpenAL32/alListener.c112
4 files changed, 84 insertions, 83 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 917faf08..f08ee597 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -1802,24 +1802,24 @@ static ALvoid InitContext(ALCcontext *Context)
ALint i, j;
//Initialise listener
- Context->Listener.Gain = 1.0f;
- Context->Listener.MetersPerUnit = 1.0f;
- Context->Listener.Position[0] = 0.0f;
- Context->Listener.Position[1] = 0.0f;
- Context->Listener.Position[2] = 0.0f;
- Context->Listener.Velocity[0] = 0.0f;
- Context->Listener.Velocity[1] = 0.0f;
- Context->Listener.Velocity[2] = 0.0f;
- Context->Listener.Forward[0] = 0.0f;
- Context->Listener.Forward[1] = 0.0f;
- Context->Listener.Forward[2] = -1.0f;
- Context->Listener.Up[0] = 0.0f;
- Context->Listener.Up[1] = 1.0f;
- Context->Listener.Up[2] = 0.0f;
+ Context->Listener->Gain = 1.0f;
+ Context->Listener->MetersPerUnit = 1.0f;
+ Context->Listener->Position[0] = 0.0f;
+ Context->Listener->Position[1] = 0.0f;
+ Context->Listener->Position[2] = 0.0f;
+ Context->Listener->Velocity[0] = 0.0f;
+ Context->Listener->Velocity[1] = 0.0f;
+ Context->Listener->Velocity[2] = 0.0f;
+ Context->Listener->Forward[0] = 0.0f;
+ Context->Listener->Forward[1] = 0.0f;
+ Context->Listener->Forward[2] = -1.0f;
+ Context->Listener->Up[0] = 0.0f;
+ Context->Listener->Up[1] = 1.0f;
+ Context->Listener->Up[2] = 0.0f;
for(i = 0;i < 4;i++)
{
for(j = 0;j < 4;j++)
- Context->Listener.Matrix[i][j] = ((i==j) ? 1.0f : 0.0f);
+ Context->Listener->Matrix[i][j] = ((i==j) ? 1.0f : 0.0f);
}
//Validate Context
@@ -2461,10 +2461,11 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin
return NULL;
}
- ALContext = calloc(1, sizeof(ALCcontext));
+ ALContext = calloc(1, sizeof(ALCcontext)+15+sizeof(ALlistener));
if(ALContext)
{
ALContext->ref = 1;
+ ALContext->Listener = (ALlistener*)(((ALintptrEXT)(ALContext+1)+15)&~15);
ALContext->MaxActiveSources = 256;
ALContext->ActiveSources = malloc(sizeof(ALContext->ActiveSources[0]) *
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 8dfe87e5..e72e1aac 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -191,7 +191,7 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
Frequency = Device->Frequency;
/* Get listener properties */
- ListenerGain = ALContext->Listener.Gain;
+ ListenerGain = ALContext->Listener->Gain;
/* Get source properties */
SourceVolume = ALSource->Gain;
@@ -425,15 +425,15 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
Frequency = Device->Frequency;
/* Get listener properties */
- ListenerGain = ALContext->Listener.Gain;
- MetersPerUnit = ALContext->Listener.MetersPerUnit;
- ListenerVel[0] = ALContext->Listener.Velocity[0];
- ListenerVel[1] = ALContext->Listener.Velocity[1];
- ListenerVel[2] = ALContext->Listener.Velocity[2];
+ ListenerGain = ALContext->Listener->Gain;
+ MetersPerUnit = ALContext->Listener->MetersPerUnit;
+ ListenerVel[0] = ALContext->Listener->Velocity[0];
+ ListenerVel[1] = ALContext->Listener->Velocity[1];
+ ListenerVel[2] = ALContext->Listener->Velocity[2];
for(i = 0;i < 4;i++)
{
for(j = 0;j < 4;j++)
- Matrix[i][j] = ALContext->Listener.Matrix[i][j];
+ Matrix[i][j] = ALContext->Listener->Matrix[i][j];
}
/* Get source properties */
@@ -506,9 +506,9 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
if(ALSource->HeadRelative == AL_FALSE)
{
/* Translate position */
- Position[0] -= ALContext->Listener.Position[0];
- Position[1] -= ALContext->Listener.Position[1];
- Position[2] -= ALContext->Listener.Position[2];
+ Position[0] -= ALContext->Listener->Position[0];
+ Position[1] -= ALContext->Listener->Position[1];
+ Position[2] -= ALContext->Listener->Position[2];
/* Transform source vectors */
aluMatrixVector(Position, 1.0f, Matrix);
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index e2031857..e12e432f 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -709,7 +709,7 @@ struct ALCcontext_struct
{
volatile RefCount ref;
- ALlistener Listener;
+ ALlistener *Listener;
UIntMap SourceMap;
UIntMap EffectSlotMap;
diff --git a/OpenAL32/alListener.c b/OpenAL32/alListener.c
index 07fadbe0..f026c8b2 100644
--- a/OpenAL32/alListener.c
+++ b/OpenAL32/alListener.c
@@ -40,14 +40,14 @@ AL_API ALvoid AL_APIENTRY alListenerf(ALenum param, ALfloat value)
case AL_GAIN:
CHECK_VALUE(Context, value >= 0.0f && isfinite(value));
- Context->Listener.Gain = value;
+ Context->Listener->Gain = value;
Context->UpdateSources = AL_TRUE;
break;
case AL_METERS_PER_UNIT:
CHECK_VALUE(Context, value >= 0.0f && isfinite(value));
- Context->Listener.MetersPerUnit = value;
+ Context->Listener->MetersPerUnit = value;
Context->UpdateSources = AL_TRUE;
break;
@@ -76,9 +76,9 @@ AL_API ALvoid AL_APIENTRY alListener3f(ALenum param, ALfloat value1, ALfloat val
CHECK_VALUE(Context, isfinite(value1) && isfinite(value2) && isfinite(value3));
LockContext(Context);
- Context->Listener.Position[0] = value1;
- Context->Listener.Position[1] = value2;
- Context->Listener.Position[2] = value3;
+ Context->Listener->Position[0] = value1;
+ Context->Listener->Position[1] = value2;
+ Context->Listener->Position[2] = value3;
Context->UpdateSources = AL_TRUE;
UnlockContext(Context);
break;
@@ -87,9 +87,9 @@ AL_API ALvoid AL_APIENTRY alListener3f(ALenum param, ALfloat value1, ALfloat val
CHECK_VALUE(Context, isfinite(value1) && isfinite(value2) && isfinite(value3));
LockContext(Context);
- Context->Listener.Velocity[0] = value1;
- Context->Listener.Velocity[1] = value2;
- Context->Listener.Velocity[2] = value3;
+ Context->Listener->Velocity[0] = value1;
+ Context->Listener->Velocity[1] = value2;
+ Context->Listener->Velocity[2] = value3;
Context->UpdateSources = AL_TRUE;
UnlockContext(Context);
break;
@@ -152,28 +152,28 @@ AL_API ALvoid AL_APIENTRY alListenerfv(ALenum param, const ALfloat *values)
aluNormalize(U);
LockContext(Context);
- Context->Listener.Forward[0] = values[0];
- Context->Listener.Forward[1] = values[1];
- Context->Listener.Forward[2] = values[2];
- Context->Listener.Up[0] = values[3];
- Context->Listener.Up[1] = values[4];
- Context->Listener.Up[2] = values[5];
- Context->Listener.Matrix[0][0] = U[0];
- Context->Listener.Matrix[0][1] = V[0];
- Context->Listener.Matrix[0][2] = -N[0];
- Context->Listener.Matrix[0][3] = 0.0f;
- Context->Listener.Matrix[1][0] = U[1];
- Context->Listener.Matrix[1][1] = V[1];
- Context->Listener.Matrix[1][2] = -N[1];
- Context->Listener.Matrix[1][3] = 0.0f;
- Context->Listener.Matrix[2][0] = U[2];
- Context->Listener.Matrix[2][1] = V[2];
- Context->Listener.Matrix[2][2] = -N[2];
- Context->Listener.Matrix[2][3] = 0.0f;
- Context->Listener.Matrix[3][0] = 0.0f;
- Context->Listener.Matrix[3][1] = 0.0f;
- Context->Listener.Matrix[3][2] = 0.0f;
- Context->Listener.Matrix[3][3] = 1.0f;
+ Context->Listener->Forward[0] = values[0];
+ Context->Listener->Forward[1] = values[1];
+ Context->Listener->Forward[2] = values[2];
+ Context->Listener->Up[0] = values[3];
+ Context->Listener->Up[1] = values[4];
+ Context->Listener->Up[2] = values[5];
+ Context->Listener->Matrix[0][0] = U[0];
+ Context->Listener->Matrix[0][1] = V[0];
+ Context->Listener->Matrix[0][2] = -N[0];
+ Context->Listener->Matrix[0][3] = 0.0f;
+ Context->Listener->Matrix[1][0] = U[1];
+ Context->Listener->Matrix[1][1] = V[1];
+ Context->Listener->Matrix[1][2] = -N[1];
+ Context->Listener->Matrix[1][3] = 0.0f;
+ Context->Listener->Matrix[2][0] = U[2];
+ Context->Listener->Matrix[2][1] = V[2];
+ Context->Listener->Matrix[2][2] = -N[2];
+ Context->Listener->Matrix[2][3] = 0.0f;
+ Context->Listener->Matrix[3][0] = 0.0f;
+ Context->Listener->Matrix[3][1] = 0.0f;
+ Context->Listener->Matrix[3][2] = 0.0f;
+ Context->Listener->Matrix[3][3] = 1.0f;
Context->UpdateSources = AL_TRUE;
UnlockContext(Context);
break;
@@ -297,11 +297,11 @@ AL_API ALvoid AL_APIENTRY alGetListenerf(ALenum param, ALfloat *value)
switch(param)
{
case AL_GAIN:
- *value = Context->Listener.Gain;
+ *value = Context->Listener->Gain;
break;
case AL_METERS_PER_UNIT:
- *value = Context->Listener.MetersPerUnit;
+ *value = Context->Listener->MetersPerUnit;
break;
default:
@@ -328,17 +328,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[0];
+ *value2 = Context->Listener->Position[1];
+ *value3 = Context->Listener->Position[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[0];
+ *value2 = Context->Listener->Velocity[1];
+ *value3 = Context->Listener->Velocity[2];
UnlockContext(Context);
break;
@@ -380,12 +380,12 @@ AL_API ALvoid AL_APIENTRY alGetListenerfv(ALenum param, ALfloat *values)
case AL_ORIENTATION:
LockContext(Context);
// AT then UP
- values[0] = Context->Listener.Forward[0];
- values[1] = Context->Listener.Forward[1];
- values[2] = Context->Listener.Forward[2];
- values[3] = Context->Listener.Up[0];
- values[4] = Context->Listener.Up[1];
- values[5] = Context->Listener.Up[2];
+ values[0] = Context->Listener->Forward[0];
+ values[1] = Context->Listener->Forward[1];
+ values[2] = Context->Listener->Forward[2];
+ values[3] = Context->Listener->Up[0];
+ values[4] = Context->Listener->Up[1];
+ values[5] = Context->Listener->Up[2];
UnlockContext(Context);
break;
@@ -435,17 +435,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[0];
+ *value2 = (ALint)Context->Listener->Position[1];
+ *value3 = (ALint)Context->Listener->Position[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[0];
+ *value2 = (ALint)Context->Listener->Velocity[1];
+ *value3 = (ALint)Context->Listener->Velocity[2];
UnlockContext(Context);
break;
@@ -482,12 +482,12 @@ AL_API void AL_APIENTRY alGetListeneriv(ALenum param, ALint* values)
case AL_ORIENTATION:
LockContext(Context);
// AT then UP
- values[0] = (ALint)Context->Listener.Forward[0];
- values[1] = (ALint)Context->Listener.Forward[1];
- values[2] = (ALint)Context->Listener.Forward[2];
- values[3] = (ALint)Context->Listener.Up[0];
- values[4] = (ALint)Context->Listener.Up[1];
- values[5] = (ALint)Context->Listener.Up[2];
+ values[0] = (ALint)Context->Listener->Forward[0];
+ values[1] = (ALint)Context->Listener->Forward[1];
+ values[2] = (ALint)Context->Listener->Forward[2];
+ values[3] = (ALint)Context->Listener->Up[0];
+ values[4] = (ALint)Context->Listener->Up[1];
+ values[5] = (ALint)Context->Listener->Up[2];
UnlockContext(Context);
break;