From ea5d5662180d98fe862bf117d9e30a35d4c1c83e Mon Sep 17 00:00:00 2001 From: "[ ]" <[ ]> Date: Sat, 20 Dec 2025 21:22:34 +0900 Subject: [PATCH] feat: Test spicetools logging bmsound-wine side > broken commit > route bmsound messages back to spicetools log --- hooks/audio/implementations/pipewire.cpp | 2 +- hooks/develhook.cpp | 1 + hooks/wmischook.cpp | 38 ++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/hooks/audio/implementations/pipewire.cpp b/hooks/audio/implementations/pipewire.cpp index 2851e21..ab027eb 100644 --- a/hooks/audio/implementations/pipewire.cpp +++ b/hooks/audio/implementations/pipewire.cpp @@ -242,7 +242,7 @@ HRESULT PipewireBackend::on_release_buffer(uint32_t num_frames_written, DWORD dw } BmswClientReleaseBuffer(client_, num_frames_written); - if(notif_state_ == -1) callback_notify(this); + if (notif_state_ == -1) callback_notify(this); return S_OK; } diff --git a/hooks/develhook.cpp b/hooks/develhook.cpp index 33c3488..34f348d 100644 --- a/hooks/develhook.cpp +++ b/hooks/develhook.cpp @@ -44,6 +44,7 @@ public: { log_warning("hooks::devel::wmisc", "Disabling auto-patching.."); hooks::wmisc::skip_patching_by_model(true); + hooks::wmisc::apply_performance_hacks(avs::game::DLL_INSTANCE, "FORCE", "bmsound"); } } wmisc_("wmisc_test"); diff --git a/hooks/wmischook.cpp b/hooks/wmischook.cpp index 0c19f42..62912bb 100644 --- a/hooks/wmischook.cpp +++ b/hooks/wmischook.cpp @@ -105,6 +105,41 @@ void attach(HINSTANCE hmodule) } } +namespace hooks::wmisc::bmsound +{ +typedef void (*BmswLoggerInit_t)(void *cb); +extern "C" void __cdecl log_printf(char level, const char *scope, const char *fmt) +{ + switch (level) + { + case 'I': + log_info(scope, "{}", fmt); + break; + case 'W': + log_warning(scope, "{}", fmt); + break; + case 'E': + log_fatal(scope, "{}", fmt); + break; + case 'M': + default: + log_misc(scope, "{}", fmt); + break; + } +} +void attach(HINSTANCE hmodule) +{ + + BmswLoggerInit_t BmswLoggerInit; + HMODULE bmsw; + if ((bmsw = libutils::try_library(MODULE_PATH / "bmsound-wine.dll"))) + { + BmswLoggerInit = (BmswLoggerInit_t) GetProcAddress(bmsw, "BmswLoggerInit"); + BmswLoggerInit(reinterpret_cast(log_printf)); + } +} +} + namespace hooks::wmisc { static bool patchmodel_ = true; @@ -132,6 +167,9 @@ void apply_performance_hacks(HINSTANCE hmodule, const char *model, const char *e case to_hash("msacm"): msacm::attach(hmodule); break; + case to_hash("bmsound"): + bmsound::attach(hmodule); + break; default: break; }