aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/ALu.c10
-rw-r--r--OpenAL32/Include/alSource.h2
-rw-r--r--OpenAL32/Include/alu.h6
-rw-r--r--OpenAL32/alSource.c16
4 files changed, 21 insertions, 13 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 7684a86f..7270cc16 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -113,7 +113,7 @@ static __inline ALvoid aluMatrixVector(ALfloat *vector,ALfloat w,ALfloat matrix[
vector[2] = temp[0]*matrix[0][2] + temp[1]*matrix[1][2] + temp[2]*matrix[2][2] + temp[3]*matrix[3][2];
}
-static ALvoid CalcNonAttnSourceParams(const ALCcontext *ALContext, ALsource *ALSource)
+ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
{
ALfloat SourceVolume,ListenerGain,MinVolume,MaxVolume;
ALfloat DryGain, DryGainHF;
@@ -194,7 +194,7 @@ static ALvoid CalcNonAttnSourceParams(const ALCcontext *ALContext, ALsource *ALS
}
}
-static ALvoid CalcSourceParams(const ALCcontext *ALContext, ALsource *ALSource)
+ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
{
const ALCdevice *Device = ALContext->Device;
ALfloat InnerAngle,OuterAngle,Angle,Distance,DryMix,OrigDist;
@@ -635,11 +635,7 @@ static void MixSource(ALsource *ALSource, ALCcontext *ALContext,
if(ALSource->NeedsUpdate)
{
- //Only apply 3D calculations for mono buffers
- if(Channels == 1)
- CalcSourceParams(ALContext, ALSource);
- else
- CalcNonAttnSourceParams(ALContext, ALSource);
+ ALsource_Update(ALSource, ALContext);
ALSource->NeedsUpdate = AL_FALSE;
}
diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h
index 0802cbaa..97ecbecf 100644
--- a/OpenAL32/Include/alSource.h
+++ b/OpenAL32/Include/alSource.h
@@ -101,10 +101,12 @@ typedef struct ALsource
FILTER iirFilter;
ALfloat history[OUTPUTCHANNELS*2];
} Params;
+ ALvoid (*Update)(struct ALsource *self, const ALCcontext *context);
// Index to itself
ALuint source;
} ALsource;
+#define ALsource_Update(s,a) ((s)->Update(s,a))
ALvoid ReleaseALSources(ALCcontext *Context);
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index 55ddbaf6..bd28771f 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -177,7 +177,13 @@ static __inline ALint aluCart2LUTpos(ALfloat re, ALfloat im)
return pos%LUT_NUM;
}
+struct ALsource;
+
ALvoid aluInitPanning(ALCdevice *Device);
+
+ALvoid CalcSourceParams(struct ALsource *ALSource, const ALCcontext *ALContext);
+ALvoid CalcNonAttnSourceParams(struct ALsource *ALSource, const ALCcontext *ALContext);
+
ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size);
ALvoid aluHandleDisconnect(ALCdevice *device);
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c
index 6e5ed1e6..0db6f76b 100644
--- a/OpenAL32/alSource.c
+++ b/OpenAL32/alSource.c
@@ -574,6 +574,11 @@ AL_API ALvoid AL_APIENTRY alSourcei(ALuint source,ALenum eParam,ALint lValue)
Source->queue = BufferListItem;
Source->BuffersInQueue = 1;
+ if(aluChannelsFromFormat(buffer->format) == 1)
+ Source->Update = CalcSourceParams;
+ else
+ Source->Update = CalcNonAttnSourceParams;
+
// Increment reference counter for buffer
buffer->refcount++;
}
@@ -1560,7 +1565,6 @@ AL_API ALvoid AL_APIENTRY alSourceQueueBuffers(ALuint source, ALsizei n, const A
ALsizei i;
ALbufferlistitem *BufferListStart;
ALbufferlistitem *BufferList;
- ALboolean HadFormat;
ALint Frequency;
ALint Format;
@@ -1591,7 +1595,6 @@ AL_API ALvoid AL_APIENTRY alSourceQueueBuffers(ALuint source, ALsizei n, const A
Frequency = -1;
Format = -1;
- HadFormat = AL_FALSE;
// Check existing Queue (if any) for a valid Buffers and get its frequency and format
BufferList = Source->queue;
@@ -1601,7 +1604,6 @@ AL_API ALvoid AL_APIENTRY alSourceQueueBuffers(ALuint source, ALsizei n, const A
{
Frequency = BufferList->buffer->frequency;
Format = BufferList->buffer->eOriginalFormat;
- HadFormat = AL_TRUE;
break;
}
BufferList = BufferList->next;
@@ -1622,6 +1624,11 @@ AL_API ALvoid AL_APIENTRY alSourceQueueBuffers(ALuint source, ALsizei n, const A
{
Frequency = buffer->frequency;
Format = buffer->eOriginalFormat;
+ if(aluChannelsFromFormat(buffer->format) == 1)
+ Source->Update = CalcSourceParams;
+ else
+ Source->Update = CalcNonAttnSourceParams;
+ Source->NeedsUpdate = AL_TRUE;
}
else if(Frequency != buffer->frequency || Format != buffer->eOriginalFormat)
{
@@ -1677,9 +1684,6 @@ AL_API ALvoid AL_APIENTRY alSourceQueueBuffers(ALuint source, ALsizei n, const A
// Update number of buffers in queue
Source->BuffersInQueue += n;
- // If no previous format, mark the source dirty now that it may have one
- if(!HadFormat)
- Source->NeedsUpdate = AL_TRUE;
done:
ProcessContext(Context);