diff options
Diffstat (limited to 'OpenAL32/event.c')
-rw-r--r-- | OpenAL32/event.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/OpenAL32/event.c b/OpenAL32/event.c index 3b70c9f3..93d68d7a 100644 --- a/OpenAL32/event.c +++ b/OpenAL32/event.c @@ -39,9 +39,24 @@ AL_API void AL_APIENTRY alEventControlSOFT(ALsizei count, const ALenum *types, A almtx_lock(&context->EventLock); if(enable) - context->EnabledEvts |= flags; + { + ALbitfieldSOFT enabledevts = ATOMIC_LOAD(&context->EnabledEvts, almemory_order_relaxed); + while(ATOMIC_COMPARE_EXCHANGE_WEAK(&context->EnabledEvts, &enabledevts, enabledevts|flags, + almemory_order_acq_rel, almemory_order_acquire) == 0) + { + /* enabledevts is (re-)filled with the current value on failure, so + * just try again. + */ + } + } else - context->EnabledEvts &= ~flags; + { + ALbitfieldSOFT enabledevts = ATOMIC_LOAD(&context->EnabledEvts, almemory_order_relaxed); + while(ATOMIC_COMPARE_EXCHANGE_WEAK(&context->EnabledEvts, &enabledevts, enabledevts&~flags, + almemory_order_acq_rel, almemory_order_acquire) == 0) + { + } + } almtx_unlock(&context->EventLock); done: |