mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-08-02 14:50:41 -07:00
asio: cache result from CoCreateInstance to work around buggy asio drivers (#781)
## Link to GitHub Issue or related Pull Request, if one exists n/a ## Description of change IIDX likes to call `CoCreateInstance` and `init` multiple times on ASIO drivers, but some ASIO drivers like `Neva Uno` really don't like that and ends up crashing. In our wrapper, cache the instances and try to reuse them for better compatibility. ## Testing Worked fine for FlexASIO / Xonar AE / Realtek ASIO though none of these drivers repro the crashing behavior.
This commit is contained in:
@@ -68,6 +68,15 @@ static HRESULT STDAPICALLTYPE CoCreateInstance_hook(
|
||||
|
||||
HRESULT ret;
|
||||
|
||||
// ASIO: if we already hold a cached instance for this CLSID, hand back a fresh
|
||||
// wrapper over it instead of re-creating the real driver (see asio_proxy.cpp)
|
||||
if (ppv != nullptr && hooks::audio::asio::is_asio_creation(rclsid, riid)) {
|
||||
if (IUnknown *reused = hooks::audio::asio::wrap_existing(rclsid)) {
|
||||
*ppv = reused;
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// call original
|
||||
ret = CoCreateInstance_orig(rclsid, pUnkOuter, dwClsContext, riid, ppv);
|
||||
if (FAILED(ret)) {
|
||||
@@ -130,5 +139,9 @@ namespace hooks::audio {
|
||||
CLIENT = nullptr;
|
||||
}
|
||||
stop_low_latency();
|
||||
|
||||
// release the ASIO drivers we kept pinned for the process lifetime now that we are
|
||||
// at a controlled shutdown point (see asio_proxy.cpp)
|
||||
hooks::audio::asio::release_all_wrappers();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user