From eb383cc0608f0138f8f4667e876499432d52bba4 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 5 Sep 2024 10:52:41 -0700 Subject: [PATCH] Trace when strings are being overridden --- alc/alc.cpp | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/alc/alc.cpp b/alc/alc.cpp index a18801c7..f444cf99 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -2963,11 +2963,20 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) noexcep return device->configValue("game_compat", optname); }; if(auto overrideopt = checkopt("__ALSOFT_VENDOR_OVERRIDE", "vendor-override"sv)) - device->mVendorOverride = *overrideopt; + { + device->mVendorOverride = std::move(*overrideopt); + TRACE("Overriding vendor string: \"%s\"\n", device->mVendorOverride.c_str()); + } if(auto overrideopt = checkopt("__ALSOFT_VERSION_OVERRIDE", "version-override"sv)) - device->mVersionOverride = *overrideopt; + { + device->mVersionOverride = std::move(*overrideopt); + TRACE("Overriding version string: \"%s\"\n", device->mVersionOverride.c_str()); + } if(auto overrideopt = checkopt("__ALSOFT_RENDERER_OVERRIDE", "renderer-override"sv)) - device->mRendererOverride = *overrideopt; + { + device->mRendererOverride = std::move(*overrideopt); + TRACE("Overriding renderer string: \"%s\"\n", device->mRendererOverride.c_str()); + } { std::lock_guard listlock{ListLock}; @@ -3520,20 +3529,29 @@ FORCE_ALIGN ALCboolean ALC_APIENTRY alcReopenDeviceSOFT(ALCdevice *device, dev->mDeviceState = DeviceState::Unprepared; TRACE("Reopened device %p, \"%s\"\n", voidp{dev.get()}, dev->DeviceName.c_str()); - std::string{}.swap(device->mVendorOverride); - std::string{}.swap(device->mVersionOverride); - std::string{}.swap(device->mRendererOverride); - auto checkopt = [&device](const char *envname, const std::string_view optname) + std::string{}.swap(dev->mVendorOverride); + std::string{}.swap(dev->mVersionOverride); + std::string{}.swap(dev->mRendererOverride); + auto checkopt = [&dev](const char *envname, const std::string_view optname) { if(auto optval = al::getenv(envname)) return optval; - return device->configValue("game_compat", optname); + return dev->configValue("game_compat", optname); }; if(auto overrideopt = checkopt("__ALSOFT_VENDOR_OVERRIDE", "vendor-override"sv)) - device->mVendorOverride = *overrideopt; + { + dev->mVendorOverride = std::move(*overrideopt); + TRACE("Overriding vendor string: \"%s\"\n", dev->mVendorOverride.c_str()); + } if(auto overrideopt = checkopt("__ALSOFT_VERSION_OVERRIDE", "version-override"sv)) - device->mVersionOverride = *overrideopt; + { + dev->mVersionOverride = std::move(*overrideopt); + TRACE("Overriding version string: \"%s\"\n", dev->mVersionOverride.c_str()); + } if(auto overrideopt = checkopt("__ALSOFT_RENDERER_OVERRIDE", "renderer-override"sv)) - device->mRendererOverride = *overrideopt; + { + dev->mRendererOverride = std::move(*overrideopt); + TRACE("Overriding renderer string: \"%s\"\n", dev->mRendererOverride.c_str()); + } /* Always return true even if resetting fails. It shouldn't fail, but this * is primarily to avoid confusion by the app seeing the function return -- 2.11.4.GIT