aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
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 /Alc
parent8c3419ed48b0221816314f605b0a7c6e045d95dc (diff)
Store a pointer to the listener in the context
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c33
-rw-r--r--Alc/ALu.c20
2 files changed, 27 insertions, 26 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);