diff options
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 | ||