FIX GUI bug related to COM and multi-threading
This commit is contained in:
parent
5418dd3185
commit
426306e1d6
|
@ -62,11 +62,6 @@ public:
|
||||||
|
|
||||||
DirectSound::DirectSound()
|
DirectSound::DirectSound()
|
||||||
{
|
{
|
||||||
if( S_OK != CoInitializeEx( NULL, COINIT_MULTITHREADED ) ) {
|
|
||||||
systemMessage( IDS_COM_FAILURE, NULL );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
pDirectSound = NULL;
|
pDirectSound = NULL;
|
||||||
dsbPrimary = NULL;
|
dsbPrimary = NULL;
|
||||||
dsbSecondary = NULL;
|
dsbSecondary = NULL;
|
||||||
|
@ -103,8 +98,6 @@ DirectSound::~DirectSound()
|
||||||
pDirectSound->Release();
|
pDirectSound->Release();
|
||||||
pDirectSound = NULL;
|
pDirectSound = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoUninitialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -271,7 +271,6 @@ CString Directories::browseForDir(CString title)
|
||||||
bi.lpfn = browseCallbackProc;
|
bi.lpfn = browseCallbackProc;
|
||||||
bi.lParam = (LPARAM)(LPCTSTR)initialFolderDir;
|
bi.lParam = (LPARAM)(LPCTSTR)initialFolderDir;
|
||||||
|
|
||||||
CoInitialize( NULL ); // required by BIF_USENEWUI
|
|
||||||
pidl = SHBrowseForFolder(&bi);
|
pidl = SHBrowseForFolder(&bi);
|
||||||
|
|
||||||
if(pidl) {
|
if(pidl) {
|
||||||
|
|
|
@ -219,6 +219,11 @@ BEGIN_MESSAGE_MAP(VBA, CWinApp)
|
||||||
|
|
||||||
VBA::VBA()
|
VBA::VBA()
|
||||||
{
|
{
|
||||||
|
// COINIT_MULTITHREADED is not supported by SHBrowseForFolder with BIF_USENEWUI
|
||||||
|
// OpenAL also causes trouble when COINIT_MULTITHREADED is used
|
||||||
|
if( S_OK != CoInitializeEx( NULL, COINIT_APARTMENTTHREADED ) ) {
|
||||||
|
systemMessage( IDS_COM_FAILURE, NULL );
|
||||||
|
}
|
||||||
mode320Available = false;
|
mode320Available = false;
|
||||||
mode640Available = false;
|
mode640Available = false;
|
||||||
mode800Available = false;
|
mode800Available = false;
|
||||||
|
@ -419,6 +424,8 @@ VBA::~VBA()
|
||||||
free( oalDevice );
|
free( oalDevice );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
CoUninitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -45,10 +45,22 @@ class XAudio2_BufferNotify : public IXAudio2VoiceCallback
|
||||||
public:
|
public:
|
||||||
HANDLE hBufferEndEvent;
|
HANDLE hBufferEndEvent;
|
||||||
|
|
||||||
XAudio2_BufferNotify() { hBufferEndEvent = CreateEvent( NULL, FALSE, FALSE, NULL ); }
|
XAudio2_BufferNotify() {
|
||||||
~XAudio2_BufferNotify() { CloseHandle( hBufferEndEvent ); }
|
hBufferEndEvent = NULL;
|
||||||
|
hBufferEndEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
|
||||||
|
ASSERT( hBufferEndEvent != NULL );
|
||||||
|
}
|
||||||
|
|
||||||
|
~XAudio2_BufferNotify() {
|
||||||
|
CloseHandle( hBufferEndEvent );
|
||||||
|
hBufferEndEvent = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
STDMETHOD_( void, OnBufferEnd ) ( void *pBufferContext ) {
|
||||||
|
ASSERT( hBufferEndEvent != NULL );
|
||||||
|
SetEvent( hBufferEndEvent );
|
||||||
|
}
|
||||||
|
|
||||||
STDMETHOD_( void, OnBufferEnd ) ( void *pBufferContext ) { SetEvent( hBufferEndEvent ); }
|
|
||||||
|
|
||||||
// dummies:
|
// dummies:
|
||||||
STDMETHOD_( void, OnVoiceProcessingPassStart ) () {}
|
STDMETHOD_( void, OnVoiceProcessingPassStart ) () {}
|
||||||
|
@ -115,12 +127,6 @@ XAudio2_Output::XAudio2_Output()
|
||||||
sVoice = NULL;
|
sVoice = NULL;
|
||||||
ZeroMemory( &buf, sizeof( buf ) );
|
ZeroMemory( &buf, sizeof( buf ) );
|
||||||
ZeroMemory( &vState, sizeof( vState ) );
|
ZeroMemory( &vState, sizeof( vState ) );
|
||||||
|
|
||||||
if( S_OK != CoInitializeEx( NULL, COINIT_MULTITHREADED ) ) {
|
|
||||||
systemMessage( IDS_COM_FAILURE, NULL );
|
|
||||||
failed = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -146,8 +152,6 @@ XAudio2_Output::~XAudio2_Output()
|
||||||
if( xaud ) {
|
if( xaud ) {
|
||||||
xaud->Release();
|
xaud->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
CoUninitialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue