upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/shims/com_shim.cpp
diff options
context:
space:
mode:
authorJan Trencansky <jan.trencansky@protonmail.com>2026-11-25 03:41:48 -0500
committerJan Trencansky <jan.trencansky@protonmail.com>2026-11-25 03:41:48 -0500
commit8b771908c3c8d7d233e66f39d535a5a7c63047aa (patch)
treea5aa45227ef725edba1f021f7f2e10fcb898a834 /runtime/shims/com_shim.cpp
parentf9792cc56de10067f1bbdb233eaac23cd5b2074f (diff)
parent237deb64ce2b567283f304b7b89a23152e7b60c0 (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.cpp8
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
19namespace rt::com_shim { 21namespace rt::com_shim {
20namespace { 22namespace {
@@ -128,6 +130,10 @@ void WINAPI co_uninitialize() {
128HRESULT WINAPI co_create_instance(REFCLSID rclsid, LPUNKNOWN outer, DWORD cls_context, REFIID riid, LPVOID* ppv) { 130HRESULT 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