aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/alc.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-01-01 16:38:54 -0800
committerChris Robinson <[email protected]>2019-01-01 16:42:54 -0800
commit1630a33567b155718b7cb984badb378b140f0889 (patch)
tree09e043b8c0c90d958431b3ef816c952511b8ad0d /Alc/alc.cpp
parent2f1566e0b4e71f9b03ae8081e81a85f52ddeab23 (diff)
Use standard unique_lock and lock_guard for the backend lock
Diffstat (limited to 'Alc/alc.cpp')
-rw-r--r--Alc/alc.cpp41
1 files changed, 19 insertions, 22 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp
index 59582ea6..b69c4756 100644
--- a/Alc/alc.cpp
+++ b/Alc/alc.cpp
@@ -2494,9 +2494,6 @@ ALCcontext_struct::~ALCcontext_struct()
*/
static bool ReleaseContext(ALCcontext *context, ALCdevice *device)
{
- ALCcontext *origctx, *newhead;
- bool ret = true;
-
if(LocalContext.get() == context)
{
WARN("%p released while current on thread\n", context);
@@ -2504,27 +2501,28 @@ static bool ReleaseContext(ALCcontext *context, ALCdevice *device)
ALCcontext_DecRef(context);
}
- origctx = context;
+ ALCcontext *origctx{context};
if(GlobalContext.compare_exchange_strong(origctx, nullptr))
ALCcontext_DecRef(context);
- device->Backend->lock();
- origctx = context;
- newhead = context->next.load(std::memory_order_relaxed);
- if(!device->ContextList.compare_exchange_strong(origctx, newhead))
- {
- ALCcontext *list;
- do {
- /* origctx is what the desired context failed to match. Try
- * swapping out the next one in the list.
- */
- list = origctx;
- origctx = context;
- } while(!list->next.compare_exchange_strong(origctx, newhead));
+ bool ret{true};
+ { BackendLockGuard _{*device->Backend};
+ origctx = context;
+ ALCcontext *newhead{context->next.load(std::memory_order_relaxed)};
+ if(!device->ContextList.compare_exchange_strong(origctx, newhead))
+ {
+ ALCcontext *list;
+ do {
+ /* origctx is what the desired context failed to match. Try
+ * swapping out the next one in the list.
+ */
+ list = origctx;
+ origctx = context;
+ } while(!list->next.compare_exchange_strong(origctx, newhead));
+ }
+ else
+ ret = !!newhead;
}
- else
- ret = !!newhead;
- device->Backend->unlock();
/* Make sure the context is finished and no longer processing in the mixer
* before sending the message queue kill event. The backend's lock does
@@ -4146,9 +4144,8 @@ FORCE_ALIGN ALC_API void ALC_APIENTRY alcRenderSamplesSOFT(ALCdevice *device, AL
alcSetError(dev.get(), ALC_INVALID_VALUE);
else
{
- dev->Backend->lock();
+ BackendLockGuard _{*device->Backend};
aluMixData(dev.get(), buffer, samples);
- dev->Backend->unlock();
}
}