Merge pull request #7849 from krzys-h/fix-7842

Fix the taskbar extension not initializing properly
This commit is contained in:
Twinaphex 2019-01-02 02:34:19 +01:00 committed by GitHub
commit 8f2fa4527c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 2 deletions

View File

@ -201,9 +201,12 @@ static xaudio2_t *xaudio2_new(unsigned samplerate, unsigned channels,
{
xaudio2_t *handle = NULL;
WAVEFORMATEX wfx = {0};
HRESULT hr;
#ifndef _XBOX
CoInitializeEx(0, COINIT_MULTITHREADED);
hr = CoInitialize(NULL);
if (FAILED(hr))
return NULL;
#endif
#if defined(__cplusplus) && !defined(CINTERFACE)
@ -255,6 +258,9 @@ static xaudio2_t *xaudio2_new(unsigned samplerate, unsigned channels,
error:
xaudio2_free(handle);
#ifndef _XBOX
CoUninitialize();
#endif
return NULL;
}
@ -404,6 +410,10 @@ static void xa_free(void *data)
if (xa->xa)
xaudio2_free(xa->xa);
free(xa);
#ifndef _XBOX
CoUninitialize();
#endif
}
static size_t xa_write_avail(void *data)

View File

@ -82,6 +82,12 @@ static void* win32_display_server_init(void)
return NULL;
#ifdef HAS_TASKBAR_EXT
if (FAILED(CoInitialize(NULL)))
{
RARCH_ERR("COM initialization failed, ITaskbarList3 disabled\n");
return dispserv;
}
#ifdef __cplusplus
/* When compiling in C++ mode, GUIDs are references instead of pointers */
hr = CoCreateInstance(CLSID_TaskbarList, NULL,
@ -96,6 +102,7 @@ static void* win32_display_server_init(void)
{
g_taskbarList = NULL;
RARCH_ERR("[dispserv]: CoCreateInstance of ITaskbarList3 failed.\n");
CoUninitialize();
}
#endif
@ -115,6 +122,7 @@ static void win32_display_server_destroy(void *data)
{
ITaskbarList3_Release(g_taskbarList);
g_taskbarList = NULL;
CoUninitialize();
}
#endif

View File

@ -98,6 +98,8 @@ void dinput_destroy_context(void)
IDirectInput8_Release(g_dinput_ctx);
g_dinput_ctx = NULL;
CoUninitialize();
}
bool dinput_init_context(void)
@ -105,7 +107,11 @@ bool dinput_init_context(void)
if (g_dinput_ctx)
return true;
CoInitialize(NULL);
if (FAILED(CoInitialize(NULL)))
{
RARCH_ERR("[DINPUT]: Failed to initialize the COM interface\n");
return false;
}
/* Who said we shouldn't have same call signature in a COM API? <_< */
#ifdef __cplusplus
@ -125,6 +131,7 @@ bool dinput_init_context(void)
error:
RARCH_ERR("[DINPUT]: Failed to initialize DirectInput.\n");
CoUninitialize();
return false;
}