diff options
author | Chris Robinson <[email protected]> | 2018-09-20 22:44:58 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-09-20 22:44:58 -0700 |
commit | 84a90b7cc39a797781566ceebd6de40c495808aa (patch) | |
tree | 7aebdc6ed991f79e6a5342d9391d7267efac3ad2 /Alc | |
parent | ebbbeb0d660e442324c2b563c7b59e9f74ad15e9 (diff) |
Stop the event thread when releasing the context
To ensure no user callback gets called after alcDestroyContext.
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ALc.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -2680,7 +2680,6 @@ static ALvoid InitContext(ALCcontext *Context) */ static void FreeContext(ALCcontext *context) { - static const AsyncEvent kill_evt = ASYNC_EVENT(EventType_KillThread); ALlistener *listener = context->Listener; struct ALeffectslotArray *auxslots; struct ALeffectslotProps *eprops; @@ -2692,11 +2691,6 @@ static void FreeContext(ALCcontext *context) TRACE("%p\n", context); - while(ll_ringbuffer_write(context->AsyncEvents, (const char*)&kill_evt, 1) == 0) - althrd_yield(); - alsem_post(&context->EventSem); - althrd_join(context->EventThread, NULL); - if((cprops=ATOMIC_LOAD(&context->Update, almemory_order_acquire)) != NULL) { TRACE("Freed unapplied context update %p\n", cprops); @@ -2809,6 +2803,7 @@ static void FreeContext(ALCcontext *context) */ static bool ReleaseContext(ALCcontext *context, ALCdevice *device) { + static const AsyncEvent kill_evt = ASYNC_EVENT(EventType_KillThread); ALCcontext *origctx, *newhead; bool ret = true; @@ -2841,6 +2836,11 @@ static bool ReleaseContext(ALCcontext *context, ALCdevice *device) ret = !!newhead; V0(device->Backend,unlock)(); + while(ll_ringbuffer_write(context->AsyncEvents, (const char*)&kill_evt, 1) == 0) + althrd_yield(); + alsem_post(&context->EventSem); + althrd_join(context->EventThread, NULL); + ALCcontext_DecRef(context); return ret; } |