Use an atomic bool on things that only take true or false

This commit is contained in:
Chris Robinson
2018-12-30 21:58:14 -08:00
parent 9f5c9a2260
commit 5e03941701
11 changed files with 36 additions and 36 deletions
+1 -1
View File
@@ -4258,7 +4258,7 @@ ALC_API ALCboolean ALC_APIENTRY alcResetDeviceSOFT(ALCdevice *device, const ALCi
if((dev->Flags&DEVICE_RUNNING))
dev->Backend->stop();
dev->Flags &= ~DEVICE_RUNNING;
device->Connected.store(AL_TRUE);
device->Connected.store(true);
ALCenum err{UpdateDeviceParams(dev.get(), attribs)};
if(LIKELY(err == ALC_NO_ERROR)) return ALC_TRUE;
+1 -1
View File
@@ -1817,7 +1817,7 @@ void aluMixData(ALCdevice *device, ALvoid *OutBuffer, ALsizei NumSamples)
void aluHandleDisconnect(ALCdevice *device, const char *msg, ...)
{
if(!device->Connected.exchange(AL_FALSE, std::memory_order_acq_rel))
if(!device->Connected.exchange(false, std::memory_order_acq_rel))
return;
AsyncEvent evt{EventType_Disconnected};
+3 -3
View File
@@ -441,7 +441,7 @@ struct AlsaPlayback final : public BackendBase {
al::vector<char> mBuffer;
std::atomic<ALenum> mKillNow{AL_TRUE};
std::atomic<bool> mKillNow{true};
std::thread mThread;
static constexpr inline const char *CurrentPrefix() noexcept { return "AlsaPlayback::"; }
@@ -856,7 +856,7 @@ ALCboolean AlsaPlayback::start()
}
try {
mKillNow.store(AL_FALSE, std::memory_order_release);
mKillNow.store(false, std::memory_order_release);
mThread = std::thread{std::mem_fn(thread_func), this};
return ALC_TRUE;
}
@@ -871,7 +871,7 @@ ALCboolean AlsaPlayback::start()
void AlsaPlayback::stop()
{
if(mKillNow.exchange(AL_TRUE, std::memory_order_acq_rel) || !mThread.joinable())
if(mKillNow.exchange(true, std::memory_order_acq_rel) || !mThread.joinable())
return;
mThread.join();
+3 -3
View File
@@ -202,7 +202,7 @@ struct DSoundPlayback final : public BackendBase {
IDirectSoundNotify *mNotifies{nullptr};
HANDLE mNotifyEvent{nullptr};
std::atomic<ALenum> mKillNow{AL_TRUE};
std::atomic<bool> mKillNow{true};
std::thread mThread;
static constexpr inline const char *CurrentPrefix() noexcept { return "DSoundPlayback::"; }
@@ -596,7 +596,7 @@ retry_open:
ALCboolean DSoundPlayback::start()
{
try {
mKillNow.store(AL_FALSE, std::memory_order_release);
mKillNow.store(false, std::memory_order_release);
mThread = std::thread{std::mem_fn(&DSoundPlayback::mixerProc), this};
return ALC_TRUE;
}
@@ -610,7 +610,7 @@ ALCboolean DSoundPlayback::start()
void DSoundPlayback::stop()
{
if(mKillNow.exchange(AL_TRUE, std::memory_order_acq_rel) || !mThread.joinable())
if(mKillNow.exchange(true, std::memory_order_acq_rel) || !mThread.joinable())
return;
mThread.join();
+3 -3
View File
@@ -55,7 +55,7 @@ struct NullBackend final : public BackendBase {
ALCboolean start() override;
void stop() override;
std::atomic<ALenum> mKillNow{AL_TRUE};
std::atomic<bool> mKillNow{true};
std::thread mThread;
static constexpr inline const char *CurrentPrefix() noexcept { return "NullBackend::"; }
@@ -129,7 +129,7 @@ ALCboolean NullBackend::reset()
ALCboolean NullBackend::start()
{
try {
mKillNow.store(AL_FALSE, std::memory_order_release);
mKillNow.store(false, std::memory_order_release);
mThread = std::thread{std::mem_fn(&NullBackend::mixerProc), this};
return ALC_TRUE;
}
@@ -143,7 +143,7 @@ ALCboolean NullBackend::start()
void NullBackend::stop()
{
if(mKillNow.exchange(AL_TRUE, std::memory_order_acq_rel) || !mThread.joinable())
if(mKillNow.exchange(true, std::memory_order_acq_rel) || !mThread.joinable())
return;
mThread.join();
}
+3 -3
View File
@@ -169,7 +169,7 @@ struct OpenSLPlayback final : public BackendBase {
ALsizei mFrameSize{0};
std::atomic<ALenum> mKillNow{AL_TRUE};
std::atomic<bool> mKillNow{true};
std::thread mThread;
static constexpr inline const char *CurrentPrefix() noexcept { return "OpenSLPlayback::"; }
@@ -550,7 +550,7 @@ ALCboolean OpenSLPlayback::start()
if(SL_RESULT_SUCCESS != result) return ALC_FALSE;
try {
mKillNow.store(AL_FALSE);
mKillNow.store(false, std::memory_order_release);
mThread = std::thread(std::mem_fn(&OpenSLPlayback::mixerProc), this);
return ALC_TRUE;
}
@@ -564,7 +564,7 @@ ALCboolean OpenSLPlayback::start()
void OpenSLPlayback::stop()
{
if(mKillNow.exchange(AL_TRUE) || !mThread.joinable())
if(mKillNow.exchange(true, std::memory_order_acq_rel) || !mThread.joinable())
return;
mSem.post();
+6 -6
View File
@@ -257,7 +257,7 @@ struct OSSPlayback final : public BackendBase {
al::vector<ALubyte> mMixData;
std::atomic<ALenum> mKillNow{AL_TRUE};
std::atomic<bool> mKillNow{true};
std::thread mThread;
static constexpr inline const char *CurrentPrefix() noexcept { return "OSSPlayback::"; }
@@ -448,7 +448,7 @@ ALCboolean OSSPlayback::reset()
ALCboolean OSSPlayback::start()
{
try {
mKillNow.store(AL_FALSE);
mKillNow.store(false, std::memory_order_release);
mThread = std::thread{std::mem_fn(&OSSPlayback::mixerProc), this};
return ALC_TRUE;
}
@@ -462,7 +462,7 @@ ALCboolean OSSPlayback::start()
void OSSPlayback::stop()
{
if(mKillNow.exchange(AL_TRUE) || !mThread.joinable())
if(mKillNow.exchange(true, std::memory_order_acq_rel) || !mThread.joinable())
return;
mThread.join();
@@ -487,7 +487,7 @@ struct OSScapture final : public BackendBase {
RingBufferPtr mRing{nullptr};
std::atomic<ALenum> mKillNow{AL_TRUE};
std::atomic<bool> mKillNow{true};
std::thread mThread;
static constexpr inline const char *CurrentPrefix() noexcept { return "OSScapture::"; }
@@ -661,7 +661,7 @@ ALCenum OSScapture::open(const ALCchar *name)
ALCboolean OSScapture::start()
{
try {
mKillNow.store(AL_FALSE);
mKillNow.store(false, std::memory_order_release);
mThread = std::thread{std::mem_fn(&OSScapture::recordProc), this};
return ALC_TRUE;
}
@@ -675,7 +675,7 @@ ALCboolean OSScapture::start()
void OSScapture::stop()
{
if(mKillNow.exchange(AL_TRUE) || !mThread.joinable())
if(mKillNow.exchange(true, std::memory_order_acq_rel) || !mThread.joinable())
return;
mThread.join();
+6 -6
View File
@@ -525,7 +525,7 @@ struct WasapiPlayback final : public BackendBase, WasapiProxy {
std::atomic<UINT32> mPadding{0u};
std::atomic<ALenum> mKillNow{AL_TRUE};
std::atomic<bool> mKillNow{true};
std::thread mThread;
static constexpr inline const char *CurrentPrefix() noexcept { return "WasapiPlayback::"; }
@@ -1070,7 +1070,7 @@ HRESULT WasapiPlayback::startProxy()
{
mRender = static_cast<IAudioRenderClient*>(ptr);
try {
mKillNow.store(AL_FALSE, std::memory_order_release);
mKillNow.store(false, std::memory_order_release);
mThread = std::thread{std::mem_fn(&WasapiPlayback::mixerProc), this};
}
catch(...) {
@@ -1101,7 +1101,7 @@ void WasapiPlayback::stopProxy()
if(!mRender || !mThread.joinable())
return;
mKillNow.store(AL_TRUE);
mKillNow.store(true, std::memory_order_release);
mThread.join();
mRender->Release();
@@ -1156,7 +1156,7 @@ struct WasapiCapture final : public BackendBase, WasapiProxy {
SampleConverterPtr mSampleConv;
RingBufferPtr mRing;
std::atomic<int> mKillNow{AL_TRUE};
std::atomic<bool> mKillNow{true};
std::thread mThread;
static constexpr inline const char *CurrentPrefix() noexcept { return "WasapiCapture::"; }
@@ -1671,7 +1671,7 @@ HRESULT WasapiCapture::startProxy()
{
mCapture = static_cast<IAudioCaptureClient*>(ptr);
try {
mKillNow.store(AL_FALSE, std::memory_order_release);
mKillNow.store(false, std::memory_order_release);
mThread = std::thread{std::mem_fn(&WasapiCapture::recordProc), this};
}
catch(...) {
@@ -1705,7 +1705,7 @@ void WasapiCapture::stopProxy()
if(!mCapture || !mThread.joinable())
return;
mKillNow.store(AL_TRUE);
mKillNow.store(true, std::memory_order_release);
mThread.join();
mCapture->Release();
+3 -3
View File
@@ -95,7 +95,7 @@ struct WaveBackend final : public BackendBase {
al::vector<ALbyte> mBuffer;
std::atomic<ALenum> mKillNow{AL_TRUE};
std::atomic<bool> mKillNow{true};
std::thread mThread;
static constexpr inline const char *CurrentPrefix() noexcept { return "WaveBackend::"; }
@@ -328,7 +328,7 @@ ALCboolean WaveBackend::reset()
ALCboolean WaveBackend::start()
{
try {
mKillNow.store(AL_FALSE, std::memory_order_release);
mKillNow.store(false, std::memory_order_release);
mThread = std::thread{std::mem_fn(&WaveBackend::mixerProc), this};
return ALC_TRUE;
}
@@ -342,7 +342,7 @@ ALCboolean WaveBackend::start()
void WaveBackend::stop()
{
if(mKillNow.exchange(AL_TRUE, std::memory_order_acq_rel) || !mThread.joinable())
if(mKillNow.exchange(true, std::memory_order_acq_rel) || !mThread.joinable())
return;
mThread.join();
+6 -6
View File
@@ -144,7 +144,7 @@ struct WinMMPlayback final : public BackendBase {
WAVEFORMATEX mFormat{};
std::atomic<ALenum> mKillNow{AL_TRUE};
std::atomic<bool> mKillNow{true};
std::thread mThread;
static constexpr inline const char *CurrentPrefix() noexcept { return "WinMMPlayback::"; }
@@ -336,7 +336,7 @@ ALCboolean WinMMPlayback::start()
);
mWritable.store(static_cast<ALuint>(mWaveBuffer.size()), std::memory_order_release);
mKillNow.store(AL_FALSE, std::memory_order_release);
mKillNow.store(false, std::memory_order_release);
mThread = std::thread{std::mem_fn(&WinMMPlayback::mixerProc), this};
return ALC_TRUE;
}
@@ -350,7 +350,7 @@ ALCboolean WinMMPlayback::start()
void WinMMPlayback::stop()
{
if(mKillNow.exchange(AL_TRUE, std::memory_order_acq_rel) || !mThread.joinable())
if(mKillNow.exchange(true, std::memory_order_acq_rel) || !mThread.joinable())
return;
mThread.join();
@@ -390,7 +390,7 @@ struct WinMMCapture final : public BackendBase {
WAVEFORMATEX mFormat{};
std::atomic<ALenum> mKillNow{AL_TRUE};
std::atomic<bool> mKillNow{true};
std::thread mThread;
static constexpr inline const char *CurrentPrefix() noexcept { return "WinMMCapture::"; }
@@ -554,7 +554,7 @@ ALCboolean WinMMCapture::start()
waveInAddBuffer(mInHdl, &mWaveBuffer[i], sizeof(WAVEHDR));
}
mKillNow.store(AL_FALSE, std::memory_order_release);
mKillNow.store(false, std::memory_order_release);
mThread = std::thread{std::mem_fn(&WinMMCapture::captureProc), this};
waveInStart(mInHdl);
@@ -572,7 +572,7 @@ void WinMMCapture::stop()
{
waveInStop(mInHdl);
mKillNow.store(AL_TRUE, std::memory_order_release);
mKillNow.store(true, std::memory_order_release);
if(mThread.joinable())
{
mSem.post();
+1 -1
View File
@@ -666,7 +666,7 @@ using POSTPROCESS = void(*)(ALCdevice *device, ALsizei SamplesToDo);
struct ALCdevice_struct {
RefCount ref{1u};
std::atomic<ALenum> Connected{AL_TRUE};
std::atomic<bool> Connected{true};
const DeviceType Type{};
ALuint Frequency{};