Replace last uses of alsem_t with al::semaphore
This commit is contained in:
parent
f26083e9ed
commit
89abbe8d94
@ -151,7 +151,7 @@ struct ALCjackPlayback final : public ALCbackend {
|
|||||||
jack_port_t *Port[MAX_OUTPUT_CHANNELS]{};
|
jack_port_t *Port[MAX_OUTPUT_CHANNELS]{};
|
||||||
|
|
||||||
ll_ringbuffer_t *Ring{nullptr};
|
ll_ringbuffer_t *Ring{nullptr};
|
||||||
alsem_t Sem;
|
al::semaphore Sem;
|
||||||
|
|
||||||
std::atomic<ALenum> mKillNow{AL_TRUE};
|
std::atomic<ALenum> mKillNow{AL_TRUE};
|
||||||
std::thread mThread;
|
std::thread mThread;
|
||||||
@ -183,8 +183,6 @@ static void ALCjackPlayback_Construct(ALCjackPlayback *self, ALCdevice *device)
|
|||||||
new (self) ALCjackPlayback{};
|
new (self) ALCjackPlayback{};
|
||||||
ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
|
ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
|
||||||
SET_VTABLE2(ALCjackPlayback, ALCbackend, self);
|
SET_VTABLE2(ALCjackPlayback, ALCbackend, self);
|
||||||
|
|
||||||
alsem_init(&self->Sem, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ALCjackPlayback_Destruct(ALCjackPlayback *self)
|
static void ALCjackPlayback_Destruct(ALCjackPlayback *self)
|
||||||
@ -201,8 +199,6 @@ static void ALCjackPlayback_Destruct(ALCjackPlayback *self)
|
|||||||
self->Client = NULL;
|
self->Client = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
alsem_destroy(&self->Sem);
|
|
||||||
|
|
||||||
ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
|
ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
|
||||||
self->~ALCjackPlayback();
|
self->~ALCjackPlayback();
|
||||||
}
|
}
|
||||||
@ -278,7 +274,7 @@ static int ALCjackPlayback_process(jack_nframes_t numframes, void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ll_ringbuffer_read_advance(self->Ring, total);
|
ll_ringbuffer_read_advance(self->Ring, total);
|
||||||
alsem_post(&self->Sem);
|
self->Sem.post();
|
||||||
|
|
||||||
if(numframes > total)
|
if(numframes > total)
|
||||||
{
|
{
|
||||||
@ -309,7 +305,7 @@ static int ALCjackPlayback_mixerProc(ALCjackPlayback *self)
|
|||||||
if(ll_ringbuffer_write_space(self->Ring) < device->UpdateSize)
|
if(ll_ringbuffer_write_space(self->Ring) < device->UpdateSize)
|
||||||
{
|
{
|
||||||
ALCjackPlayback_unlock(self);
|
ALCjackPlayback_unlock(self);
|
||||||
alsem_wait(&self->Sem);
|
self->Sem.wait();
|
||||||
ALCjackPlayback_lock(self);
|
ALCjackPlayback_lock(self);
|
||||||
continue;
|
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())
|
if(self->mKillNow.exchange(AL_TRUE, std::memory_order_acq_rel) || !self->mThread.joinable())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
alsem_post(&self->Sem);
|
self->Sem.post();
|
||||||
self->mThread.join();
|
self->mThread.join();
|
||||||
|
|
||||||
jack_deactivate(self->Client);
|
jack_deactivate(self->Client);
|
||||||
|
@ -146,7 +146,7 @@ struct ALCopenslPlayback final : public ALCbackend {
|
|||||||
SLObjectItf mBufferQueueObj{nullptr};
|
SLObjectItf mBufferQueueObj{nullptr};
|
||||||
|
|
||||||
ll_ringbuffer_t *mRing{nullptr};
|
ll_ringbuffer_t *mRing{nullptr};
|
||||||
alsem_t mSem;
|
al::semaphore mSem;
|
||||||
|
|
||||||
ALsizei mFrameSize{0};
|
ALsizei mFrameSize{0};
|
||||||
|
|
||||||
@ -178,8 +178,6 @@ static void ALCopenslPlayback_Construct(ALCopenslPlayback *self, ALCdevice *devi
|
|||||||
new (self) ALCopenslPlayback{};
|
new (self) ALCopenslPlayback{};
|
||||||
ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
|
ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
|
||||||
SET_VTABLE2(ALCopenslPlayback, ALCbackend, self);
|
SET_VTABLE2(ALCopenslPlayback, ALCbackend, self);
|
||||||
|
|
||||||
alsem_init(&self->mSem, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ALCopenslPlayback_Destruct(ALCopenslPlayback* self)
|
static void ALCopenslPlayback_Destruct(ALCopenslPlayback* self)
|
||||||
@ -200,8 +198,6 @@ static void ALCopenslPlayback_Destruct(ALCopenslPlayback* self)
|
|||||||
ll_ringbuffer_free(self->mRing);
|
ll_ringbuffer_free(self->mRing);
|
||||||
self->mRing = NULL;
|
self->mRing = NULL;
|
||||||
|
|
||||||
alsem_destroy(&self->mSem);
|
|
||||||
|
|
||||||
ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
|
ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
|
||||||
self->~ALCopenslPlayback();
|
self->~ALCopenslPlayback();
|
||||||
}
|
}
|
||||||
@ -222,7 +218,7 @@ static void ALCopenslPlayback_process(SLAndroidSimpleBufferQueueItf UNUSED(bq),
|
|||||||
*/
|
*/
|
||||||
ll_ringbuffer_read_advance(self->mRing, 1);
|
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)
|
if(ll_ringbuffer_write_space(self->mRing) == 0)
|
||||||
{
|
{
|
||||||
ALCopenslPlayback_unlock(self);
|
ALCopenslPlayback_unlock(self);
|
||||||
alsem_wait(&self->mSem);
|
self->mSem.wait();
|
||||||
ALCopenslPlayback_lock(self);
|
ALCopenslPlayback_lock(self);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -604,7 +600,7 @@ static void ALCopenslPlayback_stop(ALCopenslPlayback *self)
|
|||||||
if(self->mKillNow.exchange(AL_TRUE) || !self->mThread.joinable())
|
if(self->mKillNow.exchange(AL_TRUE) || !self->mThread.joinable())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
alsem_post(&self->mSem);
|
self->mSem.post();
|
||||||
self->mThread.join();
|
self->mThread.join();
|
||||||
|
|
||||||
result = VCALL(self->mBufferQueueObj,GetInterface)(SL_IID_PLAY, &player);
|
result = VCALL(self->mBufferQueueObj,GetInterface)(SL_IID_PLAY, &player);
|
||||||
|
@ -122,7 +122,7 @@ void ProbeCaptureDevices(void)
|
|||||||
|
|
||||||
struct ALCwinmmPlayback final : public ALCbackend {
|
struct ALCwinmmPlayback final : public ALCbackend {
|
||||||
std::atomic<ALuint> Writable{0u};
|
std::atomic<ALuint> Writable{0u};
|
||||||
alsem_t Sem;
|
al::semaphore Sem;
|
||||||
int Idx{0};
|
int Idx{0};
|
||||||
std::array<WAVEHDR,4> WaveBuffer;
|
std::array<WAVEHDR,4> WaveBuffer;
|
||||||
|
|
||||||
@ -160,7 +160,6 @@ void ALCwinmmPlayback_Construct(ALCwinmmPlayback *self, ALCdevice *device)
|
|||||||
ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
|
ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
|
||||||
SET_VTABLE2(ALCwinmmPlayback, ALCbackend, self);
|
SET_VTABLE2(ALCwinmmPlayback, ALCbackend, self);
|
||||||
|
|
||||||
alsem_init(&self->Sem, 0);
|
|
||||||
std::fill(self->WaveBuffer.begin(), self->WaveBuffer.end(), WAVEHDR{});
|
std::fill(self->WaveBuffer.begin(), self->WaveBuffer.end(), WAVEHDR{});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,8 +172,6 @@ void ALCwinmmPlayback_Destruct(ALCwinmmPlayback *self)
|
|||||||
al_free(self->WaveBuffer[0].lpData);
|
al_free(self->WaveBuffer[0].lpData);
|
||||||
std::fill(self->WaveBuffer.begin(), self->WaveBuffer.end(), WAVEHDR{});
|
std::fill(self->WaveBuffer.begin(), self->WaveBuffer.end(), WAVEHDR{});
|
||||||
|
|
||||||
alsem_destroy(&self->Sem);
|
|
||||||
|
|
||||||
ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
|
ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
|
||||||
self->~ALCwinmmPlayback();
|
self->~ALCwinmmPlayback();
|
||||||
}
|
}
|
||||||
@ -194,7 +191,7 @@ void CALLBACK ALCwinmmPlayback_waveOutProc(HWAVEOUT UNUSED(device), UINT msg,
|
|||||||
|
|
||||||
auto self = reinterpret_cast<ALCwinmmPlayback*>(instance);
|
auto self = reinterpret_cast<ALCwinmmPlayback*>(instance);
|
||||||
self->Writable.fetch_add(1, std::memory_order_acq_rel);
|
self->Writable.fetch_add(1, std::memory_order_acq_rel);
|
||||||
alsem_post(&self->Sem);
|
self->Sem.post();
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCE_ALIGN int ALCwinmmPlayback_mixerProc(ALCwinmmPlayback *self)
|
FORCE_ALIGN int ALCwinmmPlayback_mixerProc(ALCwinmmPlayback *self)
|
||||||
@ -212,7 +209,7 @@ FORCE_ALIGN int ALCwinmmPlayback_mixerProc(ALCwinmmPlayback *self)
|
|||||||
if(todo < 1)
|
if(todo < 1)
|
||||||
{
|
{
|
||||||
ALCwinmmPlayback_unlock(self);
|
ALCwinmmPlayback_unlock(self);
|
||||||
alsem_wait(&self->Sem);
|
self->Sem.wait();
|
||||||
ALCwinmmPlayback_lock(self);
|
ALCwinmmPlayback_lock(self);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -387,7 +384,7 @@ void ALCwinmmPlayback_stop(ALCwinmmPlayback *self)
|
|||||||
self->mThread.join();
|
self->mThread.join();
|
||||||
|
|
||||||
while(self->Writable.load(std::memory_order_acquire) < self->WaveBuffer.size())
|
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(),
|
std::for_each(self->WaveBuffer.begin(), self->WaveBuffer.end(),
|
||||||
[self](WAVEHDR &waveHdr) -> void
|
[self](WAVEHDR &waveHdr) -> void
|
||||||
{ waveOutUnprepareHeader(self->OutHdl, &waveHdr, sizeof(WAVEHDR)); }
|
{ waveOutUnprepareHeader(self->OutHdl, &waveHdr, sizeof(WAVEHDR)); }
|
||||||
@ -398,7 +395,7 @@ void ALCwinmmPlayback_stop(ALCwinmmPlayback *self)
|
|||||||
|
|
||||||
struct ALCwinmmCapture final : public ALCbackend {
|
struct ALCwinmmCapture final : public ALCbackend {
|
||||||
std::atomic<ALuint> Readable{0u};
|
std::atomic<ALuint> Readable{0u};
|
||||||
alsem_t Sem;
|
al::semaphore Sem;
|
||||||
int Idx{0};
|
int Idx{0};
|
||||||
std::array<WAVEHDR,4> WaveBuffer;
|
std::array<WAVEHDR,4> WaveBuffer;
|
||||||
|
|
||||||
@ -438,7 +435,6 @@ void ALCwinmmCapture_Construct(ALCwinmmCapture *self, ALCdevice *device)
|
|||||||
ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
|
ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
|
||||||
SET_VTABLE2(ALCwinmmCapture, ALCbackend, self);
|
SET_VTABLE2(ALCwinmmCapture, ALCbackend, self);
|
||||||
|
|
||||||
alsem_init(&self->Sem, 0);
|
|
||||||
std::fill(self->WaveBuffer.begin(), self->WaveBuffer.end(), WAVEHDR{});
|
std::fill(self->WaveBuffer.begin(), self->WaveBuffer.end(), WAVEHDR{});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -455,8 +451,6 @@ void ALCwinmmCapture_Destruct(ALCwinmmCapture *self)
|
|||||||
ll_ringbuffer_free(self->Ring);
|
ll_ringbuffer_free(self->Ring);
|
||||||
self->Ring = nullptr;
|
self->Ring = nullptr;
|
||||||
|
|
||||||
alsem_destroy(&self->Sem);
|
|
||||||
|
|
||||||
ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
|
ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
|
||||||
self->~ALCwinmmCapture();
|
self->~ALCwinmmCapture();
|
||||||
}
|
}
|
||||||
@ -476,7 +470,7 @@ void CALLBACK ALCwinmmCapture_waveInProc(HWAVEIN UNUSED(device), UINT msg,
|
|||||||
|
|
||||||
auto self = reinterpret_cast<ALCwinmmCapture*>(instance);
|
auto self = reinterpret_cast<ALCwinmmCapture*>(instance);
|
||||||
self->Readable.fetch_add(1, std::memory_order_acq_rel);
|
self->Readable.fetch_add(1, std::memory_order_acq_rel);
|
||||||
alsem_post(&self->Sem);
|
self->Sem.post();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ALCwinmmCapture_captureProc(ALCwinmmCapture *self)
|
int ALCwinmmCapture_captureProc(ALCwinmmCapture *self)
|
||||||
@ -493,7 +487,7 @@ int ALCwinmmCapture_captureProc(ALCwinmmCapture *self)
|
|||||||
if(todo < 1)
|
if(todo < 1)
|
||||||
{
|
{
|
||||||
ALCwinmmCapture_unlock(self);
|
ALCwinmmCapture_unlock(self);
|
||||||
alsem_wait(&self->Sem);
|
self->Sem.wait();
|
||||||
ALCwinmmCapture_lock(self);
|
ALCwinmmCapture_lock(self);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -639,7 +633,7 @@ void ALCwinmmCapture_stop(ALCwinmmCapture *self)
|
|||||||
self->mKillNow.store(AL_TRUE, std::memory_order_release);
|
self->mKillNow.store(AL_TRUE, std::memory_order_release);
|
||||||
if(self->mThread.joinable())
|
if(self->mThread.joinable())
|
||||||
{
|
{
|
||||||
alsem_post(&self->Sem);
|
self->Sem.post();
|
||||||
self->mThread.join();
|
self->mThread.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user