From 82416415025337fac95130abcb3184d04799724a Mon Sep 17 00:00:00 2001 From: bicarus-dev <202771338+bicarus-dev@users.noreply.github.com> Date: Sun, 23 Mar 2025 18:02:41 -0700 Subject: [PATCH] audio: log errors when RegOpenKey fails for ASIO registry hooks (#273) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Link to GitHub Issue, if one exists n/a ## Description of change When RegOpenKey* hooks fail when substituting user's ASIO driver, log a warning message. This can happen when the user types in the wrong value for `-iidxasio` or `-sdvxasio`, which is a common issue. ## Compiling 🥇 ## Testing Tested LDJ/KFC --- src/spice2x/games/iidx/iidx.cpp | 20 ++++++++++++++++++-- src/spice2x/games/sdvx/sdvx.cpp | 20 ++++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/spice2x/games/iidx/iidx.cpp b/src/spice2x/games/iidx/iidx.cpp index 72a7ac4..32cc1f5 100644 --- a/src/spice2x/games/iidx/iidx.cpp +++ b/src/spice2x/games/iidx/iidx.cpp @@ -100,9 +100,25 @@ namespace games::iidx { *phkResult = DEVICE_ASIO_REG_HANDLE; log_info("iidx::asio", "replacing '{}' with '{}'", lpSubKey, ASIO_DRIVER.value()); - - return RegOpenKeyExA_orig(real_asio_reg_handle, ASIO_DRIVER.value().c_str(), ulOptions, samDesired, + const auto result = RegOpenKeyExA_orig( + real_asio_reg_handle, + ASIO_DRIVER.value().c_str(), + ulOptions, + samDesired, &real_asio_device_reg_handle); + + if (result != ERROR_SUCCESS) { + log_warning( + "iidx::asio", + "failed to open registry subkey '{}', error=0x{:x}", + ASIO_DRIVER.value().c_str(), result); + log_warning( + "iidx::asio", + "due to improper ASIO setting, game will likely fail to launch; double check -iidxasio and the registry", + ASIO_DRIVER.value().c_str(), result); + } + + return result; } } diff --git a/src/spice2x/games/sdvx/sdvx.cpp b/src/spice2x/games/sdvx/sdvx.cpp index 0a5ec54..0bd77ec 100644 --- a/src/spice2x/games/sdvx/sdvx.cpp +++ b/src/spice2x/games/sdvx/sdvx.cpp @@ -79,9 +79,25 @@ namespace games::sdvx { *phkResult = DEVICE_ASIO_REG_HANDLE; log_info("sdvx::asio", "replacing '{}' with '{}'", lpSubKey, ASIO_DRIVER.value()); - - return RegOpenKeyExA_orig(real_asio_reg_handle, ASIO_DRIVER.value().c_str(), ulOptions, samDesired, + const auto result = RegOpenKeyExA_orig( + real_asio_reg_handle, + ASIO_DRIVER.value().c_str(), + ulOptions, + samDesired, &real_asio_device_reg_handle); + + if (result != ERROR_SUCCESS) { + log_warning( + "sdvx::asio", + "failed to open registry subkey '{}', error=0x{:x}", + ASIO_DRIVER.value().c_str(), result); + log_warning( + "sdvx::asio", + "due to improper ASIO setting, game will likely fall back to WASAPI; double check -sdvxasio and the registry", + ASIO_DRIVER.value().c_str(), result); + } + + return result; } }