From a5f68c21214e6f85ade835cd29045026797ac2a4 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 13 Nov 2018 20:26:32 -0800 Subject: Avoid using ATOMIC_FLAG Although it cant potentially be better than a regular atomic, it presents compatibility issues when non-C11 atomics are mixed with C++ --- OpenAL32/Include/alAuxEffectSlot.h | 2 +- OpenAL32/Include/alListener.h | 2 +- OpenAL32/Include/alMain.h | 2 +- OpenAL32/Include/alSource.h | 2 +- OpenAL32/alAuxEffectSlot.c | 6 +++--- OpenAL32/alListener.c | 4 ++-- OpenAL32/alSource.c | 13 +++++-------- OpenAL32/alState.c | 2 +- 8 files changed, 15 insertions(+), 18 deletions(-) (limited to 'OpenAL32') diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h index 97a3906d..16de9a79 100644 --- a/OpenAL32/Include/alAuxEffectSlot.h +++ b/OpenAL32/Include/alAuxEffectSlot.h @@ -111,7 +111,7 @@ typedef struct ALeffectslot { ALeffectState *State; } Effect; - ATOMIC_FLAG PropsClean; + ATOMIC(ALenum) PropsClean; RefCount ref; diff --git a/OpenAL32/Include/alListener.h b/OpenAL32/Include/alListener.h index 0d80a8d7..9efadf47 100644 --- a/OpenAL32/Include/alListener.h +++ b/OpenAL32/Include/alListener.h @@ -36,7 +36,7 @@ typedef struct ALlistener { ALfloat Up[3]; ALfloat Gain; - ATOMIC_FLAG PropsClean; + ATOMIC(ALenum) PropsClean; /* Pointer to the most recent property values that are awaiting an update. */ diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index 8cb22615..666a8ade 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -808,7 +808,7 @@ struct ALCcontext_struct { ALfloat SpeedOfSound; ALfloat MetersPerUnit; - ATOMIC_FLAG PropsClean; + ATOMIC(ALenum) PropsClean; ATOMIC(ALenum) DeferUpdates; almtx_t PropLock; diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h index 5f07c09d..f7749de3 100644 --- a/OpenAL32/Include/alSource.h +++ b/OpenAL32/Include/alSource.h @@ -98,7 +98,7 @@ typedef struct ALsource { /** Source Buffer Queue head. */ ALbufferlistitem *queue; - ATOMIC_FLAG PropsClean; + ATOMIC(ALenum) PropsClean; /* Index into the context's Voices array. Lazily updated, only checked and * reset when looking up the voice. diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c index e1d84bb9..4758646f 100644 --- a/OpenAL32/alAuxEffectSlot.c +++ b/OpenAL32/alAuxEffectSlot.c @@ -103,7 +103,7 @@ static inline ALeffect *LookupEffect(ALCdevice *device, ALuint id) if(!ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) \ UpdateEffectSlotProps(slot, context); \ else \ - ATOMIC_FLAG_CLEAR(&slot->PropsClean, almemory_order_release); \ + ATOMIC_STORE(&slot->PropsClean, AL_FALSE, almemory_order_release); \ } while(0) @@ -679,7 +679,7 @@ ALenum InitEffectSlot(ALeffectslot *slot) slot->Gain = 1.0; slot->AuxSendAuto = AL_TRUE; - ATOMIC_FLAG_TEST_AND_SET(&slot->PropsClean, almemory_order_relaxed); + ATOMIC_INIT(&slot->PropsClean, AL_TRUE); InitRef(&slot->ref, 0); ATOMIC_INIT(&slot->Update, NULL); @@ -773,7 +773,7 @@ void UpdateAllEffectSlotProps(ALCcontext *context) for(i = 0;i < auxslots->count;i++) { ALeffectslot *slot = auxslots->slot[i]; - if(!ATOMIC_FLAG_TEST_AND_SET(&slot->PropsClean, almemory_order_acq_rel)) + if(!ATOMIC_EXCHANGE(&slot->PropsClean, AL_TRUE, almemory_order_acq_rel)) UpdateEffectSlotProps(slot, context); } UnlockEffectSlotList(context); diff --git a/OpenAL32/alListener.c b/OpenAL32/alListener.c index f1ac3ff4..700fa0af 100644 --- a/OpenAL32/alListener.c +++ b/OpenAL32/alListener.c @@ -30,7 +30,7 @@ if(!ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) \ UpdateListenerProps(context); \ else \ - ATOMIC_FLAG_CLEAR(&listener->PropsClean, almemory_order_release); \ + ATOMIC_STORE(&listener->PropsClean, AL_FALSE, almemory_order_release);\ } while(0) @@ -60,7 +60,7 @@ AL_API ALvoid AL_APIENTRY alListenerf(ALenum param, ALfloat value) if(!ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) UpdateContextProps(context); else - ATOMIC_FLAG_CLEAR(&context->PropsClean, almemory_order_release); + ATOMIC_STORE(&context->PropsClean, AL_FALSE, almemory_order_release); break; default: diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index 1f76a069..2eb69cb9 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -519,7 +519,7 @@ static ALint Int64ValsByProp(ALenum prop) (voice=GetSourceVoice(Source, Context)) != NULL) \ UpdateSourceProps(Source, voice, device->NumAuxSends, Context); \ else \ - ATOMIC_FLAG_CLEAR(&Source->PropsClean, almemory_order_release); \ + ATOMIC_STORE(&Source->PropsClean, AL_FALSE, almemory_order_release); \ } while(0) static ALboolean SetSourcefv(ALsource *Source, ALCcontext *Context, SourceProp prop, const ALfloat *values) @@ -1036,7 +1036,7 @@ static ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp p if((voice=GetSourceVoice(Source, Context)) != NULL) UpdateSourceProps(Source, voice, device->NumAuxSends, Context); else - ATOMIC_FLAG_CLEAR(&Source->PropsClean, almemory_order_release); + ATOMIC_STORE(&Source->PropsClean, AL_FALSE, almemory_order_release); } else { @@ -2488,7 +2488,7 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources) voice = context->Voices[vidx]; ATOMIC_STORE(&voice->Playing, false, almemory_order_release); - ATOMIC_FLAG_TEST_AND_SET(&source->PropsClean, almemory_order_acquire); + ATOMIC_EXCHANGE(&source->PropsClean, AL_TRUE, almemory_order_acquire); UpdateSourceProps(source, voice, device->NumAuxSends, context); /* A source that's not playing or paused has any offset applied when it @@ -3109,10 +3109,7 @@ static void InitSourceParams(ALsource *Source, ALsizei num_sends) Source->queue = NULL; - /* 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->PropsClean, AL_TRUE); Source->VoiceIdx = -1; } @@ -3246,7 +3243,7 @@ void UpdateAllSourceProps(ALCcontext *context) { ALvoice *voice = context->Voices[pos]; ALsource *source = ATOMIC_LOAD(&voice->Source, almemory_order_acquire); - if(source && !ATOMIC_FLAG_TEST_AND_SET(&source->PropsClean, almemory_order_acq_rel)) + if(source && !ATOMIC_EXCHANGE(&source->PropsClean, AL_TRUE, almemory_order_acq_rel)) UpdateSourceProps(source, voice, num_sends, context); } } diff --git a/OpenAL32/alState.c b/OpenAL32/alState.c index ce93e143..8be08435 100644 --- a/OpenAL32/alState.c +++ b/OpenAL32/alState.c @@ -68,7 +68,7 @@ AL_API const ALchar* AL_APIENTRY alsoft_get_version(void) if(!ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) \ UpdateContextProps(context); \ else \ - ATOMIC_FLAG_CLEAR(&context->PropsClean, almemory_order_release); \ + ATOMIC_STORE(&context->PropsClean, AL_FALSE, almemory_order_release); \ } while(0) -- cgit v1.2.3