diff options
-rw-r--r-- | Alc/alc.cpp | 4 | ||||
-rw-r--r-- | Alc/alcontext.h | 5 | ||||
-rw-r--r-- | OpenAL32/alSource.cpp | 10 | ||||
-rw-r--r-- | common/threads.h | 5 |
4 files changed, 10 insertions, 14 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp index fa7b9f44..28c9bc6f 100644 --- a/Alc/alc.cpp +++ b/Alc/alc.cpp @@ -2263,7 +2263,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) } almtx_lock(&context->PropLock); - almtx_lock(&context->EffectSlotLock); + std::unique_lock<almtx_t> slotlock{context->EffectSlotLock}; for(auto &slot : context->EffectSlotList) { EffectState *state = slot->Effect.State; @@ -2275,7 +2275,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) else UpdateEffectSlotProps(slot.get(), context); } - almtx_unlock(&context->EffectSlotLock); + slotlock.unlock(); almtx_lock(&context->SourceLock); for(auto &sublist : context->SourceList) diff --git a/Alc/alcontext.h b/Alc/alcontext.h index 26616f18..c9cfa985 100644 --- a/Alc/alcontext.h +++ b/Alc/alcontext.h @@ -135,11 +135,6 @@ void UpdateContextProps(ALCcontext *context); void ALCcontext_DeferUpdates(ALCcontext *context); void ALCcontext_ProcessUpdates(ALCcontext *context); -inline void LockEffectSlotList(ALCcontext *context) -{ almtx_lock(&context->EffectSlotLock); } -inline void UnlockEffectSlotList(ALCcontext *context) -{ almtx_unlock(&context->EffectSlotLock); } - /* Simple RAII context reference. Takes the reference of the provided * ALCcontext, and decrements it when leaving scope. Movable (transfer diff --git a/OpenAL32/alSource.cpp b/OpenAL32/alSource.cpp index 783a9d82..3a7bc4f0 100644 --- a/OpenAL32/alSource.cpp +++ b/OpenAL32/alSource.cpp @@ -755,6 +755,7 @@ static ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp p ALfilter *filter = NULL; ALeffectslot *slot = NULL; ALbufferlistitem *oldlist; + std::unique_lock<almtx_t> slotlock; ALfloat fvals[6]; switch(prop) @@ -980,23 +981,23 @@ static ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp p case AL_AUXILIARY_SEND_FILTER: - LockEffectSlotList(Context); + slotlock = std::unique_lock<almtx_t>{Context->EffectSlotLock}; if(!(values[0] == 0 || (slot=LookupEffectSlot(Context, values[0])) != NULL)) { - UnlockEffectSlotList(Context); + slotlock.unlock(); SETERR_RETURN(Context, AL_INVALID_VALUE, AL_FALSE, "Invalid effect ID %u", values[0]); } if((ALuint)values[1] >= (ALuint)device->NumAuxSends) { - UnlockEffectSlotList(Context); + slotlock.unlock(); SETERR_RETURN(Context, AL_INVALID_VALUE, AL_FALSE, "Invalid send %u", values[1]); } LockFilterList(device); if(!(values[2] == 0 || (filter=LookupFilter(device, values[2])) != NULL)) { UnlockFilterList(device); - UnlockEffectSlotList(Context); + slotlock.unlock(); SETERR_RETURN(Context, AL_INVALID_VALUE, AL_FALSE, "Invalid filter ID %u", values[2]); } @@ -1045,7 +1046,6 @@ static ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp p Source->Send[values[1]].Slot = slot; DO_UPDATEPROPS(); } - UnlockEffectSlotList(Context); return AL_TRUE; diff --git a/common/threads.h b/common/threads.h index 0b53c38f..8fd1093d 100644 --- a/common/threads.h +++ b/common/threads.h @@ -137,7 +137,7 @@ public: using mutex_type = almtx_t; explicit lock_guard(almtx_t &mtx) : mMtx(mtx) { almtx_lock(&mMtx); } - lock_guard(almtx_t &mtx, std::adopt_lock_t) : mMtx(mtx) { } + lock_guard(almtx_t &mtx, std::adopt_lock_t) noexcept : mMtx(mtx) { } ~lock_guard() { almtx_unlock(&mMtx); } lock_guard(const lock_guard&) = delete; @@ -152,8 +152,9 @@ class unique_lock<almtx_t> { public: using mutex_type = almtx_t; + unique_lock() noexcept = default; explicit unique_lock(almtx_t &mtx) : mMtx(&mtx) { almtx_lock(mMtx); mLocked = true; } - unique_lock(unique_lock&& rhs) : mMtx(rhs.mMtx), mLocked(rhs.mLocked) + unique_lock(unique_lock&& rhs) noexcept : mMtx(rhs.mMtx), mLocked(rhs.mLocked) { rhs.mMtx = nullptr; rhs.mLocked = false; } ~unique_lock() { if(mLocked) almtx_unlock(mMtx); } |