diff options
author | Chris Robinson <[email protected]> | 2018-02-01 18:59:32 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-02-01 18:59:32 -0800 |
commit | ec14c98f2d7c2a01f62a2fcebf1d9479cb540a0d (patch) | |
tree | d21cebacf7b9b974cf8ad4bfc675f51462a6f893 | |
parent | 975c682ec367f61e6e700b21da38e2c59cf69c3b (diff) |
Use an atomic instead of volatile to tell a thread to quit
-rw-r--r-- | Alc/backends/jack.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/Alc/backends/jack.c b/Alc/backends/jack.c index 09f778c7..14032d45 100644 --- a/Alc/backends/jack.c +++ b/Alc/backends/jack.c @@ -152,7 +152,7 @@ typedef struct ALCjackPlayback { ll_ringbuffer_t *Ring; alsem_t Sem; - volatile int killNow; + ATOMIC(ALenum) killNow; althrd_t thread; } ALCjackPlayback; @@ -191,7 +191,7 @@ static void ALCjackPlayback_Construct(ALCjackPlayback *self, ALCdevice *device) self->Port[i] = NULL; self->Ring = NULL; - self->killNow = 1; + ATOMIC_INIT(&self->killNow, AL_TRUE); } static void ALCjackPlayback_Destruct(ALCjackPlayback *self) @@ -312,7 +312,7 @@ static int ALCjackPlayback_mixerProc(void *arg) althrd_setname(althrd_current(), MIXER_THREAD_NAME); ALCjackPlayback_lock(self); - while(!self->killNow && device->Connected) + while(!ATOMIC_LOAD(&self->killNow, almemory_order_acquire) && device->Connected) { ALuint todo, len1, len2; @@ -479,7 +479,7 @@ static ALCboolean ALCjackPlayback_start(ALCjackPlayback *self) } jack_free(ports); - self->killNow = 0; + ATOMIC_STORE(&self->killNow, AL_FALSE, almemory_order_release); if(althrd_create(&self->thread, ALCjackPlayback_mixerProc, self) != althrd_success) { jack_deactivate(self->Client); @@ -493,10 +493,9 @@ static void ALCjackPlayback_stop(ALCjackPlayback *self) { int res; - if(self->killNow) + if(ATOMIC_EXCHANGE(&self->killNow, AL_TRUE, almemory_order_acq_rel)) return; - self->killNow = 1; alsem_post(&self->Sem); althrd_join(self->thread, &res); |