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:21:26 -0500
committerJan Trencansky <jan.trencansky@protonmail.com>2026-11-25 03:21:26 -0500
commit8665eee910cf4e3e3b86324ae025a6cbb0c64e69 (patch)
treefffa1b15186dbb147cd1e079c7e0f227fc19c569 /runtime/shims/com_shim.cpp
parentd4f3e0bbc63bbd47c7b0afa762f0f22fed5a5a2e (diff)
parent3f81d46ac01021bd7517f0cce153f4283bc8dd17 (diff)
Merge commit '3f81d46ac' into HEAD
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