mirror of https://github.com/mpv-player/mpv
threads-win32: support UWP in mp_thread_set_name
This commit is contained in:
parent
add2f3c8c9
commit
2ae56e78dd
|
@ -198,18 +198,22 @@ static inline int mp_thread_detach(mp_thread thread)
|
|||
wchar_t *mp_from_utf8(void *talloc_ctx, const char *s);
|
||||
static inline void mp_thread_set_name(const char *name)
|
||||
{
|
||||
HRESULT (WINAPI *pSetThreadDescription)(HANDLE, PCWSTR);
|
||||
#if !HAVE_UWP
|
||||
HMODULE kernel32 = GetModuleHandleW(L"kernel32.dll");
|
||||
if (!kernel32)
|
||||
return;
|
||||
HRESULT (WINAPI *pSetThreadDescription)(HANDLE, PCWSTR) =
|
||||
(void *) GetProcAddress(kernel32, "SetThreadDescription");
|
||||
pSetThreadDescription = (void *) GetProcAddress(kernel32, "SetThreadDescription");
|
||||
if (!pSetThreadDescription)
|
||||
return;
|
||||
#else
|
||||
WINBASEAPI HRESULT WINAPI
|
||||
SetThreadDescription(HANDLE hThread, PCWSTR lpThreadDescription);
|
||||
pSetThreadDescription = &SetThreadDescription;
|
||||
#endif
|
||||
wchar_t *wname = mp_from_utf8(NULL, name);
|
||||
pSetThreadDescription(GetCurrentThread(), wname);
|
||||
talloc_free(wname);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int64_t mp_thread_cpu_time_ns(mp_thread_id thread)
|
||||
|
|
Loading…
Reference in New Issue