FIX GUI bug related to COM and multi-threading

This commit is contained in:
spacy51 2008-03-10 14:18:45 +00:00
parent 5418dd3185
commit 426306e1d6
4 changed files with 22 additions and 19 deletions

View File

@ -62,11 +62,6 @@ public:
DirectSound::DirectSound()
{
if( S_OK != CoInitializeEx( NULL, COINIT_MULTITHREADED ) ) {
systemMessage( IDS_COM_FAILURE, NULL );
return;
}
pDirectSound = NULL;
dsbPrimary = NULL;
dsbSecondary = NULL;
@ -103,8 +98,6 @@ DirectSound::~DirectSound()
pDirectSound->Release();
pDirectSound = NULL;
}
CoUninitialize();
}

View File

@ -271,7 +271,6 @@ CString Directories::browseForDir(CString title)
bi.lpfn = browseCallbackProc;
bi.lParam = (LPARAM)(LPCTSTR)initialFolderDir;
CoInitialize( NULL ); // required by BIF_USENEWUI
pidl = SHBrowseForFolder(&bi);
if(pidl) {

View File

@ -219,6 +219,11 @@ BEGIN_MESSAGE_MAP(VBA, CWinApp)
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;
mode640Available = false;
mode800Available = false;
@ -419,6 +424,8 @@ VBA::~VBA()
free( oalDevice );
}
#endif
CoUninitialize();
}
/////////////////////////////////////////////////////////////////////////////

View File

@ -45,10 +45,22 @@ class XAudio2_BufferNotify : public IXAudio2VoiceCallback
public:
HANDLE hBufferEndEvent;
XAudio2_BufferNotify() { hBufferEndEvent = CreateEvent( NULL, FALSE, FALSE, NULL ); }
~XAudio2_BufferNotify() { CloseHandle( hBufferEndEvent ); }
XAudio2_BufferNotify() {
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:
STDMETHOD_( void, OnVoiceProcessingPassStart ) () {}
@ -115,12 +127,6 @@ XAudio2_Output::XAudio2_Output()
sVoice = NULL;
ZeroMemory( &buf, sizeof( buf ) );
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 ) {
xaud->Release();
}
CoUninitialize();
}