Commit 7f0a92a0 authored by David Reid's avatar David Reid

Don't call CoUninialize() when CoInitializeEx() fails.

parent ab873752
...@@ -7658,6 +7658,8 @@ struct ma_context ...@@ -7658,6 +7658,8 @@ struct ma_context
ma_proc RegOpenKeyExA; ma_proc RegOpenKeyExA;
ma_proc RegCloseKey; ma_proc RegCloseKey;
ma_proc RegQueryValueExA; ma_proc RegQueryValueExA;
/*HRESULT*/ long CoInitializeResult;
} win32; } win32;
#endif #endif
#ifdef MA_POSIX #ifdef MA_POSIX
...@@ -40838,10 +40840,14 @@ MA_API ma_result ma_device_post_init(ma_device* pDevice, ma_device_type deviceTy ...@@ -40838,10 +40840,14 @@ MA_API ma_result ma_device_post_init(ma_device* pDevice, ma_device_type deviceTy
static ma_thread_result MA_THREADCALL ma_worker_thread(void* pData) static ma_thread_result MA_THREADCALL ma_worker_thread(void* pData)
{ {
ma_device* pDevice = (ma_device*)pData; ma_device* pDevice = (ma_device*)pData;
#ifdef MA_WIN32
HRESULT CoInitializeResult;
#endif
MA_ASSERT(pDevice != NULL); MA_ASSERT(pDevice != NULL);
#ifdef MA_WIN32 #ifdef MA_WIN32
ma_CoInitializeEx(pDevice->pContext, NULL, MA_COINIT_VALUE); CoInitializeResult = ma_CoInitializeEx(pDevice->pContext, NULL, MA_COINIT_VALUE);
#endif #endif
/* /*
...@@ -40927,7 +40933,9 @@ static ma_thread_result MA_THREADCALL ma_worker_thread(void* pData) ...@@ -40927,7 +40933,9 @@ static ma_thread_result MA_THREADCALL ma_worker_thread(void* pData)
} }
#ifdef MA_WIN32 #ifdef MA_WIN32
if (CoInitializeResult == S_OK) {
ma_CoUninitialize(pDevice->pContext); ma_CoUninitialize(pDevice->pContext);
}
#endif #endif
return (ma_thread_result)0; return (ma_thread_result)0;
...@@ -40950,7 +40958,9 @@ static ma_result ma_context_uninit_backend_apis__win32(ma_context* pContext) ...@@ -40950,7 +40958,9 @@ static ma_result ma_context_uninit_backend_apis__win32(ma_context* pContext)
{ {
/* For some reason UWP complains when CoUninitialize() is called. I'm just not going to call it on UWP. */ /* For some reason UWP complains when CoUninitialize() is called. I'm just not going to call it on UWP. */
#if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK)
if (pContext->win32.CoInitializeResult == S_OK) {
ma_CoUninitialize(pContext); ma_CoUninitialize(pContext);
}
#if defined(MA_WIN32_DESKTOP) #if defined(MA_WIN32_DESKTOP)
ma_dlclose(ma_context_get_log(pContext), pContext->win32.hUser32DLL); ma_dlclose(ma_context_get_log(pContext), pContext->win32.hUser32DLL);
...@@ -41007,7 +41017,7 @@ static ma_result ma_context_init_backend_apis__win32(ma_context* pContext) ...@@ -41007,7 +41017,7 @@ static ma_result ma_context_init_backend_apis__win32(ma_context* pContext)
(void)pContext; /* Unused. */ (void)pContext; /* Unused. */
#endif #endif
ma_CoInitializeEx(pContext, NULL, MA_COINIT_VALUE); pContext->win32.CoInitializeResult = ma_CoInitializeEx(pContext, NULL, MA_COINIT_VALUE);
return MA_SUCCESS; return MA_SUCCESS;
} }
#else #else
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment