aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/alSource.h1
-rw-r--r--OpenAL32/alAuxEffectSlot.c26
-rw-r--r--OpenAL32/alListener.c67
-rw-r--r--OpenAL32/alSource.c68
-rw-r--r--OpenAL32/alState.c47
5 files changed, 191 insertions, 18 deletions
diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h
index 663a9e35..1e54031b 100644
--- a/OpenAL32/Include/alSource.h
+++ b/OpenAL32/Include/alSource.h
@@ -85,6 +85,7 @@ typedef struct ALsource
ALboolean FirstStart;
// Current target parameters used for mixing
+ ALboolean NeedsUpdate;
struct {
ALfloat DryGains[OUTPUTCHANNELS];
ALfloat WetGains[MAX_SENDS];
diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c
index 700b9d28..74097d3f 100644
--- a/OpenAL32/alAuxEffectSlot.c
+++ b/OpenAL32/alAuxEffectSlot.c
@@ -29,6 +29,7 @@
#include "alAuxEffectSlot.h"
#include "alThunk.h"
#include "alError.h"
+#include "alSource.h"
static ALvoid InitializeEffect(ALCcontext *Context, ALeffectslot *ALEffectSlot, ALeffect *effect);
@@ -179,6 +180,7 @@ ALboolean AL_APIENTRY alIsAuxiliaryEffectSlot(ALuint effectslot)
ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint iValue)
{
ALCcontext *Context;
+ ALboolean updateSources = AL_FALSE;
Context = GetContextSuspended();
if(!Context) return;
@@ -194,6 +196,7 @@ ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint
{
ALeffect *effect = (ALeffect*)ALTHUNK_LOOKUPENTRY(iValue);
InitializeEffect(Context, ALEffectSlot, effect);
+ updateSources = AL_TRUE;
}
else
alSetError(AL_INVALID_VALUE);
@@ -201,7 +204,10 @@ ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint
case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO:
if(iValue == AL_TRUE || iValue == AL_FALSE)
+ {
ALEffectSlot->AuxSendAuto = iValue;
+ updateSources = AL_TRUE;
+ }
else
alSetError(AL_INVALID_VALUE);
break;
@@ -214,6 +220,26 @@ ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint
else
alSetError(AL_INVALID_NAME);
+ // Force updating the sources that use this slot, since it affects the
+ // sending parameters
+ if(updateSources)
+ {
+ ALsource *source = Context->Source;
+ while(source)
+ {
+ ALuint i;
+ for(i = 0;i < MAX_SENDS;i++)
+ {
+ if(!source->Send[i].Slot ||
+ source->Send[i].Slot->effectslot != effectslot)
+ continue;
+ source->NeedsUpdate = AL_TRUE;
+ break;
+ }
+ source = source->next;
+ }
+ }
+
ProcessContext(Context);
}
diff --git a/OpenAL32/alListener.c b/OpenAL32/alListener.c
index cef7ae4b..303d2f93 100644
--- a/OpenAL32/alListener.c
+++ b/OpenAL32/alListener.c
@@ -24,10 +24,12 @@
#include "AL/alc.h"
#include "alError.h"
#include "alListener.h"
+#include "alSource.h"
ALAPI ALvoid ALAPIENTRY alListenerf(ALenum eParam, ALfloat flValue)
{
ALCcontext *pContext;
+ ALboolean updateAll = AL_FALSE;
pContext = GetContextSuspended();
if(!pContext) return;
@@ -36,14 +38,20 @@ ALAPI ALvoid ALAPIENTRY alListenerf(ALenum eParam, ALfloat flValue)
{
case AL_GAIN:
if(flValue >= 0.0f)
+ {
pContext->Listener.Gain = flValue;
+ updateAll = AL_TRUE;
+ }
else
alSetError(AL_INVALID_VALUE);
break;
case AL_METERS_PER_UNIT:
if(flValue > 0.0f)
+ {
pContext->Listener.MetersPerUnit = flValue;
+ updateAll = AL_TRUE;
+ }
else
alSetError(AL_INVALID_VALUE);
break;
@@ -53,6 +61,18 @@ ALAPI ALvoid ALAPIENTRY alListenerf(ALenum eParam, ALfloat flValue)
break;
}
+ // Force updating the sources for these parameters, since even head-
+ // relative sources are affected
+ if(updateAll)
+ {
+ ALsource *source = pContext->Source;
+ while(source)
+ {
+ source->NeedsUpdate = AL_TRUE;
+ source = source->next;
+ }
+ }
+
ProcessContext(pContext);
}
@@ -60,6 +80,7 @@ ALAPI ALvoid ALAPIENTRY alListenerf(ALenum eParam, ALfloat flValue)
ALAPI ALvoid ALAPIENTRY alListener3f(ALenum eParam, ALfloat flValue1, ALfloat flValue2, ALfloat flValue3)
{
ALCcontext *pContext;
+ ALboolean updateWorld = AL_FALSE;
pContext = GetContextSuspended();
if(!pContext) return;
@@ -70,12 +91,14 @@ ALAPI ALvoid ALAPIENTRY alListener3f(ALenum eParam, ALfloat flValue1, ALfloat fl
pContext->Listener.Position[0] = flValue1;
pContext->Listener.Position[1] = flValue2;
pContext->Listener.Position[2] = flValue3;
+ updateWorld = AL_TRUE;
break;
case AL_VELOCITY:
pContext->Listener.Velocity[0] = flValue1;
pContext->Listener.Velocity[1] = flValue2;
pContext->Listener.Velocity[2] = flValue3;
+ updateWorld = AL_TRUE;
break;
default:
@@ -83,6 +106,17 @@ ALAPI ALvoid ALAPIENTRY alListener3f(ALenum eParam, ALfloat flValue1, ALfloat fl
break;
}
+ if(updateWorld)
+ {
+ ALsource *source = pContext->Source;
+ while(source)
+ {
+ if(!source->bHeadRelative)
+ source->NeedsUpdate = AL_TRUE;
+ source = source->next;
+ }
+ }
+
ProcessContext(pContext);
}
@@ -90,6 +124,7 @@ ALAPI ALvoid ALAPIENTRY alListener3f(ALenum eParam, ALfloat flValue1, ALfloat fl
ALAPI ALvoid ALAPIENTRY alListenerfv(ALenum eParam, const ALfloat *pflValues)
{
ALCcontext *pContext;
+ ALboolean updateWorld = AL_FALSE;
pContext = GetContextSuspended();
if(!pContext) return;
@@ -99,29 +134,13 @@ ALAPI ALvoid ALAPIENTRY alListenerfv(ALenum eParam, const ALfloat *pflValues)
switch(eParam)
{
case AL_GAIN:
- if(pflValues[0] >= 0.0f)
- pContext->Listener.Gain = pflValues[0];
- else
- alSetError(AL_INVALID_VALUE);
- break;
-
case AL_METERS_PER_UNIT:
- if(pflValues[0] > 0.0f)
- pContext->Listener.MetersPerUnit = pflValues[0];
- else
- alSetError(AL_INVALID_VALUE);
+ alListenerf(eParam, pflValues[0]);
break;
case AL_POSITION:
- pContext->Listener.Position[0] = pflValues[0];
- pContext->Listener.Position[1] = pflValues[1];
- pContext->Listener.Position[2] = pflValues[2];
- break;
-
case AL_VELOCITY:
- pContext->Listener.Velocity[0] = pflValues[0];
- pContext->Listener.Velocity[1] = pflValues[1];
- pContext->Listener.Velocity[2] = pflValues[2];
+ alListener3f(eParam, pflValues[0], pflValues[1], pflValues[2]);
break;
case AL_ORIENTATION:
@@ -132,6 +151,7 @@ ALAPI ALvoid ALAPIENTRY alListenerfv(ALenum eParam, const ALfloat *pflValues)
pContext->Listener.Up[0] = pflValues[3];
pContext->Listener.Up[1] = pflValues[4];
pContext->Listener.Up[2] = pflValues[5];
+ updateWorld = AL_TRUE;
break;
default:
@@ -142,6 +162,17 @@ ALAPI ALvoid ALAPIENTRY alListenerfv(ALenum eParam, const ALfloat *pflValues)
else
alSetError(AL_INVALID_VALUE);
+ if(updateWorld)
+ {
+ ALsource *source = pContext->Source;
+ while(source)
+ {
+ if(!source->bHeadRelative)
+ source->NeedsUpdate = AL_TRUE;
+ source = source->next;
+ }
+ }
+
ProcessContext(pContext);
}
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c
index 2e725081..fb0ac514 100644
--- a/OpenAL32/alSource.c
+++ b/OpenAL32/alSource.c
@@ -230,6 +230,7 @@ ALAPI ALvoid ALAPIENTRY alSourcef(ALuint source, ALenum eParam, ALfloat flValue)
pSource->flPitch = flValue;
if(pSource->flPitch < 0.001f)
pSource->flPitch = 0.001f;
+ pSource->NeedsUpdate = AL_TRUE;
}
else
alSetError(AL_INVALID_VALUE);
@@ -237,91 +238,130 @@ ALAPI ALvoid ALAPIENTRY alSourcef(ALuint source, ALenum eParam, ALfloat flValue)
case AL_CONE_INNER_ANGLE:
if(flValue >= 0.0f && flValue <= 360.0f)
+ {
pSource->flInnerAngle = flValue;
+ pSource->NeedsUpdate = AL_TRUE;
+ }
else
alSetError(AL_INVALID_VALUE);
break;
case AL_CONE_OUTER_ANGLE:
if(flValue >= 0.0f && flValue <= 360.0f)
+ {
pSource->flOuterAngle = flValue;
+ pSource->NeedsUpdate = AL_TRUE;
+ }
else
alSetError(AL_INVALID_VALUE);
break;
case AL_GAIN:
if(flValue >= 0.0f)
+ {
pSource->flGain = flValue;
+ pSource->NeedsUpdate = AL_TRUE;
+ }
else
alSetError(AL_INVALID_VALUE);
break;
case AL_MAX_DISTANCE:
if(flValue >= 0.0f)
+ {
pSource->flMaxDistance = flValue;
+ pSource->NeedsUpdate = AL_TRUE;
+ }
else
alSetError(AL_INVALID_VALUE);
break;
case AL_ROLLOFF_FACTOR:
if(flValue >= 0.0f)
+ {
pSource->flRollOffFactor = flValue;
+ pSource->NeedsUpdate = AL_TRUE;
+ }
else
alSetError(AL_INVALID_VALUE);
break;
case AL_REFERENCE_DISTANCE:
if(flValue >= 0.0f)
+ {
pSource->flRefDistance = flValue;
+ pSource->NeedsUpdate = AL_TRUE;
+ }
else
alSetError(AL_INVALID_VALUE);
break;
case AL_MIN_GAIN:
if(flValue >= 0.0f && flValue <= 1.0f)
+ {
pSource->flMinGain = flValue;
+ pSource->NeedsUpdate = AL_TRUE;
+ }
else
alSetError(AL_INVALID_VALUE);
break;
case AL_MAX_GAIN:
if(flValue >= 0.0f && flValue <= 1.0f)
+ {
pSource->flMaxGain = flValue;
+ pSource->NeedsUpdate = AL_TRUE;
+ }
else
alSetError(AL_INVALID_VALUE);
break;
case AL_CONE_OUTER_GAIN:
if(flValue >= 0.0f && flValue <= 1.0f)
+ {
pSource->flOuterGain = flValue;
+ pSource->NeedsUpdate = AL_TRUE;
+ }
else
alSetError(AL_INVALID_VALUE);
break;
case AL_CONE_OUTER_GAINHF:
if(flValue >= 0.0f && flValue <= 1.0f)
+ {
pSource->OuterGainHF = flValue;
+ pSource->NeedsUpdate = AL_TRUE;
+ }
else
alSetError(AL_INVALID_VALUE);
break;
case AL_AIR_ABSORPTION_FACTOR:
if(flValue >= 0.0f && flValue <= 10.0f)
+ {
pSource->AirAbsorptionFactor = flValue;
+ pSource->NeedsUpdate = AL_TRUE;
+ }
else
alSetError(AL_INVALID_VALUE);
break;
case AL_ROOM_ROLLOFF_FACTOR:
if(flValue >= 0.0f && flValue <= 10.0f)
+ {
pSource->RoomRolloffFactor = flValue;
+ pSource->NeedsUpdate = AL_TRUE;
+ }
else
alSetError(AL_INVALID_VALUE);
break;
case AL_DOPPLER_FACTOR:
if(flValue >= 0.0f && flValue <= 1.0f)
+ {
pSource->DopplerFactor = flValue;
+ pSource->NeedsUpdate = AL_TRUE;
+ }
else
alSetError(AL_INVALID_VALUE);
break;
@@ -378,18 +418,21 @@ ALAPI ALvoid ALAPIENTRY alSource3f(ALuint source, ALenum eParam, ALfloat flValue
pSource->vPosition[0] = flValue1;
pSource->vPosition[1] = flValue2;
pSource->vPosition[2] = flValue3;
+ pSource->NeedsUpdate = AL_TRUE;
break;
case AL_VELOCITY:
pSource->vVelocity[0] = flValue1;
pSource->vVelocity[1] = flValue2;
pSource->vVelocity[2] = flValue3;
+ pSource->NeedsUpdate = AL_TRUE;
break;
case AL_DIRECTION:
pSource->vOrientation[0] = flValue1;
pSource->vOrientation[1] = flValue2;
pSource->vOrientation[2] = flValue3;
+ pSource->NeedsUpdate = AL_TRUE;
break;
default:
@@ -480,21 +523,30 @@ ALAPI ALvoid ALAPIENTRY alSourcei(ALuint source,ALenum eParam,ALint lValue)
case AL_SOURCE_RELATIVE:
if(lValue == AL_FALSE || lValue == AL_TRUE)
+ {
pSource->bHeadRelative = (ALboolean)lValue;
+ pSource->NeedsUpdate = AL_TRUE;
+ }
else
alSetError(AL_INVALID_VALUE);
break;
case AL_CONE_INNER_ANGLE:
if(lValue >= 0 && lValue <= 360)
+ {
pSource->flInnerAngle = (float)lValue;
+ pSource->NeedsUpdate = AL_TRUE;
+ }
else
alSetError(AL_INVALID_VALUE);
break;
case AL_CONE_OUTER_ANGLE:
if(lValue >= 0 && lValue <= 360)
+ {
pSource->flOuterAngle = (float)lValue;
+ pSource->NeedsUpdate = AL_TRUE;
+ }
else
alSetError(AL_INVALID_VALUE);
break;
@@ -599,6 +651,7 @@ ALAPI ALvoid ALAPIENTRY alSourcei(ALuint source,ALenum eParam,ALint lValue)
}
else
memcpy(&pSource->DirectFilter, filter, sizeof(*filter));
+ pSource->NeedsUpdate = AL_TRUE;
}
else
alSetError(AL_INVALID_VALUE);
@@ -606,21 +659,30 @@ ALAPI ALvoid ALAPIENTRY alSourcei(ALuint source,ALenum eParam,ALint lValue)
case AL_DIRECT_FILTER_GAINHF_AUTO:
if(lValue == AL_TRUE || lValue == AL_FALSE)
+ {
pSource->DryGainHFAuto = lValue;
+ pSource->NeedsUpdate = AL_TRUE;
+ }
else
alSetError(AL_INVALID_VALUE);
break;
case AL_AUXILIARY_SEND_FILTER_GAIN_AUTO:
if(lValue == AL_TRUE || lValue == AL_FALSE)
+ {
pSource->WetGainAuto = lValue;
+ pSource->NeedsUpdate = AL_TRUE;
+ }
else
alSetError(AL_INVALID_VALUE);
break;
case AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO:
if(lValue == AL_TRUE || lValue == AL_FALSE)
+ {
pSource->WetGainHFAuto = lValue;
+ pSource->NeedsUpdate = AL_TRUE;
+ }
else
alSetError(AL_INVALID_VALUE);
break;
@@ -633,7 +695,10 @@ ALAPI ALvoid ALAPIENTRY alSourcei(ALuint source,ALenum eParam,ALint lValue)
lValue == AL_LINEAR_DISTANCE_CLAMPED ||
lValue == AL_EXPONENT_DISTANCE ||
lValue == AL_EXPONENT_DISTANCE_CLAMPED)
+ {
pSource->DistanceModel = lValue;
+ pSource->NeedsUpdate = AL_TRUE;
+ }
else
alSetError(AL_INVALID_VALUE);
break;
@@ -694,6 +759,7 @@ ALAPI void ALAPIENTRY alSource3i(ALuint source, ALenum eParam, ALint lValue1, AL
}
else
memcpy(&pSource->Send[lValue2].WetFilter, ALFilter, sizeof(*ALFilter));
+ pSource->NeedsUpdate = AL_TRUE;
}
else
alSetError(AL_INVALID_VALUE);
@@ -1751,6 +1817,8 @@ static ALvoid InitSourceParams(ALCcontext *Context, ALsource *pSource)
pSource->state = AL_INITIAL;
pSource->lSourceType = AL_UNDETERMINED;
+ pSource->NeedsUpdate = AL_TRUE;
+
pSource->Buffer = NULL;
}
diff --git a/OpenAL32/alState.c b/OpenAL32/alState.c
index 7d370766..1516bb31 100644
--- a/OpenAL32/alState.c
+++ b/OpenAL32/alState.c
@@ -499,45 +499,89 @@ ALAPI const ALchar* ALAPIENTRY alGetString(ALenum pname)
ALAPI ALvoid ALAPIENTRY alDopplerFactor(ALfloat value)
{
ALCcontext *Context;
+ ALboolean updateSources = AL_FALSE;
Context = GetContextSuspended();
if(!Context) return;
if(value >= 0.0f)
+ {
Context->DopplerFactor = value;
+ updateSources = AL_TRUE;
+ }
else
alSetError(AL_INVALID_VALUE);
+ // Force updating the sources for these parameters, since even head-
+ // relative sources are affected
+ if(updateSources)
+ {
+ ALsource *source = Context->Source;
+ while(source)
+ {
+ source->NeedsUpdate = AL_TRUE;
+ source = source->next;
+ }
+ }
+
ProcessContext(Context);
}
ALAPI ALvoid ALAPIENTRY alDopplerVelocity(ALfloat value)
{
ALCcontext *Context;
+ ALboolean updateSources = AL_FALSE;
Context = GetContextSuspended();
if(!Context) return;
if(value > 0.0f)
+ {
Context->DopplerVelocity=value;
+ updateSources = AL_TRUE;
+ }
else
alSetError(AL_INVALID_VALUE);
+ if(updateSources)
+ {
+ ALsource *source = Context->Source;
+ while(source)
+ {
+ source->NeedsUpdate = AL_TRUE;
+ source = source->next;
+ }
+ }
+
ProcessContext(Context);
}
ALAPI ALvoid ALAPIENTRY alSpeedOfSound(ALfloat flSpeedOfSound)
{
ALCcontext *pContext;
+ ALboolean updateSources = AL_FALSE;
pContext = GetContextSuspended();
if(!pContext) return;
if(flSpeedOfSound > 0.0f)
+ {
pContext->flSpeedOfSound = flSpeedOfSound;
+ updateSources = AL_TRUE;
+ }
else
alSetError(AL_INVALID_VALUE);
+ if(updateSources)
+ {
+ ALsource *source = pContext->Source;
+ while(source)
+ {
+ source->NeedsUpdate = AL_TRUE;
+ source = source->next;
+ }
+ }
+
ProcessContext(pContext);
}
@@ -560,7 +604,10 @@ ALAPI ALvoid ALAPIENTRY alDistanceModel(ALenum value)
case AL_EXPONENT_DISTANCE_CLAMPED:
Context->DistanceModel = value;
for(Source = Context->Source;Source != NULL;Source = Source->next)
+ {
Source->DistanceModel = value;
+ Source->NeedsUpdate = AL_TRUE;
+ }
break;
default: