aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/ALu.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-12-21 19:58:03 -0800
committerChris Robinson <[email protected]>2016-12-21 19:58:03 -0800
commit4c33818dde702128be13040f9fc8bd0a5b835c76 (patch)
tree27c77c6283e35ec0f4e42d3163174f41018dda00 /Alc/ALu.c
parent315bd556acdc4b8b67b073f64d472f243a96544d (diff)
Avoid duplicating code using a macro
Diffstat (limited to 'Alc/ALu.c')
-rw-r--r--Alc/ALu.c41
1 files changed, 3 insertions, 38 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index db032057..dc979522 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -239,7 +239,6 @@ static ALboolean CalcListenerParams(ALCcontext *Context)
{
ALlistener *Listener = Context->Listener;
ALfloat N[3], V[3], U[3], P[3];
- struct ALlistenerProps *first;
struct ALlistenerProps *props;
aluVector vel;
@@ -288,24 +287,12 @@ static ALboolean CalcListenerParams(ALCcontext *Context)
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,
- * but...).
- */
- first = ATOMIC_LOAD(&Listener->FreeList, almemory_order_acquire);
- do {
- ATOMIC_STORE(&props->next, first, almemory_order_relaxed);
- } while(ATOMIC_COMPARE_EXCHANGE_WEAK(struct ALlistenerProps*,
- &Listener->FreeList, &first, props, almemory_order_acq_rel,
- almemory_order_acquire) == 0);
-
+ ATOMIC_REPLACE_HEAD(struct ALlistenerProps*, &Listener->FreeList, props);
return AL_TRUE;
}
static ALboolean CalcEffectSlotParams(ALeffectslot *slot, ALCdevice *device)
{
- struct ALeffectslotProps *first;
struct ALeffectslotProps *props;
ALeffectState *state;
@@ -337,18 +324,7 @@ static ALboolean CalcEffectSlotParams(ALeffectslot *slot, ALCdevice *device)
V(state,update)(device, slot, &props->Props);
- /* 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,
- * but...).
- */
- first = ATOMIC_LOAD(&slot->FreeList, almemory_order_acquire);
- do {
- ATOMIC_STORE(&props->next, first, almemory_order_relaxed);
- } while(ATOMIC_COMPARE_EXCHANGE_WEAK(struct ALeffectslotProps*,
- &slot->FreeList, &first, props, almemory_order_acq_rel,
- almemory_order_acquire) == 0);
-
+ ATOMIC_REPLACE_HEAD(struct ALeffectslotProps*, &slot->FreeList, props);
return AL_TRUE;
}
@@ -1301,7 +1277,6 @@ static void CalcSourceParams(ALvoice *voice, ALCcontext *context, ALboolean forc
{
ALsource *source = voice->Source;
const ALbufferlistitem *BufferListItem;
- struct ALsourceProps *first;
struct ALsourceProps *props;
props = ATOMIC_EXCHANGE(struct ALsourceProps*, &source->Update, NULL, almemory_order_acq_rel);
@@ -1311,17 +1286,7 @@ static void CalcSourceParams(ALvoice *voice, ALCcontext *context, ALboolean forc
{
voice->Props = *props;
- /* 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, but...).
- */
- first = ATOMIC_LOAD(&source->FreeList, almemory_order_acquire);
- do {
- ATOMIC_STORE(&props->next, first, almemory_order_relaxed);
- } while(ATOMIC_COMPARE_EXCHANGE_WEAK(struct ALsourceProps*,
- &source->FreeList, &first, props, almemory_order_acq_rel,
- almemory_order_acquire) == 0);
+ ATOMIC_REPLACE_HEAD(struct ALsourceProps*, &source->FreeList, props);
}
BufferListItem = ATOMIC_LOAD(&source->queue, almemory_order_relaxed);