Use CREATE_WAITABLE_TIMER_HIGH_RESOLUTION flag in SDL_Delay on Windows 10 version 1803 and later
This commit is contained in:
committed by
Sam Lantinga
parent
6d5526f3a5
commit
7d5ffbdab7
@@ -146,7 +146,9 @@ SDL_GetPerformanceFrequency(void)
|
|||||||
void
|
void
|
||||||
SDL_Delay(Uint32 ms)
|
SDL_Delay(Uint32 ms)
|
||||||
{
|
{
|
||||||
/* Sleep() is not publicly available to apps in early versions of WinRT.
|
/* CREATE_WAITABLE_TIMER_HIGH_RESOLUTION flag was added in Windows 10 version 1803.
|
||||||
|
*
|
||||||
|
* Sleep() is not publicly available to apps in early versions of WinRT.
|
||||||
*
|
*
|
||||||
* Visual C++ 2013 Update 4 re-introduced Sleep() for Windows 8.1 and
|
* Visual C++ 2013 Update 4 re-introduced Sleep() for Windows 8.1 and
|
||||||
* Windows Phone 8.1.
|
* Windows Phone 8.1.
|
||||||
@@ -158,6 +160,18 @@ SDL_Delay(Uint32 ms)
|
|||||||
* Windows Phone 8.0, uses the Visual C++ 2012 compiler to build
|
* Windows Phone 8.0, uses the Visual C++ 2012 compiler to build
|
||||||
* apps and libraries.
|
* apps and libraries.
|
||||||
*/
|
*/
|
||||||
|
#ifdef CREATE_WAITABLE_TIMER_HIGH_RESOLUTION
|
||||||
|
HANDLE timer = CreateWaitableTimerExW(NULL, NULL, CREATE_WAITABLE_TIMER_HIGH_RESOLUTION, TIMER_ALL_ACCESS);
|
||||||
|
if (timer) {
|
||||||
|
LARGE_INTEGER due_time;
|
||||||
|
due_time.QuadPart = -(LONGLONG)(ms * 10000);
|
||||||
|
if (SetWaitableTimerEx(timer, &due_time, 0, NULL, NULL, NULL, 0)) {
|
||||||
|
WaitForSingleObject(timer, INFINITE);
|
||||||
|
}
|
||||||
|
CloseHandle(timer);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#if defined(__WINRT__) && defined(_MSC_FULL_VER) && (_MSC_FULL_VER <= 180030723)
|
#if defined(__WINRT__) && defined(_MSC_FULL_VER) && (_MSC_FULL_VER <= 180030723)
|
||||||
static HANDLE mutex = 0;
|
static HANDLE mutex = 0;
|
||||||
if (!mutex) {
|
if (!mutex) {
|
||||||
|
|||||||
Reference in New Issue
Block a user