aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-03-20 21:25:39 -0700
committerChris Robinson <[email protected]>2017-03-20 21:25:39 -0700
commitcdfe0d8f5af871258f1f58493e9659148659cacb (patch)
tree61412add20d91a243c18d3c8e18213adfe18806e
parent42bcf0870d7f7358b4e1775d37e20e3b9162d249 (diff)
Use an atomic flag to test if a source needs to update
-rw-r--r--Alc/ALc.c2
-rw-r--r--OpenAL32/Include/alSource.h2
-rw-r--r--OpenAL32/alSource.c14
3 files changed, 9 insertions, 9 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index f275871e..f830a602 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -2254,7 +2254,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
}
}
- source->NeedsUpdate = AL_TRUE;
+ ATOMIC_FLAG_CLEAR(&source->PropsClean, almemory_order_release);
/* Clear any pre-existing source property structs, in case the
* number of auxiliary sends changed. Playing (or paused) sources
diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h
index 284d5cbe..5b1e2547 100644
--- a/OpenAL32/Include/alSource.h
+++ b/OpenAL32/Include/alSource.h
@@ -149,7 +149,7 @@ typedef struct ALsource {
ATOMIC(ALboolean) looping;
- ALenum NeedsUpdate;
+ ATOMIC_FLAG PropsClean;
ATOMIC(struct ALsourceProps*) Update;
ATOMIC(struct ALsourceProps*) FreeList;
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);
- }
}
}