[client] only resync the timer if we got an early frame

This prevents a slow update (ie, 30ups) from pulling the refresh rate
below the minimum (ie, 60fps).
This commit is contained in:
Geoffrey McRae 2020-08-20 15:18:45 +10:00
parent 5c912e3c27
commit f9b6dcc986
2 changed files with 8 additions and 4 deletions

View File

@ -1 +1 @@
B2-rc4-6-g7e362050f7+1 B2-rc4-7-g5c912e3c27+1

View File

@ -213,12 +213,16 @@ static int renderThread(void * unused)
if (atomic_fetch_sub_explicit(&a_framesPending, 1, memory_order_release) > 1) if (atomic_fetch_sub_explicit(&a_framesPending, 1, memory_order_release) > 1)
continue; continue;
if (lgWaitEventAbs(e_frame, &time)) if (lgWaitEventAbs(e_frame, &time) && state.frameTime > 0)
{ {
if (state.frameTime > 0) /* only resync the timer if we got an early frame */
struct timespec now, diff;
clock_gettime(CLOCK_REALTIME, &now);
tsDiff(&diff, &now, &time);
if (diff.tv_sec == 0 && diff.tv_nsec < state.frameTime)
{ {
resyncCheck = 0; resyncCheck = 0;
clock_gettime(CLOCK_REALTIME, &time); memcpy(&time, &now, sizeof(struct timespec));
tsAdd(&time, state.frameTime); tsAdd(&time, state.frameTime);
} }
} }