aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-11-19 03:21:58 -0800
committerChris Robinson <[email protected]>2018-11-19 03:21:58 -0800
commite24435ef58b2f28555e6397f502f41f36524dac9 (patch)
tree5b828032fff7d64a2d613a40e7dac09cc5c05840 /Alc
parentc5142530d675885415c9168869eb6c125ce10876 (diff)
Remove the atomic exchange macros
Diffstat (limited to 'Alc')
-rw-r--r--Alc/alc.cpp29
-rw-r--r--Alc/alu.cpp23
-rw-r--r--Alc/backends/jack.cpp2
-rw-r--r--Alc/backends/null.cpp3
-rw-r--r--Alc/backends/opensl.cpp2
-rw-r--r--Alc/backends/qsa.cpp2
-rw-r--r--Alc/backends/sndio.cpp4
-rw-r--r--Alc/backends/solaris.cpp2
-rw-r--r--Alc/backends/wave.cpp3
9 files changed, 30 insertions, 40 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp
index 6bb632f7..879dba00 100644
--- a/Alc/alc.cpp
+++ b/Alc/alc.cpp
@@ -1614,7 +1614,7 @@ void ALCcontext_DeferUpdates(ALCcontext *context)
void ALCcontext_ProcessUpdates(ALCcontext *context)
{
almtx_lock(&context->PropLock);
- if(ATOMIC_EXCHANGE_SEQ(&context->DeferUpdates, AL_FALSE))
+ if(context->DeferUpdates.exchange(AL_FALSE))
{
/* Tell the mixer to stop applying updates, then wait for any active
* updating to finish, before providing updates.
@@ -1623,9 +1623,9 @@ void ALCcontext_ProcessUpdates(ALCcontext *context)
while((ATOMIC_LOAD(&context->UpdateCount, almemory_order_acquire)&1) != 0)
althrd_yield();
- if(!ATOMIC_EXCHANGE(&context->PropsClean, AL_TRUE, almemory_order_acq_rel))
+ if(!context->PropsClean.exchange(AL_TRUE, std::memory_order_acq_rel))
UpdateContextProps(context);
- if(!ATOMIC_EXCHANGE(&context->Listener.PropsClean, AL_TRUE, almemory_order_acq_rel))
+ if(!context->Listener.PropsClean.exchange(AL_TRUE, std::memory_order_acq_rel))
UpdateListenerProps(context);
UpdateAllEffectSlotProps(context);
UpdateAllSourceProps(context);
@@ -2330,11 +2330,10 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
* auxiliary sends is changing. Active sources will have updates
* respecified in UpdateAllSourceProps.
*/
- vprops = ATOMIC_EXCHANGE(&context->FreeVoiceProps, static_cast<ALvoiceProps*>(nullptr),
- almemory_order_acq_rel);
+ vprops = context->FreeVoiceProps.exchange(nullptr, std::memory_order_acq_rel);
while(vprops)
{
- struct ALvoiceProps *next = ATOMIC_LOAD(&vprops->next, almemory_order_relaxed);
+ struct ALvoiceProps *next = vprops->next.load(std::memory_order_relaxed);
al_free(vprops);
vprops = next;
}
@@ -2344,10 +2343,9 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
{
ALvoice *voice = context->Voices[pos];
- al_free(ATOMIC_EXCHANGE(&voice->Update, static_cast<ALvoiceProps*>(nullptr),
- almemory_order_acq_rel));
+ al_free(voice->Update.exchange(nullptr, std::memory_order_acq_rel));
- if(ATOMIC_LOAD(&voice->Source, almemory_order_acquire) == nullptr)
+ if(voice->Source.load(std::memory_order_acquire) == nullptr)
continue;
if(device->AvgSpeakerDist > 0.0f)
@@ -2698,7 +2696,7 @@ static bool ReleaseContext(ALCcontext *context, ALCdevice *device)
V0(device->Backend,lock)();
origctx = context;
newhead = ATOMIC_LOAD(&context->next, almemory_order_relaxed);
- if(!ATOMIC_COMPARE_EXCHANGE_STRONG_SEQ(&device->ContextList, &origctx, newhead))
+ if(!device->ContextList.compare_exchange_strong(origctx, newhead))
{
ALCcontext *list;
do {
@@ -2707,7 +2705,7 @@ static bool ReleaseContext(ALCcontext *context, ALCdevice *device)
*/
list = origctx;
origctx = context;
- } while(!ATOMIC_COMPARE_EXCHANGE_STRONG_SEQ(&list->next, &origctx, newhead));
+ } while(!list->next.compare_exchange_strong(origctx, newhead));
}
else
ret = !!newhead;
@@ -2893,7 +2891,7 @@ ALC_API ALCenum ALC_APIENTRY alcGetError(ALCdevice *device)
if(VerifyDevice(&device))
{
- errorCode = ATOMIC_EXCHANGE_SEQ(&device->LastError, ALC_NO_ERROR);
+ errorCode = device->LastError.exchange(ALC_NO_ERROR);
ALCdevice_DecRef(device);
}
else
@@ -3720,8 +3718,7 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin
ALCcontext *head = ATOMIC_LOAD_SEQ(&device->ContextList);
do {
ATOMIC_STORE(&ALContext->next, head, almemory_order_relaxed);
- } while(ATOMIC_COMPARE_EXCHANGE_WEAK_SEQ(&device->ContextList, &head,
- ALContext) == 0);
+ } while(!device->ContextList.compare_exchange_weak(head, ALContext));
}
almtx_unlock(&device->BackendLock);
@@ -4068,7 +4065,7 @@ ALC_API ALCboolean ALC_APIENTRY alcCloseDevice(ALCdevice *device)
do {
list = origdev;
origdev = device;
- } while(!ATOMIC_COMPARE_EXCHANGE_STRONG_SEQ(&list->next, &origdev, nextdev));
+ } while(!list->next.compare_exchange_strong(origdev, nextdev));
}
listlock.unlock();
@@ -4188,7 +4185,7 @@ ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice(ALCdevice *device)
do {
list = origdev;
origdev = device;
- } while(!ATOMIC_COMPARE_EXCHANGE_STRONG_SEQ(&list->next, &origdev, nextdev));
+ } while(!list->next.compare_exchange_strong(origdev, nextdev));
}
listlock.unlock();
diff --git a/Alc/alu.cpp b/Alc/alu.cpp
index e26f5f57..f9a53139 100644
--- a/Alc/alu.cpp
+++ b/Alc/alu.cpp
@@ -75,7 +75,7 @@ static HrtfDirectMixerFunc MixDirectHrtf = MixDirectHrtf_C;
void DeinitVoice(ALvoice *voice)
{
- al_free(ATOMIC_EXCHANGE_SEQ(&voice->Update, static_cast<ALvoiceProps*>(nullptr)));
+ al_free(voice->Update.exchange(nullptr));
}
@@ -315,8 +315,7 @@ static bool CalcContextParams(ALCcontext *Context)
ALlistener &Listener = Context->Listener;
struct ALcontextProps *props;
- props = ATOMIC_EXCHANGE(&Context->Update, static_cast<ALcontextProps*>(nullptr),
- almemory_order_acq_rel);
+ props = Context->Update.exchange(nullptr, std::memory_order_acq_rel);
if(!props) return false;
Listener.Params.MetersPerUnit = props->MetersPerUnit;
@@ -341,8 +340,7 @@ static bool CalcListenerParams(ALCcontext *Context)
struct ALlistenerProps *props;
aluVector vel;
- props = ATOMIC_EXCHANGE(&Listener.Update, static_cast<ALlistenerProps*>(nullptr),
- almemory_order_acq_rel);
+ props = Listener.Update.exchange(nullptr, std::memory_order_acq_rel);
if(!props) return false;
/* AT then UP */
@@ -385,8 +383,7 @@ static bool CalcEffectSlotParams(ALeffectslot *slot, ALCcontext *context, bool f
struct ALeffectslotProps *props;
ALeffectState *state;
- props = ATOMIC_EXCHANGE(&slot->Update, static_cast<ALeffectslotProps*>(nullptr),
- almemory_order_acq_rel);
+ props = slot->Update.exchange(nullptr, std::memory_order_acq_rel);
if(!props && !force) return false;
if(props)
@@ -1455,8 +1452,7 @@ static void CalcSourceParams(ALvoice *voice, ALCcontext *context, bool force)
ALbufferlistitem *BufferListItem;
struct ALvoiceProps *props;
- props = ATOMIC_EXCHANGE(&voice->Update, static_cast<ALvoiceProps*>(nullptr),
- almemory_order_acq_rel);
+ props = voice->Update.exchange(nullptr, std::memory_order_acq_rel);
if(!props && !force) return;
if(props)
@@ -1830,7 +1826,7 @@ void aluHandleDisconnect(ALCdevice *device, const char *msg, ...)
va_list args;
int msglen;
- if(!ATOMIC_EXCHANGE(&device->Connected, AL_FALSE, almemory_order_acq_rel))
+ if(!device->Connected.exchange(AL_FALSE, std::memory_order_acq_rel))
return;
evt.u.user.type = AL_EVENT_TYPE_DISCONNECTED_SOFT;
@@ -1857,9 +1853,8 @@ void aluHandleDisconnect(ALCdevice *device, const char *msg, ...)
for(i = 0;i < ctx->VoiceCount;i++)
{
ALvoice *voice = ctx->Voices[i];
- ALsource *source = ATOMIC_EXCHANGE(&voice->Source, static_cast<ALsource*>(nullptr),
- almemory_order_relaxed);
- if(source && ATOMIC_LOAD(&voice->Playing, almemory_order_relaxed))
+ ALsource *source = voice->Source.exchange(nullptr, std::memory_order_relaxed);
+ if(source && voice->Playing.load(std::memory_order_relaxed))
{
/* If the source's voice was playing, it's now effectively
* stopped (the source state will be updated the next time it's
@@ -1867,7 +1862,7 @@ void aluHandleDisconnect(ALCdevice *device, const char *msg, ...)
*/
SendSourceStoppedEvent(ctx, source->id);
}
- ATOMIC_STORE(&voice->Playing, false, almemory_order_release);
+ voice->Playing.store(false, std::memory_order_release);
}
ctx = ATOMIC_LOAD(&ctx->next, almemory_order_relaxed);
diff --git a/Alc/backends/jack.cpp b/Alc/backends/jack.cpp
index c72958e7..924e1926 100644
--- a/Alc/backends/jack.cpp
+++ b/Alc/backends/jack.cpp
@@ -488,7 +488,7 @@ static void ALCjackPlayback_stop(ALCjackPlayback *self)
{
int res;
- if(ATOMIC_EXCHANGE(&self->killNow, AL_TRUE, almemory_order_acq_rel))
+ if(self->killNow.exchange(AL_TRUE, std::memory_order_acq_rel))
return;
alsem_post(&self->Sem);
diff --git a/Alc/backends/null.cpp b/Alc/backends/null.cpp
index 255aa01f..47ebd0ae 100644
--- a/Alc/backends/null.cpp
+++ b/Alc/backends/null.cpp
@@ -168,8 +168,7 @@ ALCboolean ALCnullBackend_start(ALCnullBackend *self)
void ALCnullBackend_stop(ALCnullBackend *self)
{
- if(ATOMIC_EXCHANGE(&self->killNow, AL_TRUE, almemory_order_acq_rel) ||
- !self->thread.joinable())
+ if(self->killNow.exchange(AL_TRUE, std::memory_order_acq_rel) || !self->thread.joinable())
return;
self->thread.join();
}
diff --git a/Alc/backends/opensl.cpp b/Alc/backends/opensl.cpp
index d0b1a7b1..0eb194e0 100644
--- a/Alc/backends/opensl.cpp
+++ b/Alc/backends/opensl.cpp
@@ -610,7 +610,7 @@ static void ALCopenslPlayback_stop(ALCopenslPlayback *self)
SLresult result;
int res;
- if(ATOMIC_EXCHANGE_SEQ(&self->mKillNow, AL_TRUE))
+ if(self->mKillNow.exchange(AL_TRUE))
return;
alsem_post(&self->mSem);
diff --git a/Alc/backends/qsa.cpp b/Alc/backends/qsa.cpp
index 9803d77d..09082357 100644
--- a/Alc/backends/qsa.cpp
+++ b/Alc/backends/qsa.cpp
@@ -614,7 +614,7 @@ static void qsa_stop_playback(PlaybackWrapper *self)
qsa_data *data = self->ExtraData;
int res;
- if(ATOMIC_EXCHANGE(&data->killNow, AL_TRUE, almemory_order_acq_rel))
+ if(data->killNow.exchange(AL_TRUE, std::memory_order_acq_rel))
return;
althrd_join(data->thread, &res);
}
diff --git a/Alc/backends/sndio.cpp b/Alc/backends/sndio.cpp
index 958bc2ff..cc5eacbe 100644
--- a/Alc/backends/sndio.cpp
+++ b/Alc/backends/sndio.cpp
@@ -267,7 +267,7 @@ static void SndioPlayback_stop(SndioPlayback *self)
{
int res;
- if(ATOMIC_EXCHANGE(&self->killNow, AL_TRUE, almemory_order_acq_rel))
+ if(self->killNow.exchange(AL_TRUE, std::memory_order_acq_rel))
return;
althrd_join(self->thread, &res);
@@ -513,7 +513,7 @@ static void SndioCapture_stop(SndioCapture *self)
{
int res;
- if(ATOMIC_EXCHANGE(&self->killNow, AL_TRUE, almemory_order_acq_rel))
+ if(self->killNow.exchange(AL_TRUE, std::memory_order_acq_rel))
return;
althrd_join(self->thread, &res);
diff --git a/Alc/backends/solaris.cpp b/Alc/backends/solaris.cpp
index 86120491..c757e5e1 100644
--- a/Alc/backends/solaris.cpp
+++ b/Alc/backends/solaris.cpp
@@ -282,7 +282,7 @@ static void ALCsolarisBackend_stop(ALCsolarisBackend *self)
{
int res;
- if(ATOMIC_EXCHANGE_SEQ(&self->killNow, AL_TRUE))
+ if(self->killNow.exchange(AL_TRUE))
return;
althrd_join(self->thread, &res);
diff --git a/Alc/backends/wave.cpp b/Alc/backends/wave.cpp
index 3f8d8c97..83af40a8 100644
--- a/Alc/backends/wave.cpp
+++ b/Alc/backends/wave.cpp
@@ -367,8 +367,7 @@ ALCboolean ALCwaveBackend_start(ALCwaveBackend *self)
void ALCwaveBackend_stop(ALCwaveBackend *self)
{
- if(ATOMIC_EXCHANGE(&self->killNow, AL_TRUE, almemory_order_acq_rel) ||
- !self->thread.joinable())
+ if(self->killNow.exchange(AL_TRUE, std::memory_order_acq_rel) || !self->thread.joinable())
return;
self->thread.join();