Module: wine Branch: master Commit: bf527c001a7cadc91667c33053ced7fe0aad7dec URL: https://source.winehq.org/git/wine.git/?a=commit;h=bf527c001a7cadc91667c3305...
Author: Alexandre Julliard julliard@winehq.org Date: Thu Jan 20 11:18:11 2022 +0100
faudio: Import upstream release 22.01.
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
libs/faudio/include/FAudio.h | 4 +-- libs/faudio/src/FAudio_platform_win32.c | 48 +++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-)
diff --git a/libs/faudio/include/FAudio.h b/libs/faudio/include/FAudio.h index 6f68013d79f..28fa62c4fc5 100644 --- a/libs/faudio/include/FAudio.h +++ b/libs/faudio/include/FAudio.h @@ -484,8 +484,8 @@ extern FAudioGUID DATAFORMAT_SUBTYPE_IEEE_FLOAT; #define FAUDIO_TARGET_VERSION 8 /* Targeting compatibility with XAudio 2.8 */
#define FAUDIO_ABI_VERSION 0 -#define FAUDIO_MAJOR_VERSION 21 -#define FAUDIO_MINOR_VERSION 11 +#define FAUDIO_MAJOR_VERSION 22 +#define FAUDIO_MINOR_VERSION 1 #define FAUDIO_PATCH_VERSION 0
#define FAUDIO_COMPILED_VERSION ( \ diff --git a/libs/faudio/src/FAudio_platform_win32.c b/libs/faudio/src/FAudio_platform_win32.c index d99bae044a4..89101a6cf7a 100644 --- a/libs/faudio/src/FAudio_platform_win32.c +++ b/libs/faudio/src/FAudio_platform_win32.c @@ -70,6 +70,44 @@ void FAudio_Log(char const *msg) OutputDebugStringA(msg); }
+static HMODULE kernelbase = NULL; +static HRESULT (WINAPI *my_SetThreadDescription)(HANDLE, PCWSTR) = NULL; + +static void FAudio_resolve_SetThreadDescription(void) +{ + kernelbase = LoadLibraryA("kernelbase.dll"); + if (!kernelbase) + return; + + my_SetThreadDescription = (HRESULT (WINAPI *)(HANDLE, PCWSTR)) GetProcAddress(kernelbase, "SetThreadDescription"); + if (!my_SetThreadDescription) + { + FreeLibrary(kernelbase); + kernelbase = NULL; + } +} + +static void FAudio_set_thread_name(char const *name) +{ + int ret; + WCHAR *nameW; + + if (!my_SetThreadDescription) + return; + + ret = MultiByteToWideChar(CP_UTF8, 0, name, -1, NULL, 0); + + nameW = FAudio_malloc(ret * sizeof(WCHAR)); + if (!nameW) + return; + + ret = MultiByteToWideChar(CP_UTF8, 0, name, -1, nameW, ret); + if (ret) + my_SetThreadDescription(GetCurrentThread(), nameW); + + FAudio_free(nameW); +} + static HRESULT FAudio_FillAudioClientBuffer( struct FAudioAudioClientThreadArgs *args, IAudioRenderClient *client, @@ -121,6 +159,8 @@ static DWORD WINAPI FAudio_AudioClientThread(void *user) HRESULT hr = S_OK; UINT frames, padding = 0;
+ FAudio_set_thread_name(__func__); + hr = IAudioClient_GetService( args->client, &IID_IAudioRenderClient, @@ -172,6 +212,7 @@ void FAudio_PlatformInit( BOOL has_sse2 = IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE);
FAudio_INTERNAL_InitSIMDFunctions(has_sse2, FALSE); + FAudio_resolve_SetThreadDescription();
FAudio_PlatformAddRef();
@@ -305,6 +346,12 @@ void FAudio_PlatformQuit(void* platformDevice) SetEvent(data->stopEvent); WaitForSingleObject(data->audioThread, INFINITE); if (data->client) IAudioClient_Release(data->client); + if (kernelbase) + { + my_SetThreadDescription = NULL; + FreeLibrary(kernelbase); + kernelbase = NULL; + } FAudio_PlatformRelease(); }
@@ -500,6 +547,7 @@ static DWORD WINAPI FaudioThreadWrapper(void *user) struct FAudioThreadArgs *args = user; DWORD ret;
+ FAudio_set_thread_name(args->name); ret = args->func(args->data);
FAudio_free(args);