diff options
author | Chris Robinson <[email protected]> | 2023-04-30 19:22:38 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-04-30 19:22:38 -0700 |
commit | 3953cb5dbef7add70e72f41bbf36d5fdf1b02917 (patch) | |
tree | aa9228df643444d9818f2b7d4f3ec494d640904a /alc/context.cpp | |
parent | 027ce915373bfae3181725065b8ea906e5095a99 (diff) |
Fix shadowing warnings and add another missing include
Diffstat (limited to 'alc/context.cpp')
-rw-r--r-- | alc/context.cpp | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/alc/context.cpp b/alc/context.cpp index 4b477184..66de19d6 100644 --- a/alc/context.cpp +++ b/alc/context.cpp @@ -5,6 +5,7 @@ #include <algorithm> #include <array> +#include <cstring> #include <functional> #include <limits> #include <numeric> @@ -306,7 +307,28 @@ void ALCcontext::sendDebugMessage(DebugSource source, DebugType type, ALuint id, DebugSeverity severity, ALsizei length, const char *message) { static_assert(DebugSeverityBase+DebugSeverityCount <= 32, "Too many debug bits"); - static auto get_source_enum = [](DebugSource source) + + if(length < 0) + { + size_t newlen{std::strlen(message)}; + if(newlen > MaxDebugMessageLength) UNLIKELY + { + ERR("Debug message too long (%zu > %d)\n", newlen, MaxDebugMessageLength); + return; + } + length = static_cast<ALsizei>(newlen); + } + else if(length > MaxDebugMessageLength) UNLIKELY + { + ERR("Debug message too long (%d > %d)\n", length, MaxDebugMessageLength); + return; + } + + std::unique_lock<std::mutex> debuglock{mDebugCbLock}; + if(!mDebugEnabled.load()) UNLIKELY + return; + + auto get_source_enum = [source]() { switch(source) { @@ -318,7 +340,7 @@ void ALCcontext::sendDebugMessage(DebugSource source, DebugType type, ALuint id, } throw std::runtime_error{"Unexpected debug source value "+std::to_string(al::to_underlying(source))}; }; - static auto get_type_enum = [](DebugType type) + auto get_type_enum = [type]() { switch(type) { @@ -332,7 +354,7 @@ void ALCcontext::sendDebugMessage(DebugSource source, DebugType type, ALuint id, } throw std::runtime_error{"Unexpected debug type value "+std::to_string(al::to_underlying(type))}; }; - static auto get_severity_enum = [](DebugSeverity severity) + auto get_severity_enum = [severity]() { switch(severity) { @@ -344,26 +366,6 @@ void ALCcontext::sendDebugMessage(DebugSource source, DebugType type, ALuint id, throw std::runtime_error{"Unexpected debug severity value "+std::to_string(al::to_underlying(severity))}; }; - if(length < 0) - { - size_t newlen{std::strlen(message)}; - if(newlen > MaxDebugMessageLength) UNLIKELY - { - ERR("Debug message too long (%zu > %d)\n", newlen, MaxDebugMessageLength); - return; - } - length = static_cast<ALsizei>(newlen); - } - else if(length > MaxDebugMessageLength) UNLIKELY - { - ERR("Debug message too long (%d > %d)\n", length, MaxDebugMessageLength); - return; - } - - std::unique_lock<std::mutex> debuglock{mDebugCbLock}; - if(!mDebugEnabled.load()) UNLIKELY - return; - const uint filter{(1u<<(DebugSourceBase+al::to_underlying(source))) | (1u<<(DebugTypeBase+al::to_underlying(type))) | (1u<<(DebugSeverityBase+al::to_underlying(severity)))}; @@ -377,8 +379,8 @@ void ALCcontext::sendDebugMessage(DebugSource source, DebugType type, ALuint id, 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); + callback(get_source_enum(), get_type_enum(), id, get_severity_enum(), length, message, + param); } else { @@ -391,8 +393,7 @@ void ALCcontext::sendDebugMessage(DebugSource source, DebugType type, ALuint id, " ID: %u\n" " Severity: 0x%04x\n" " Message: \"%s\"\n", - get_source_enum(source), get_type_enum(type), id, get_severity_enum(severity), - message); + get_source_enum(), get_type_enum(), id, get_severity_enum(), message); } } |