diff options
-rw-r--r-- | Alc/ALu.c | 7 | ||||
-rw-r--r-- | OpenAL32/Include/alListener.h | 5 | ||||
-rw-r--r-- | OpenAL32/alListener.c | 3 | ||||
-rw-r--r-- | OpenAL32/alSource.c | 17 | ||||
-rw-r--r-- | OpenAL32/alState.c | 6 |
5 files changed, 24 insertions, 14 deletions
@@ -278,6 +278,9 @@ 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, @@ -939,7 +942,9 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALsourceProps *pro Attenuation = 1.0f; for(i = 0;i < NumSends;i++) RoomAttenuation[i] = 1.0f; - switch(ATOMIC_LOAD(&props->DistanceModel, almemory_order_relaxed)) + switch(Listener->Params.SourceDistanceModel ? + ATOMIC_LOAD(&props->DistanceModel, almemory_order_relaxed) : + Listener->Params.DistanceModel) { case InverseDistanceClamped: ClampedDist = clampf(ClampedDist, MinDist, MaxDist); diff --git a/OpenAL32/Include/alListener.h b/OpenAL32/Include/alListener.h index a10d6728..b89a00e7 100644 --- a/OpenAL32/Include/alListener.h +++ b/OpenAL32/Include/alListener.h @@ -19,6 +19,8 @@ struct ALlistenerProps { ATOMIC(ALfloat) DopplerFactor; ATOMIC(ALfloat) DopplerVelocity; ATOMIC(ALfloat) SpeedOfSound; + ATOMIC(ALboolean) SourceDistanceModel; + ATOMIC(enum DistanceModel) DistanceModel; ATOMIC(struct ALlistenerProps*) next; }; @@ -49,6 +51,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 3ea23732..08ece19d 100644 --- a/OpenAL32/alListener.c +++ b/OpenAL32/alListener.c @@ -496,6 +496,9 @@ 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/alSource.c b/OpenAL32/alSource.c index fb2ada10..891286a2 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -49,7 +49,7 @@ extern inline struct ALsource *RemoveSource(ALCcontext *context, ALuint id); static void InitSourceParams(ALsource *Source); static void DeinitSource(ALsource *source); -static void UpdateSourceProps(ALsource *source, ALuint num_sends, ALCcontext *context); +static void UpdateSourceProps(ALsource *source, ALuint num_sends); static ALint64 GetSourceSampleOffset(ALsource *Source, ALCdevice *device, ALuint64 *clocktime); static ALdouble GetSourceSecOffset(ALsource *Source, ALCdevice *device, ALuint64 *clocktime); static ALdouble GetSourceOffset(ALsource *Source, ALenum name, ALCdevice *device); @@ -386,7 +386,7 @@ static ALint Int64ValsByProp(ALenum prop) #define DO_UPDATEPROPS() do { \ if(SourceShouldUpdate(Source, Context)) \ - UpdateSourceProps(Source, device->NumAuxSends, Context); \ + UpdateSourceProps(Source, device->NumAuxSends); \ } while(0) static ALboolean SetSourcefv(ALsource *Source, ALCcontext *Context, SourceProp prop, const ALfloat *values) @@ -840,7 +840,7 @@ static ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp p /* We must force an update if the auxiliary slot changed on a * playing source, in case the slot is about to be deleted. */ - UpdateSourceProps(Source, device->NumAuxSends, Context); + UpdateSourceProps(Source, device->NumAuxSends); } else { @@ -2813,7 +2813,7 @@ static void DeinitSource(ALsource *source) } } -static void UpdateSourceProps(ALsource *source, ALuint num_sends, ALCcontext *context) +static void UpdateSourceProps(ALsource *source, ALuint num_sends) { struct ALsourceProps *props; size_t i; @@ -2857,10 +2857,7 @@ static void UpdateSourceProps(ALsource *source, ALuint num_sends, ALCcontext *co almemory_order_relaxed); } ATOMIC_STORE(&props->HeadRelative, source->HeadRelative, almemory_order_relaxed); - ATOMIC_STORE(&props->DistanceModel, - context->SourceDistanceModel ? source->DistanceModel : context->DistanceModel, - almemory_order_relaxed - ); + ATOMIC_STORE(&props->DistanceModel, source->DistanceModel, almemory_order_relaxed); ATOMIC_STORE(&props->DirectChannels, source->DirectChannels, almemory_order_relaxed); ATOMIC_STORE(&props->DryGainHFAuto, source->DryGainHFAuto, almemory_order_relaxed); @@ -2928,7 +2925,7 @@ void UpdateAllSourceProps(ALCcontext *context) ALsource *source = voice->Source; if(source != NULL && (source->state == AL_PLAYING || source->state == AL_PAUSED)) - UpdateSourceProps(source, num_sends, context); + UpdateSourceProps(source, num_sends); } /* Now with all updates declared, let the mixer continue applying them so * they all happen at once. @@ -3037,7 +3034,7 @@ ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state) } } - UpdateSourceProps(Source, device->NumAuxSends, Context); + UpdateSourceProps(Source, device->NumAuxSends); } else if(state == AL_PAUSED) { diff --git a/OpenAL32/alState.c b/OpenAL32/alState.c index 59814a4b..fa3b190a 100644 --- a/OpenAL32/alState.c +++ b/OpenAL32/alState.c @@ -63,7 +63,7 @@ AL_API ALvoid AL_APIENTRY alEnable(ALenum capability) SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); } if(!ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) - UpdateAllSourceProps(context); + UpdateListenerProps(context); done: WriteUnlock(&context->PropLock); @@ -88,7 +88,7 @@ AL_API ALvoid AL_APIENTRY alDisable(ALenum capability) SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); } if(!ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) - UpdateAllSourceProps(context); + UpdateListenerProps(context); done: WriteUnlock(&context->PropLock); @@ -622,7 +622,7 @@ AL_API ALvoid AL_APIENTRY alDistanceModel(ALenum value) if(!context->SourceDistanceModel) { if(!ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) - UpdateAllSourceProps(context); + UpdateListenerProps(context); } WriteUnlock(&context->PropLock); |