diff options
author | Chris Robinson <[email protected]> | 2017-03-20 21:25:39 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2017-03-20 21:25:39 -0700 |
commit | cdfe0d8f5af871258f1f58493e9659148659cacb (patch) | |
tree | 61412add20d91a243c18d3c8e18213adfe18806e /OpenAL32/alSource.c | |
parent | 42bcf0870d7f7358b4e1775d37e20e3b9162d249 (diff) |
Use an atomic flag to test if a source needs to update
Diffstat (limited to 'OpenAL32/alSource.c')
-rw-r--r-- | OpenAL32/alSource.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index fef00e5a..e32bb5c8 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -421,7 +421,7 @@ static ALint Int64ValsByProp(ALenum prop) if(SourceShouldUpdate(Source, Context)) \ UpdateSourceProps(Source, device->NumAuxSends); \ else \ - Source->NeedsUpdate = AL_TRUE; \ + ATOMIC_FLAG_CLEAR(&Source->PropsClean, almemory_order_release); \ } while(0) static ALboolean SetSourcefv(ALsource *Source, ALCcontext *Context, SourceProp prop, const ALfloat *values) @@ -2429,7 +2429,7 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources) break; } - source->NeedsUpdate = AL_FALSE; + ATOMIC_FLAG_TEST_AND_SET(&source->PropsClean, almemory_order_acquire); UpdateSourceProps(source, device->NumAuxSends); /* Make sure this source isn't already active, and if not, look for an @@ -2948,7 +2948,10 @@ static void InitSourceParams(ALsource *Source, ALsizei num_sends) ATOMIC_INIT(&Source->looping, AL_FALSE); - Source->NeedsUpdate = AL_TRUE; + /* No way to do an 'init' here, so just test+set with relaxed ordering and + * ignore the test. + */ + ATOMIC_FLAG_TEST_AND_SET(&Source->PropsClean, almemory_order_relaxed); ATOMIC_INIT(&Source->Update, NULL); ATOMIC_INIT(&Source->FreeList, NULL); @@ -3098,11 +3101,8 @@ void UpdateAllSourceProps(ALCcontext *context) { ALvoice *voice = context->Voices[pos]; ALsource *source = ATOMIC_LOAD(&voice->Source, almemory_order_acquire); - if(source != NULL && source->NeedsUpdate) - { - source->NeedsUpdate = AL_FALSE; + if(source != NULL && ATOMIC_FLAG_TEST_AND_SET(&source->PropsClean, almemory_order_acq_rel)) UpdateSourceProps(source, num_sends); - } } } |