diff options
-rw-r--r-- | Alc/backends/jack.cpp | 12 | ||||
-rw-r--r-- | Alc/backends/opensl.cpp | 12 | ||||
-rw-r--r-- | Alc/backends/winmm.cpp | 22 |
3 files changed, 16 insertions, 30 deletions
diff --git a/Alc/backends/jack.cpp b/Alc/backends/jack.cpp index 0862f685..0679dd73 100644 --- a/Alc/backends/jack.cpp +++ b/Alc/backends/jack.cpp @@ -151,7 +151,7 @@ struct ALCjackPlayback final : public ALCbackend { jack_port_t *Port[MAX_OUTPUT_CHANNELS]{}; ll_ringbuffer_t *Ring{nullptr}; - alsem_t Sem; + al::semaphore Sem; std::atomic<ALenum> mKillNow{AL_TRUE}; std::thread mThread; @@ -183,8 +183,6 @@ static void ALCjackPlayback_Construct(ALCjackPlayback *self, ALCdevice *device) new (self) ALCjackPlayback{}; ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device); SET_VTABLE2(ALCjackPlayback, ALCbackend, self); - - alsem_init(&self->Sem, 0); } static void ALCjackPlayback_Destruct(ALCjackPlayback *self) @@ -201,8 +199,6 @@ static void ALCjackPlayback_Destruct(ALCjackPlayback *self) self->Client = NULL; } - alsem_destroy(&self->Sem); - ALCbackend_Destruct(STATIC_CAST(ALCbackend, self)); self->~ALCjackPlayback(); } @@ -278,7 +274,7 @@ static int ALCjackPlayback_process(jack_nframes_t numframes, void *arg) } ll_ringbuffer_read_advance(self->Ring, total); - alsem_post(&self->Sem); + self->Sem.post(); if(numframes > total) { @@ -309,7 +305,7 @@ static int ALCjackPlayback_mixerProc(ALCjackPlayback *self) if(ll_ringbuffer_write_space(self->Ring) < device->UpdateSize) { ALCjackPlayback_unlock(self); - alsem_wait(&self->Sem); + self->Sem.wait(); ALCjackPlayback_lock(self); continue; } @@ -485,7 +481,7 @@ static void ALCjackPlayback_stop(ALCjackPlayback *self) if(self->mKillNow.exchange(AL_TRUE, std::memory_order_acq_rel) || !self->mThread.joinable()) return; - alsem_post(&self->Sem); + self->Sem.post(); self->mThread.join(); jack_deactivate(self->Client); diff --git a/Alc/backends/opensl.cpp b/Alc/backends/opensl.cpp index e8d4a862..c2acda3a 100644 --- a/Alc/backends/opensl.cpp +++ b/Alc/backends/opensl.cpp @@ -146,7 +146,7 @@ struct ALCopenslPlayback final : public ALCbackend { SLObjectItf mBufferQueueObj{nullptr}; ll_ringbuffer_t *mRing{nullptr}; - alsem_t mSem; + al::semaphore mSem; ALsizei mFrameSize{0}; @@ -178,8 +178,6 @@ static void ALCopenslPlayback_Construct(ALCopenslPlayback *self, ALCdevice *devi new (self) ALCopenslPlayback{}; ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device); SET_VTABLE2(ALCopenslPlayback, ALCbackend, self); - - alsem_init(&self->mSem, 0); } static void ALCopenslPlayback_Destruct(ALCopenslPlayback* self) @@ -200,8 +198,6 @@ static void ALCopenslPlayback_Destruct(ALCopenslPlayback* self) ll_ringbuffer_free(self->mRing); self->mRing = NULL; - alsem_destroy(&self->mSem); - ALCbackend_Destruct(STATIC_CAST(ALCbackend, self)); self->~ALCopenslPlayback(); } @@ -222,7 +218,7 @@ static void ALCopenslPlayback_process(SLAndroidSimpleBufferQueueItf UNUSED(bq), */ ll_ringbuffer_read_advance(self->mRing, 1); - alsem_post(&self->mSem); + self->mSem.post(); } @@ -274,7 +270,7 @@ static int ALCopenslPlayback_mixerProc(ALCopenslPlayback *self) if(ll_ringbuffer_write_space(self->mRing) == 0) { ALCopenslPlayback_unlock(self); - alsem_wait(&self->mSem); + self->mSem.wait(); ALCopenslPlayback_lock(self); continue; } @@ -604,7 +600,7 @@ static void ALCopenslPlayback_stop(ALCopenslPlayback *self) if(self->mKillNow.exchange(AL_TRUE) || !self->mThread.joinable()) return; - alsem_post(&self->mSem); + self->mSem.post(); self->mThread.join(); result = VCALL(self->mBufferQueueObj,GetInterface)(SL_IID_PLAY, &player); diff --git a/Alc/backends/winmm.cpp b/Alc/backends/winmm.cpp index 2524ecc1..c88a43b6 100644 --- a/Alc/backends/winmm.cpp +++ b/Alc/backends/winmm.cpp @@ -122,7 +122,7 @@ void ProbeCaptureDevices(void) struct ALCwinmmPlayback final : public ALCbackend { std::atomic<ALuint> Writable{0u}; - alsem_t Sem; + al::semaphore Sem; int Idx{0}; std::array<WAVEHDR,4> WaveBuffer; @@ -160,7 +160,6 @@ void ALCwinmmPlayback_Construct(ALCwinmmPlayback *self, ALCdevice *device) ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device); SET_VTABLE2(ALCwinmmPlayback, ALCbackend, self); - alsem_init(&self->Sem, 0); std::fill(self->WaveBuffer.begin(), self->WaveBuffer.end(), WAVEHDR{}); } @@ -173,8 +172,6 @@ void ALCwinmmPlayback_Destruct(ALCwinmmPlayback *self) al_free(self->WaveBuffer[0].lpData); std::fill(self->WaveBuffer.begin(), self->WaveBuffer.end(), WAVEHDR{}); - alsem_destroy(&self->Sem); - ALCbackend_Destruct(STATIC_CAST(ALCbackend, self)); self->~ALCwinmmPlayback(); } @@ -194,7 +191,7 @@ void CALLBACK ALCwinmmPlayback_waveOutProc(HWAVEOUT UNUSED(device), UINT msg, auto self = reinterpret_cast<ALCwinmmPlayback*>(instance); self->Writable.fetch_add(1, std::memory_order_acq_rel); - alsem_post(&self->Sem); + self->Sem.post(); } FORCE_ALIGN int ALCwinmmPlayback_mixerProc(ALCwinmmPlayback *self) @@ -212,7 +209,7 @@ FORCE_ALIGN int ALCwinmmPlayback_mixerProc(ALCwinmmPlayback *self) if(todo < 1) { ALCwinmmPlayback_unlock(self); - alsem_wait(&self->Sem); + self->Sem.wait(); ALCwinmmPlayback_lock(self); continue; } @@ -387,7 +384,7 @@ void ALCwinmmPlayback_stop(ALCwinmmPlayback *self) self->mThread.join(); while(self->Writable.load(std::memory_order_acquire) < self->WaveBuffer.size()) - alsem_wait(&self->Sem); + self->Sem.wait(); std::for_each(self->WaveBuffer.begin(), self->WaveBuffer.end(), [self](WAVEHDR &waveHdr) -> void { waveOutUnprepareHeader(self->OutHdl, &waveHdr, sizeof(WAVEHDR)); } @@ -398,7 +395,7 @@ void ALCwinmmPlayback_stop(ALCwinmmPlayback *self) struct ALCwinmmCapture final : public ALCbackend { std::atomic<ALuint> Readable{0u}; - alsem_t Sem; + al::semaphore Sem; int Idx{0}; std::array<WAVEHDR,4> WaveBuffer; @@ -438,7 +435,6 @@ void ALCwinmmCapture_Construct(ALCwinmmCapture *self, ALCdevice *device) ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device); SET_VTABLE2(ALCwinmmCapture, ALCbackend, self); - alsem_init(&self->Sem, 0); std::fill(self->WaveBuffer.begin(), self->WaveBuffer.end(), WAVEHDR{}); } @@ -455,8 +451,6 @@ void ALCwinmmCapture_Destruct(ALCwinmmCapture *self) ll_ringbuffer_free(self->Ring); self->Ring = nullptr; - alsem_destroy(&self->Sem); - ALCbackend_Destruct(STATIC_CAST(ALCbackend, self)); self->~ALCwinmmCapture(); } @@ -476,7 +470,7 @@ void CALLBACK ALCwinmmCapture_waveInProc(HWAVEIN UNUSED(device), UINT msg, auto self = reinterpret_cast<ALCwinmmCapture*>(instance); self->Readable.fetch_add(1, std::memory_order_acq_rel); - alsem_post(&self->Sem); + self->Sem.post(); } int ALCwinmmCapture_captureProc(ALCwinmmCapture *self) @@ -493,7 +487,7 @@ int ALCwinmmCapture_captureProc(ALCwinmmCapture *self) if(todo < 1) { ALCwinmmCapture_unlock(self); - alsem_wait(&self->Sem); + self->Sem.wait(); ALCwinmmCapture_lock(self); continue; } @@ -639,7 +633,7 @@ void ALCwinmmCapture_stop(ALCwinmmCapture *self) self->mKillNow.store(AL_TRUE, std::memory_order_release); if(self->mThread.joinable()) { - alsem_post(&self->Sem); + self->Sem.post(); self->mThread.join(); } |