Store the remaining context properties with the listener properties
This commit is contained in:
parent
93a94d177c
commit
f751f5e25e
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user