From 96dcf40c79ffcc9c4d38268efe8d8f0e978b7316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 20 Jan 2024 23:33:21 +0100 Subject: [PATCH] Throw in some sanity checks of usleep --- Core/HLE/sceDisplay.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Core/HLE/sceDisplay.cpp b/Core/HLE/sceDisplay.cpp index 38e877810aa9..d636a9b12abc 100644 --- a/Core/HLE/sceDisplay.cpp +++ b/Core/HLE/sceDisplay.cpp @@ -484,7 +484,9 @@ static void DoFrameIdleTiming() { sleep_ms(1); #else const double left = goal - cur_time; - usleep((long)(left * 1000000)); + if (left > 0.0f && left < 1.0f) { // Sanity check + usleep((long)(left * 1000000)); + } #endif } @@ -743,7 +745,9 @@ void hleLagSync(u64 userdata, int cyclesLate) { // Tight loop on win32 - intentionally, as timing is otherwise not precise enough. #ifndef _WIN32 const double left = goal - now; - usleep((long)(left * 1000000.0)); + if (left > 0.0f && left < 1.0f) { // Sanity check + usleep((long)(left * 1000000.0)); + } #else yield(); #endif