faudio: Import upstream release 22.01.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2022-01-20 11:18:11 +01:00
parent 879ccd3357
commit bf527c001a
2 changed files with 50 additions and 2 deletions

View File

@ -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 ( \

View File

@ -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);