aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/ALu.c8
-rw-r--r--OpenAL32/Include/alListener.h6
-rw-r--r--OpenAL32/alListener.c4
-rw-r--r--OpenAL32/alState.c10
4 files changed, 20 insertions, 8 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 6ae89b89..4a9a59cf 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -316,6 +316,10 @@ static ALboolean CalcListenerParams(ALCcontext *Context)
Listener->Params.SpeedOfSound = ATOMIC_LOAD(&props->SpeedOfSound, almemory_order_relaxed) *
ATOMIC_LOAD(&props->DopplerVelocity, almemory_order_relaxed);
+ Listener->Params.SourceDistanceModel = ATOMIC_LOAD(&props->SourceDistanceModel,
+ almemory_order_relaxed);
+ Listener->Params.DistanceModel = ATOMIC_LOAD(&props->DistanceModel, almemory_order_relaxed);
+
/* WARNING: A livelock is theoretically possible if another thread keeps
* changing the freelist head without giving this a chance to actually swap
* in the old container (practically impossible with this little code,
@@ -960,8 +964,8 @@ ALvoid CalcSourceParams(ALvoice *voice, const ALsource *ALSource, const ALbuffer
Attenuation = 1.0f;
for(i = 0;i < NumSends;i++)
RoomAttenuation[i] = 1.0f;
- switch(ALContext->SourceDistanceModel ? ALSource->DistanceModel :
- ALContext->DistanceModel)
+ switch(Listener->Params.SourceDistanceModel ? ALSource->DistanceModel :
+ Listener->Params.DistanceModel)
{
case InverseDistanceClamped:
ClampedDist = clampf(ClampedDist, MinDist, MaxDist);
diff --git a/OpenAL32/Include/alListener.h b/OpenAL32/Include/alListener.h
index 75a3fb46..dee66720 100644
--- a/OpenAL32/Include/alListener.h
+++ b/OpenAL32/Include/alListener.h
@@ -20,6 +20,9 @@ struct ALlistenerProps {
ATOMIC(ALfloat) DopplerVelocity;
ATOMIC(ALfloat) SpeedOfSound;
+ ATOMIC(ALboolean) SourceDistanceModel;
+ ATOMIC(enum DistanceModel) DistanceModel;
+
ATOMIC(struct ALlistenerProps*) next;
};
@@ -49,6 +52,9 @@ typedef struct ALlistener {
ALfloat DopplerFactor;
ALfloat SpeedOfSound;
+
+ ALboolean SourceDistanceModel;
+ enum DistanceModel DistanceModel;
} Params;
} ALlistener;
diff --git a/OpenAL32/alListener.c b/OpenAL32/alListener.c
index b215f678..1c40c399 100644
--- a/OpenAL32/alListener.c
+++ b/OpenAL32/alListener.c
@@ -490,6 +490,10 @@ void UpdateListenerProps(ALCcontext *context)
ATOMIC_STORE(&props->DopplerVelocity, context->DopplerVelocity, almemory_order_relaxed);
ATOMIC_STORE(&props->SpeedOfSound, context->SpeedOfSound, almemory_order_relaxed);
+ ATOMIC_STORE(&props->SourceDistanceModel, context->SourceDistanceModel,
+ almemory_order_relaxed);
+ ATOMIC_STORE(&props->DistanceModel, context->DistanceModel, almemory_order_relaxed);
+
/* Set the new container for updating internal parameters. */
props = ATOMIC_EXCHANGE(struct ALlistenerProps*, &listener->Update, props, almemory_order_acq_rel);
if(props)
diff --git a/OpenAL32/alState.c b/OpenAL32/alState.c
index 899dacd4..c0c2ca82 100644
--- a/OpenAL32/alState.c
+++ b/OpenAL32/alState.c
@@ -52,6 +52,7 @@ AL_API ALvoid AL_APIENTRY alEnable(ALenum capability)
context = GetContextRef();
if(!context) return;
+ WriteLock(&context->PropLock);
switch(capability)
{
case AL_SOURCE_DISTANCE_MODEL:
@@ -61,12 +62,10 @@ AL_API ALvoid AL_APIENTRY alEnable(ALenum capability)
default:
SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
}
- /* HACK: Force sources to update by doing a listener update */
- ReadLock(&context->PropLock);
UpdateListenerProps(context);
- ReadUnlock(&context->PropLock);
done:
+ WriteUnlock(&context->PropLock);
ALCcontext_DecRef(context);
}
@@ -77,6 +76,7 @@ AL_API ALvoid AL_APIENTRY alDisable(ALenum capability)
context = GetContextRef();
if(!context) return;
+ WriteLock(&context->PropLock);
switch(capability)
{
case AL_SOURCE_DISTANCE_MODEL:
@@ -86,12 +86,10 @@ AL_API ALvoid AL_APIENTRY alDisable(ALenum capability)
default:
SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
}
- /* HACK: Force sources to update by doing a listener update */
- ReadLock(&context->PropLock);
UpdateListenerProps(context);
- ReadUnlock(&context->PropLock);
done:
+ WriteUnlock(&context->PropLock);
ALCcontext_DecRef(context);
}