Rename EventLock to make it more clear it's protecting the callback
This commit is contained in:
@@ -2611,7 +2611,7 @@ static ALvoid InitContext(ALCcontext *Context)
|
||||
Context->MetersPerUnit = AL_DEFAULT_METERS_PER_UNIT;
|
||||
ATOMIC_FLAG_TEST_AND_SET(&Context->PropsClean, almemory_order_relaxed);
|
||||
ATOMIC_INIT(&Context->DeferUpdates, AL_FALSE);
|
||||
almtx_init(&Context->EventLock, almtx_plain);
|
||||
almtx_init(&Context->EventCbLock, almtx_plain);
|
||||
ATOMIC_INIT(&Context->EnabledEvts, 0);
|
||||
Context->EventCb = NULL;
|
||||
Context->EventParam = NULL;
|
||||
@@ -2743,7 +2743,7 @@ static void FreeContext(ALCcontext *context)
|
||||
}
|
||||
TRACE("Freed "SZFMT" listener property object%s\n", count, (count==1)?"":"s");
|
||||
|
||||
almtx_destroy(&context->EventLock);
|
||||
almtx_destroy(&context->EventCbLock);
|
||||
|
||||
ALCdevice_DecRef(context->Device);
|
||||
context->Device = NULL;
|
||||
|
||||
@@ -664,7 +664,7 @@ struct ALCcontext_struct {
|
||||
|
||||
ATOMIC(struct ALeffectslotArray*) ActiveAuxSlots;
|
||||
|
||||
almtx_t EventLock;
|
||||
almtx_t EventCbLock;
|
||||
ATOMIC(ALbitfieldSOFT) EnabledEvts;
|
||||
ALEVENTPROCSOFT EventCb;
|
||||
void *EventParam;
|
||||
|
||||
+2
-2
@@ -75,12 +75,12 @@ void alSetError(ALCcontext *context, ALenum errorCode, const char *msg, ...)
|
||||
if((ATOMIC_LOAD(&context->EnabledEvts, almemory_order_relaxed)&EventType_Error))
|
||||
{
|
||||
ALbitfieldSOFT enabledevts;
|
||||
almtx_lock(&context->EventLock);
|
||||
almtx_lock(&context->EventCbLock);
|
||||
enabledevts = ATOMIC_LOAD(&context->EnabledEvts, almemory_order_relaxed);
|
||||
if((enabledevts&EventType_Error) && context->EventCb)
|
||||
(*context->EventCb)(AL_EVENT_TYPE_ERROR_SOFT, 0, errorCode, msglen, msg,
|
||||
context->EventParam);
|
||||
almtx_unlock(&context->EventLock);
|
||||
almtx_unlock(&context->EventCbLock);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -722,12 +722,12 @@ AL_API ALvoid AL_APIENTRY alDopplerVelocity(ALfloat value)
|
||||
"alDopplerVelocity is deprecated in AL1.1, use alSpeedOfSound";
|
||||
const ALsizei msglen = (ALsizei)strlen(msg);
|
||||
ALbitfieldSOFT enabledevts;
|
||||
almtx_lock(&context->EventLock);
|
||||
almtx_lock(&context->EventCbLock);
|
||||
enabledevts = ATOMIC_LOAD(&context->EnabledEvts, almemory_order_relaxed);
|
||||
if((enabledevts&EventType_Deprecated) && context->EventCb)
|
||||
(*context->EventCb)(AL_EVENT_TYPE_DEPRECATED_SOFT, 0, 0, msglen, msg,
|
||||
context->EventParam);
|
||||
almtx_unlock(&context->EventLock);
|
||||
almtx_unlock(&context->EventCbLock);
|
||||
}
|
||||
|
||||
if(!(value >= 0.0f && isfinite(value)))
|
||||
|
||||
+2
-4
@@ -37,7 +37,6 @@ AL_API void AL_APIENTRY alEventControlSOFT(ALsizei count, const ALenum *types, A
|
||||
SETERR_GOTO(context, AL_INVALID_ENUM, done, "Invalid event type 0x%04x", types[i]);
|
||||
}
|
||||
|
||||
almtx_lock(&context->EventLock);
|
||||
if(enable)
|
||||
{
|
||||
ALbitfieldSOFT enabledevts = ATOMIC_LOAD(&context->EnabledEvts, almemory_order_relaxed);
|
||||
@@ -57,7 +56,6 @@ AL_API void AL_APIENTRY alEventControlSOFT(ALsizei count, const ALenum *types, A
|
||||
{
|
||||
}
|
||||
}
|
||||
almtx_unlock(&context->EventLock);
|
||||
|
||||
done:
|
||||
ALCcontext_DecRef(context);
|
||||
@@ -70,10 +68,10 @@ AL_API void AL_APIENTRY alEventCallbackSOFT(ALEVENTPROCSOFT callback, void *user
|
||||
context = GetContextRef();
|
||||
if(!context) return;
|
||||
|
||||
almtx_lock(&context->EventLock);
|
||||
almtx_lock(&context->EventCbLock);
|
||||
context->EventCb = callback;
|
||||
context->EventParam = userParam;
|
||||
almtx_unlock(&context->EventLock);
|
||||
almtx_unlock(&context->EventCbLock);
|
||||
|
||||
ALCcontext_DecRef(context);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user