From 8a574e5cd21c51b022e1cbdc01cd2896057fcd2a Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Thu, 15 Jan 2015 22:32:25 +0100 Subject: [PATCH] Do the first CoInitializeEx on the main thread instead of the EmuThread (WASAPI). Fixes #7334 --- Windows/DSoundStream.cpp | 2 -- Windows/W32Util/ShellUtil.cpp | 2 -- Windows/WindowsHost.cpp | 2 +- Windows/main.cpp | 3 +++ 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Windows/DSoundStream.cpp b/Windows/DSoundStream.cpp index 4fe56ee0db..d6e2e02b02 100644 --- a/Windows/DSoundStream.cpp +++ b/Windows/DSoundStream.cpp @@ -275,11 +275,9 @@ private: #define REFTIMES_PER_MILLISEC (REFTIMES_PER_SEC / 1000) WASAPIAudioBackend::WASAPIAudioBackend() : hThread_(NULL), sampleRate_(0), callback_(nullptr), threadData_(0) { - CoInitializeEx(NULL, COINIT_MULTITHREADED); } WASAPIAudioBackend::~WASAPIAudioBackend() { - CoUninitialize(); if (threadData_ == 0) { threadData_ = 1; } diff --git a/Windows/W32Util/ShellUtil.cpp b/Windows/W32Util/ShellUtil.cpp index 5ee34c9d57..6b7aa9a19c 100644 --- a/Windows/W32Util/ShellUtil.cpp +++ b/Windows/W32Util/ShellUtil.cpp @@ -34,9 +34,7 @@ namespace W32Util wchar_t temp[MAX_PATH]; SHGetPathFromIDList(idList, temp); if (wcslen(temp)) - { return ConvertWStringToUTF8(temp); - } else return ""; } diff --git a/Windows/WindowsHost.cpp b/Windows/WindowsHost.cpp index ebdf665951..1c14b869bb 100644 --- a/Windows/WindowsHost.cpp +++ b/Windows/WindowsHost.cpp @@ -285,7 +285,7 @@ void WindowsHost::UpdateConsolePosition() HRESULT CreateLink(LPCWSTR lpszPathObj, LPCWSTR lpszArguments, LPCWSTR lpszPathLink, LPCWSTR lpszDesc) { HRESULT hres; IShellLink* psl; - CoInitialize(0); + CoInitializeEx(NULL, COINIT_MULTITHREADED); // Get a pointer to the IShellLink interface. It is assumed that CoInitialize // has already been called. diff --git a/Windows/main.cpp b/Windows/main.cpp index dcf1c222b9..eb5c677e24 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -359,6 +359,8 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin { setCurrentThreadName("Main"); + CoInitializeEx(NULL, COINIT_MULTITHREADED); + // Windows Vista and above: alert Windows that PPSSPP is DPI aware, // so that we don't flicker in fullscreen on some PCs. MakePPSSPPDPIAware(); @@ -616,5 +618,6 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin if (g_Config.bRestartRequired) { W32Util::ExitAndRestart(); } + CoUninitialize(); return 0; }