diff options
author | Chris Robinson <[email protected]> | 2023-04-30 14:36:56 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-04-30 14:36:56 -0700 |
commit | f2a0df87916de7b9fa8b65a52814c9a09fc6bee9 (patch) | |
tree | 5f7b2f662f4983780e4e358e74a6fd9b8ed5bef0 | |
parent | 6d98d5595768fc4fbd8e41a012a73839cb2a35ba (diff) |
Unlock the debug lock when calling the callback
There's no full guarantee about calling AL functions in a debug callback, due
to a risk of deadlocks from an AL call that tries to take a lock that's already
held at the time the callback is invoked, but this helps more work.
-rw-r--r-- | alc/context.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/alc/context.cpp b/alc/context.cpp index 6553f322..4e5a3ab6 100644 --- a/alc/context.cpp +++ b/alc/context.cpp @@ -342,7 +342,7 @@ void ALCcontext::sendDebugMessage(DebugSource source, DebugType type, ALuint id, throw std::runtime_error{"Unexpected debug severity value "+std::to_string(al::to_underlying(severity))}; }; - std::lock_guard<std::mutex> _{mDebugCbLock}; + std::unique_lock<std::mutex> debuglock{mDebugCbLock}; if(!mDebugEnabled.load()) UNLIKELY return; @@ -355,8 +355,13 @@ void ALCcontext::sendDebugMessage(DebugSource source, DebugType type, ALuint id, return; if(mDebugCb) - mDebugCb(get_source_enum(source), get_type_enum(type), id, get_severity_enum(severity), - length, message, mDebugParam); + { + auto callback = mDebugCb; + auto param = mDebugParam; + debuglock.unlock(); + callback(get_source_enum(source), get_type_enum(type), id, get_severity_enum(severity), + length, message, param); + } else { /* TODO: Store in a log. */ |