From e79dff173152d52f56c9dd23781d3c8465360eec Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Tue, 26 Jan 2021 02:22:59 +1000 Subject: [PATCH] System: Use hybrid sleep on Android --- src/core/system.cpp | 37 +++---------------------------------- 1 file changed, 3 insertions(+), 34 deletions(-) diff --git a/src/core/system.cpp b/src/core/system.cpp index 6e797218c..686390c0b 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -39,12 +39,6 @@ #include Log_SetChannel(System); -#ifdef WIN32 -#include "common/windows_headers.h" -#else -#include -#endif - SystemBootParameters::SystemBootParameters() = default; SystemBootParameters::SystemBootParameters(SystemBootParameters&& other) = default; @@ -1391,35 +1385,10 @@ void Throttle() } else if (sleep_time >= MINIMUM_SLEEP_TIME) { -#ifdef WIN32 - static HANDLE throttle_timer; - static bool throttle_timer_created = false; - if (!throttle_timer_created) - { - throttle_timer_created = true; - throttle_timer = CreateWaitableTimer(nullptr, TRUE, nullptr); - if (throttle_timer) - std::atexit([]() { CloseHandle(throttle_timer); }); - else - Log_ErrorPrintf("CreateWaitableTimer() failed, falling back to Sleep()"); - } - - if (throttle_timer) - { - LARGE_INTEGER due_time; - due_time.QuadPart = -static_cast(static_cast(sleep_time) / 100u); - if (SetWaitableTimer(throttle_timer, &due_time, 0, nullptr, nullptr, FALSE)) - WaitForSingleObject(throttle_timer, INFINITE); - else - Log_ErrorPrintf("SetWaitableTimer() failed: %08X", GetLastError()); - } - else - { - Sleep(static_cast(sleep_time / 1000000)); - } +#ifdef __ANDROID__ + Common::Timer::HybridSleep(sleep_time); #else - const struct timespec ts = {0, static_cast(sleep_time)}; - nanosleep(&ts, nullptr); + Common::Timer::NanoSleep(sleep_time); #endif }