[common/client] platform: make timing waits portable

This commit is contained in:
Geoffrey McRae
2026-09-12 08:13:16 +10:00
parent d045ac6ba7
commit 9c8343df96
18 changed files with 351 additions and 161 deletions

View File

@@ -893,10 +893,7 @@ static int cursorRepaintThread(void * unused)
if (!waitTime)
break;
struct timespec deadlineTime;
clock_gettime(CLOCK_MONOTONIC, &deadlineTime);
tsAdd(&deadlineTime, waitTime);
lgWaitEventAbs(e_cursorRepaint, &deadlineTime);
lgWaitEventDeadline(e_cursorRepaint, deadline);
}
}
@@ -941,8 +938,7 @@ static int renderThread(void * unused)
/* signal to other threads that the renderer is ready */
lgSignalEvent(e_startup);
struct timespec time;
clock_gettime(CLOCK_MONOTONIC, &time);
uint64_t renderDeadline = nanotime();
while(likely(app_getState() != APP_STATE_SHUTDOWN))
{
@@ -994,7 +990,7 @@ static int renderThread(void * unused)
else if (g_params.fpsMin != 0)
{
app_handleRenderEvent(microtime());
lgWaitEventAbs(g_state.frameEvent, &time);
lgWaitEventDeadline(g_state.frameEvent, renderDeadline);
}
bool cursorWake;
@@ -1112,8 +1108,7 @@ static int renderThread(void * unused)
if (!g_state.jitRender && g_params.fpsMin != 0)
{
/* A frame-driven swap also satisfies the minimum render rate. */
clock_gettime(CLOCK_MONOTONIC, &time);
tsAdd(&time, app_overlayNeedsRender() ?
renderDeadline = nanotime() + (app_overlayNeedsRender() ?
g_state.overlayFrameTime : g_state.frameTime);
}

View File

@@ -29,6 +29,7 @@
#include "common/debug.h"
#include "common/stringutils.h"
#include "common/time.h"
#include "common/util.h"
#include "overlay_utils.h"
#include <math.h>

View File

@@ -28,6 +28,7 @@
#include "common/debug.h"
#include "common/locking.h"
#include "common/util.h"
#include "main.h"
typedef struct RenderCommand

View File

@@ -24,6 +24,7 @@
#include "common/event.h"
#include "common/ringbuffer.h"
#include "common/time.h"
#include "common/util.h"
#include <usbredirparser.h>