AsioDriverList needs a balanced call of CoInitialize/CoUninitialize just like, e.g., RtApiAsio, RtApiDs, or RtApiWasapi. The thing is that, if the application earlier already initialized COM using multithreading, then CoInitialize( NULL ) in the constructor of AsioDriverList will fail with RPC_E_CHANGED_MODE, in which case you must NOT call CoUninitialize() in the destructor, because if you do so, you are one uninit-call ahead, which causes a fail fast exception at the final CoUninitialize() at least in my code and I wouldn't know how to prevent this. The solution is to introduce a bool flag just like in RtApiDs and other parts of the code, e.g.:
constructor code:
coInitialized_ = false; HRESULT hr = CoInitialize( NULL ); if ( !FAILED( hr ) ) coInitialized_ = true;
destructor code:
if ( coInitialized_ ) CoUninitialize(); // balanced call.
idk if additional error handlingis required if the mode is not single-threaded apartment (which it would be in my case), frankly, idk what the reason for this requirement is in the first place, but what I do know is that there is an extra call of CoUninitialize.
AsioDriverListneeds a balanced call ofCoInitialize/CoUninitializejust like, e.g.,RtApiAsio,RtApiDs, orRtApiWasapi. The thing is that, if the application earlier already initialized COM using multithreading, thenCoInitialize( NULL )in the constructor of AsioDriverList will fail withRPC_E_CHANGED_MODE, in which case you must NOT callCoUninitialize()in the destructor, because if you do so, you are one uninit-call ahead, which causes a fail fast exception at the finalCoUninitialize()at least in my code and I wouldn't know how to prevent this. The solution is to introduce a bool flag just like inRtApiDsand other parts of the code, e.g.:constructor code:
coInitialized_ = false; HRESULT hr = CoInitialize( NULL ); if ( !FAILED( hr ) ) coInitialized_ = true;destructor code:
if ( coInitialized_ ) CoUninitialize(); // balanced call.idk if additional error handlingis required if the mode is not single-threaded apartment (which it would be in my case), frankly, idk what the reason for this requirement is in the first place, but what I do know is that there is an extra call of
CoUninitialize.