From 7d9b4b9bea625495f9f6e6a284a9222a61df2674 Mon Sep 17 00:00:00 2001 From: Micael Dias Date: Tue, 27 Feb 2024 22:14:35 +0000 Subject: [PATCH] Try both wineasio32.dll and wineasio.dll when attempting to find the wineasio dll --- RS_ASIO/AsioHelpers.cpp | 57 ++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/RS_ASIO/AsioHelpers.cpp b/RS_ASIO/AsioHelpers.cpp index 8dda137..0daa09c 100644 --- a/RS_ASIO/AsioHelpers.cpp +++ b/RS_ASIO/AsioHelpers.cpp @@ -173,35 +173,50 @@ static std::optional GetWineAsioInfo() { isFirstCall = false; - rslog::info_ts() << __FUNCTION__ << " - Looking for wineasio.dll... " << std::endl; - HMODULE hWineAsio = LoadLibraryExA("wineasio.dll", nullptr, DONT_RESOLVE_DLL_REFERENCES); - if (hWineAsio) - { - rslog::info_ts() << " loaded" << std::endl; + std::array possibleDllNames = { + "wineasio32.dll", + "wineasio.dll" + }; + + bool keepLooking = true; - char path[MAX_PATH] = {}; - if (GetModuleFileNameA(hWineAsio, path, sizeof(path) - 1)) + for (const char* dllToFind : possibleDllNames) + { + if (!keepLooking) { - rslog::info_ts() << " path: " << path << std::endl; + break; + } - AsioHelpers::DriverInfo info; - info.Clsid = { 0x48d0c522, 0xbfcc, 0x45cc, { 0x8b, 0x84, 0x17, 0xf2, 0x5f, 0x33, 0xe6, 0xe8 } }; - info.Description = "Auto-detected wineasio.dll"; - info.DllPath = path; - info.Name = "wineasio-rsasio"; + rslog::info_ts() << __FUNCTION__ << " - Looking for \"" << dllToFind << "\"..."; - rslog::info_ts() << " name: " << info.Name.c_str() << std::endl; - result = info; + HMODULE hWineAsio = LoadLibraryExA(dllToFind, nullptr, DONT_RESOLVE_DLL_REFERENCES); + if (hWineAsio) + { + char path[512] = {}; + if (GetModuleFileNameA(hWineAsio, path, sizeof(path) - 1)) + { + rslog::info << " Loaded and found at \"" << path << "\"." << std::endl; + + AsioHelpers::DriverInfo info; + info.Clsid = { 0x48d0c522, 0xbfcc, 0x45cc, { 0x8b, 0x84, 0x17, 0xf2, 0x5f, 0x33, 0xe6, 0xe8 } }; + info.Description = "Auto-detected wineasio dll"; + info.DllPath = path; + info.Name = "wineasio-rsasio"; + + rslog::info_ts() << " name: " << info.Name.c_str() << std::endl; + result = info; + keepLooking = false; + } + else + { + rslog::info_ts() << " Loaded but could not get path." << std::endl; + } + FreeLibrary(hWineAsio); } else { - rslog::info_ts() << " Failed to find module name for wineasio.dll" << std::endl; + rslog::info << " Not found." << std::endl; } - FreeLibrary(hWineAsio); - } - else - { - rslog::info_ts() << " Failed to load wineasio.dll or file not found" << std::endl; } }