From 6886f77cbc02b93db3682acb27eb767c6541fba0 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 23 Nov 2016 01:31:13 -0800 Subject: Only send source updates for sources that have updated --- Alc/ALc.c | 3 ++- OpenAL32/Include/alSource.h | 2 ++ OpenAL32/alSource.c | 11 ++++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Alc/ALc.c b/Alc/ALc.c index 9d3467f7..2e7c1e7f 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -2141,10 +2141,11 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) source->Send[s].LFReference = HIGHPASSFREQREF; s++; } + source->NeedsUpdate = AL_TRUE; } UnlockUIntMapRead(&context->SourceMap); - UpdateAllSourceProps(context); + UpdateListenerProps(context); ReadUnlock(&context->PropLock); context = context->next; diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h index d5eb3c50..8b793102 100644 --- a/OpenAL32/Include/alSource.h +++ b/OpenAL32/Include/alSource.h @@ -197,6 +197,8 @@ typedef struct ALsource { ALuint NumChannels; ALuint SampleSize; + ALenum NeedsUpdate; + ATOMIC(struct ALsourceProps*) Update; ATOMIC(struct ALsourceProps*) FreeList; diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index b65c2c18..9ef58115 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -399,6 +399,8 @@ static ALint Int64ValsByProp(ALenum prop) #define DO_UPDATEPROPS() do { \ if(SourceShouldUpdate(Source, Context)) \ UpdateSourceProps(Source, device->NumAuxSends); \ + else \ + Source->NeedsUpdate = AL_TRUE; \ } while(0) static ALboolean SetSourcefv(ALsource *Source, ALCcontext *Context, SourceProp prop, const ALfloat *values) @@ -2772,6 +2774,8 @@ static void InitSourceParams(ALsource *Source) ATOMIC_INIT(&Source->looping, AL_FALSE); + Source->NeedsUpdate = AL_TRUE; + ATOMIC_INIT(&Source->Update, NULL); ATOMIC_INIT(&Source->FreeList, NULL); } @@ -2924,8 +2928,12 @@ void UpdateAllSourceProps(ALCcontext *context) ALvoice *voice = &context->Voices[pos]; ALsource *source = voice->Source; if(source != NULL && (source->state == AL_PLAYING || - source->state == AL_PAUSED)) + source->state == AL_PAUSED) && + source->NeedsUpdate) + { + source->NeedsUpdate = AL_FALSE; UpdateSourceProps(source, num_sends); + } } } @@ -3029,6 +3037,7 @@ ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state) } } + Source->NeedsUpdate = AL_FALSE; UpdateSourceProps(Source, device->NumAuxSends); } else if(state == AL_PAUSED) -- cgit v1.2.3