diff options
author | Chris Robinson <[email protected]> | 2018-11-26 14:31:54 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-11-26 14:31:54 -0800 |
commit | a6923790fac739f0b98db6c06bc93543b9707556 (patch) | |
tree | e30677dd529ba0a2fecb6cbd6232f862acdc27dd /Alc/backends | |
parent | 5b2b96b24598636e35f1fe7ecf868b09571065d6 (diff) |
Avoid using ATOMIC_INIT
Diffstat (limited to 'Alc/backends')
-rw-r--r-- | Alc/backends/jack.cpp | 15 | ||||
-rw-r--r-- | Alc/backends/null.cpp | 4 | ||||
-rw-r--r-- | Alc/backends/opensl.cpp | 44 | ||||
-rw-r--r-- | Alc/backends/qsa.cpp | 2 | ||||
-rw-r--r-- | Alc/backends/sndio.cpp | 22 | ||||
-rw-r--r-- | Alc/backends/solaris.cpp | 12 | ||||
-rw-r--r-- | Alc/backends/wave.cpp | 11 |
7 files changed, 32 insertions, 78 deletions
diff --git a/Alc/backends/jack.cpp b/Alc/backends/jack.cpp index cd02388d..d0687939 100644 --- a/Alc/backends/jack.cpp +++ b/Alc/backends/jack.cpp @@ -145,13 +145,13 @@ static ALCboolean jack_load(void) struct ALCjackPlayback final : public ALCbackend { - jack_client_t *Client; - jack_port_t *Port[MAX_OUTPUT_CHANNELS]; + jack_client_t *Client{nullptr}; + jack_port_t *Port[MAX_OUTPUT_CHANNELS]{}; - ll_ringbuffer_t *Ring; + ll_ringbuffer_t *Ring{nullptr}; alsem_t Sem; - ATOMIC(ALenum) killNow; + ATOMIC(ALenum) killNow{AL_TRUE}; althrd_t thread; }; @@ -183,13 +183,6 @@ static void ALCjackPlayback_Construct(ALCjackPlayback *self, ALCdevice *device) SET_VTABLE2(ALCjackPlayback, ALCbackend, self); alsem_init(&self->Sem, 0); - - self->Client = NULL; - for(ALsizei i{0};i < MAX_OUTPUT_CHANNELS;i++) - self->Port[i] = NULL; - self->Ring = NULL; - - ATOMIC_INIT(&self->killNow, AL_TRUE); } static void ALCjackPlayback_Destruct(ALCjackPlayback *self) diff --git a/Alc/backends/null.cpp b/Alc/backends/null.cpp index 47ebd0ae..7c7f5e5e 100644 --- a/Alc/backends/null.cpp +++ b/Alc/backends/null.cpp @@ -45,7 +45,7 @@ constexpr ALCchar nullDevice[] = "No Output"; struct ALCnullBackend final : public ALCbackend { - ATOMIC(int) killNow; + ATOMIC(int) killNow{AL_TRUE}; std::thread thread; }; @@ -72,8 +72,6 @@ void ALCnullBackend_Construct(ALCnullBackend *self, ALCdevice *device) new (self) ALCnullBackend{}; ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device); SET_VTABLE2(ALCnullBackend, ALCbackend, self); - - ATOMIC_INIT(&self->killNow, AL_TRUE); } void ALCnullBackend_Destruct(ALCnullBackend *self) diff --git a/Alc/backends/opensl.cpp b/Alc/backends/opensl.cpp index f7ad1595..5b80ea65 100644 --- a/Alc/backends/opensl.cpp +++ b/Alc/backends/opensl.cpp @@ -134,21 +134,21 @@ static const char *res_str(SLresult result) struct ALCopenslPlayback final : public ALCbackend { /* engine interfaces */ - SLObjectItf mEngineObj; - SLEngineItf mEngine; + SLObjectItf mEngineObj{nullptr}; + SLEngineItf mEngine{nullptr}; /* output mix interfaces */ - SLObjectItf mOutputMix; + SLObjectItf mOutputMix{nullptr}; /* buffer queue player interfaces */ - SLObjectItf mBufferQueueObj; + SLObjectItf mBufferQueueObj{nullptr}; - ll_ringbuffer_t *mRing; + ll_ringbuffer_t *mRing{nullptr}; alsem_t mSem; - ALsizei mFrameSize; + ALsizei mFrameSize{0}; - ATOMIC(ALenum) mKillNow; + ATOMIC(ALenum) mKillNow{AL_TRUE}; althrd_t mThread; }; @@ -177,17 +177,7 @@ static void ALCopenslPlayback_Construct(ALCopenslPlayback *self, ALCdevice *devi ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device); SET_VTABLE2(ALCopenslPlayback, ALCbackend, self); - self->mEngineObj = NULL; - self->mEngine = NULL; - self->mOutputMix = NULL; - self->mBufferQueueObj = NULL; - - self->mRing = NULL; alsem_init(&self->mSem, 0); - - self->mFrameSize = 0; - - ATOMIC_INIT(&self->mKillNow, AL_FALSE); } static void ALCopenslPlayback_Destruct(ALCopenslPlayback* self) @@ -664,16 +654,16 @@ static ClockLatency ALCopenslPlayback_getClockLatency(ALCopenslPlayback *self) struct ALCopenslCapture final : public ALCbackend { /* engine interfaces */ - SLObjectItf mEngineObj; + SLObjectItf mEngineObj{nullptr}; SLEngineItf mEngine; /* recording interfaces */ - SLObjectItf mRecordObj; + SLObjectItf mRecordObj{nullptr}; - ll_ringbuffer_t *mRing; - ALCuint mSplOffset; + ll_ringbuffer_t *mRing{nullptr}; + ALCuint mSplOffset{0u}; - ALsizei mFrameSize; + ALsizei mFrameSize{0}; }; static void ALCopenslCapture_process(SLAndroidSimpleBufferQueueItf bq, void *context); @@ -698,16 +688,6 @@ static void ALCopenslCapture_Construct(ALCopenslCapture *self, ALCdevice *device new (self) ALCopenslCapture{}; ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device); SET_VTABLE2(ALCopenslCapture, ALCbackend, self); - - self->mEngineObj = NULL; - self->mEngine = NULL; - - self->mRecordObj = NULL; - - self->mRing = NULL; - self->mSplOffset = 0; - - self->mFrameSize = 0; } static void ALCopenslCapture_Destruct(ALCopenslCapture *self) diff --git a/Alc/backends/qsa.cpp b/Alc/backends/qsa.cpp index 09082357..a6d1e0ea 100644 --- a/Alc/backends/qsa.cpp +++ b/Alc/backends/qsa.cpp @@ -289,7 +289,7 @@ static ALCenum qsa_open_playback(PlaybackWrapper *self, const ALCchar* deviceNam data = (qsa_data*)calloc(1, sizeof(qsa_data)); if(data == NULL) return ALC_OUT_OF_MEMORY; - ATOMIC_INIT(&data->killNow, AL_TRUE); + data->killNow.store(AL_TRUE, std::memory_order_relaxed); if(!deviceName) deviceName = qsaDevice; diff --git a/Alc/backends/sndio.cpp b/Alc/backends/sndio.cpp index 2a20fb61..de5f74e4 100644 --- a/Alc/backends/sndio.cpp +++ b/Alc/backends/sndio.cpp @@ -38,12 +38,12 @@ static const ALCchar sndio_device[] = "SndIO Default"; struct SndioPlayback final : public ALCbackend { - struct sio_hdl *sndHandle; + struct sio_hdl *sndHandle{nullptr}; - ALvoid *mix_data; - ALsizei data_size; + ALvoid *mix_data{nullptr}; + ALsizei data_size{0}; - ATOMIC(int) killNow; + ATOMIC(int) killNow{AL_TRUE}; althrd_t thread; }; @@ -70,10 +70,6 @@ static void SndioPlayback_Construct(SndioPlayback *self, ALCdevice *device) new (self) SndioPlayback{}; ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device); SET_VTABLE2(SndioPlayback, ALCbackend, self); - - self->sndHandle = nullptr; - self->mix_data = nullptr; - ATOMIC_INIT(&self->killNow, AL_TRUE); } static void SndioPlayback_Destruct(SndioPlayback *self) @@ -280,11 +276,11 @@ static void SndioPlayback_stop(SndioPlayback *self) struct SndioCapture final : public ALCbackend { - struct sio_hdl *sndHandle; + struct sio_hdl *sndHandle{nullptr}; - ll_ringbuffer_t *ring; + ll_ringbuffer_t *ring{nullptr}; - ATOMIC(int) killNow; + ATOMIC(int) killNow{AL_TRUE}; althrd_t thread; }; @@ -311,10 +307,6 @@ static void SndioCapture_Construct(SndioCapture *self, ALCdevice *device) new (self) SndioCapture{}; ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device); SET_VTABLE2(SndioCapture, ALCbackend, self); - - self->sndHandle = nullptr; - self->ring = nullptr; - ATOMIC_INIT(&self->killNow, AL_TRUE); } static void SndioCapture_Destruct(SndioCapture *self) diff --git a/Alc/backends/solaris.cpp b/Alc/backends/solaris.cpp index c757e5e1..93de4384 100644 --- a/Alc/backends/solaris.cpp +++ b/Alc/backends/solaris.cpp @@ -44,12 +44,12 @@ struct ALCsolarisBackend final : public ALCbackend { - int fd; + int fd{-1}; - ALubyte *mix_data; - int data_size; + ALubyte *mix_data{nullptr}; + int data_size{0}; - ATOMIC(ALenum) killNow; + ATOMIC(ALenum) killNow{AL_TRUE}; althrd_t thread; }; @@ -81,10 +81,6 @@ static void ALCsolarisBackend_Construct(ALCsolarisBackend *self, ALCdevice *devi new (self) ALCsolarisBackend{}; ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device); SET_VTABLE2(ALCsolarisBackend, ALCbackend, self); - - self->fd = -1; - self->mix_data = nullptr; - ATOMIC_INIT(&self->killNow, AL_FALSE); } static void ALCsolarisBackend_Destruct(ALCsolarisBackend *self) diff --git a/Alc/backends/wave.cpp b/Alc/backends/wave.cpp index d9219336..bb37d979 100644 --- a/Alc/backends/wave.cpp +++ b/Alc/backends/wave.cpp @@ -79,12 +79,12 @@ void fwrite32le(ALuint val, FILE *f) struct ALCwaveBackend final : public ALCbackend { - FILE *mFile; - long mDataStart; + FILE *mFile{nullptr}; + long mDataStart{-1}; al::vector<ALbyte> mBuffer; - ATOMIC(ALenum) killNow; + ATOMIC(ALenum) killNow{AL_TRUE}; std::thread thread; }; @@ -111,11 +111,6 @@ void ALCwaveBackend_Construct(ALCwaveBackend *self, ALCdevice *device) new (self) ALCwaveBackend{}; ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device); SET_VTABLE2(ALCwaveBackend, ALCbackend, self); - - self->mFile = nullptr; - self->mDataStart = -1; - - ATOMIC_INIT(&self->killNow, AL_TRUE); } void ALCwaveBackend_Destruct(ALCwaveBackend *self) |