Skip to content

Commit

Permalink
Don't try to override threading model if already initialized in this …
Browse files Browse the repository at this point in the history
…process.
  • Loading branch information
kode54 committed Jan 3, 2018
1 parent 1a44a66 commit c125b65
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions driver/VSTDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
VSTDriver::VSTDriver() {
szPluginPath = NULL;
bInitialized = false;
bInitializedOtherModel = false;
hProcess = NULL;
hThread = NULL;
hReadEvent = NULL;
Expand Down Expand Up @@ -194,8 +195,10 @@ bool VSTDriver::process_create()

if ( !bInitialized )
{
if ( FAILED( CoInitialize( NULL ) ) ) return false;
HRESULT ret = CoInitialize( NULL );
if ( FAILED( ret ) && ret != RPC_E_CHANGED_MODE ) return false;
bInitialized = true;
bInitializedOtherModel = ret == RPC_E_CHANGED_MODE;
}

hReadEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
Expand Down Expand Up @@ -330,8 +333,9 @@ void VSTDriver::process_terminate()
if ( hChildStd_OUT_Rd ) CloseHandle( hChildStd_OUT_Rd );
if ( hChildStd_OUT_Wr ) CloseHandle( hChildStd_OUT_Wr );
if ( hReadEvent ) CloseHandle( hReadEvent );
if ( bInitialized ) CoUninitialize();
if ( bInitialized && !bInitializedOtherModel ) CoUninitialize();
bInitialized = false;
bInitializedOtherModel = false;
hProcess = NULL;
hThread = NULL;
hReadEvent = NULL;
Expand Down
1 change: 1 addition & 0 deletions driver/VSTDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class VSTDriver {
unsigned uPluginPlatform;

bool bInitialized;
bool bInitializedOtherModel;
HANDLE hProcess;
HANDLE hThread;
HANDLE hReadEvent;
Expand Down

0 comments on commit c125b65

Please sign in to comment.