diff options
| author | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-25 03:41:48 -0500 |
|---|---|---|
| committer | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-25 03:41:48 -0500 |
| commit | 8b771908c3c8d7d233e66f39d535a5a7c63047aa (patch) | |
| tree | a5aa45227ef725edba1f021f7f2e10fcb898a834 /runtime/shims/com_shim.cpp | |
| parent | f9792cc56de10067f1bbdb233eaac23cd5b2074f (diff) | |
| parent | 237deb64ce2b567283f304b7b89a23152e7b60c0 (diff) | |
Merge main into feat/gdk-lifecycle-window-hook (#769)feat/gdk-lifecycle-window-hook
scripts/build_runtime.ps1 conflicted in the $files list of the build
without CMake: main added shims\silent_audio.cpp there (#1598) after this
branch had merged main, and this branch adds shims\lifecycle.cpp. Both
entries are kept, lifecycle.cpp where this branch had it. The branch's
other change in that file (user32.lib on the link line) merged cleanly.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/shims/com_shim.cpp')
| -rw-r--r-- | runtime/shims/com_shim.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/runtime/shims/com_shim.cpp b/runtime/shims/com_shim.cpp index 55962e215..8156b1917 100644 --- a/runtime/shims/com_shim.cpp +++ b/runtime/shims/com_shim.cpp | |||
| @@ -1,7 +1,8 @@ | |||
| 1 | // COM lifecycle and helper shims for api-ms-win-core-com-l1-1-0..3.dll. | 1 | // COM lifecycle and helper shims for api-ms-win-core-com-l1-1-0..3.dll. |
| 2 | // | 2 | // |
| 3 | // game_scarlett_master.exe imports CoInitializeEx, CoUninitialize, CoCreateInstance, CoCreateGuid, CoTaskMemFree, | 3 | // game_scarlett_master.exe imports CoInitializeEx, CoUninitialize, CoCreateInstance, CoCreateGuid, CoTaskMemFree, |
| 4 | // PropVariantClear, and StringFromGUID2 through api-ms-win-core-com-l1-1-0.dll. When the host (or a host library) has | 4 | // PropVariantClear, and StringFromGUID2 through api-ms-win-core-com-l1-1-0.dll. CoCreateInstance of the |
| 5 | // MMDeviceEnumerator goes to silent_audio.cpp, which serves a silent output endpoint when the host has none. When the host (or a host library) has | ||
| 5 | // already initialized a thread as STA, a guest call to CoInitializeEx(nullptr, COINIT_MULTITHREADED) fails with | 6 | // already initialized a thread as STA, a guest call to CoInitializeEx(nullptr, COINIT_MULTITHREADED) fails with |
| 6 | // RPC_E_CHANGED_MODE (0x80010106) and an unbalanced CoUninitialize can tear down host COM early. | 7 | // RPC_E_CHANGED_MODE (0x80010106) and an unbalanced CoUninitialize can tear down host COM early. |
| 7 | // | 8 | // |
| @@ -15,6 +16,7 @@ | |||
| 15 | #include <new> | 16 | #include <new> |
| 16 | 17 | ||
| 17 | #include "shims.h" | 18 | #include "shims.h" |
| 19 | #include "silent_audio.h" | ||
| 18 | 20 | ||
| 19 | namespace rt::com_shim { | 21 | namespace rt::com_shim { |
| 20 | namespace { | 22 | namespace { |
| @@ -128,6 +130,10 @@ void WINAPI co_uninitialize() { | |||
| 128 | HRESULT WINAPI co_create_instance(REFCLSID rclsid, LPUNKNOWN outer, DWORD cls_context, REFIID riid, LPVOID* ppv) { | 130 | HRESULT WINAPI co_create_instance(REFCLSID rclsid, LPUNKNOWN outer, DWORD cls_context, REFIID riid, LPVOID* ppv) { |
| 129 | if (!ppv) return E_POINTER; | 131 | if (!ppv) return E_POINTER; |
| 130 | *ppv = nullptr; | 132 | *ppv = nullptr; |
| 133 | // The audio device enumerator: the host's when it has an output, else (or with LEONIDA_AUDIO=silent) one that | ||
| 134 | // also answers with the silent output endpoint (silent_audio.h). | ||
| 135 | if (!outer && IsEqualCLSID(rclsid, rt::silent_audio::kClsidMMDeviceEnumerator)) | ||
| 136 | return rt::silent_audio::create_enumerator(cls_context, riid, ppv); | ||
| 131 | return ::CoCreateInstance(rclsid, outer, cls_context, riid, ppv); | 137 | return ::CoCreateInstance(rclsid, outer, cls_context, riid, ppv); |
| 132 | } | 138 | } |
| 133 | 139 | ||