aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/ALu.c
diff options
context:
space:
mode:
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);