Replace delay by deadline in timedwait()

The function sc_cond_timedwait() accepted a parameter representing the
max duration to wait, because it internally uses SDL_CondWaitTimeout().

Instead, accept a deadline, to be consistent with
pthread_cond_timedwait().
This commit is contained in:
Romain Vimont
2021-07-04 17:04:20 +02:00
parent ec871dd3f5
commit 32e692d5d2
4 changed files with 8 additions and 9 deletions

View File

@@ -84,11 +84,9 @@ run_fps_counter(void *data) {
sc_tick now = sc_tick_now();
check_interval_expired(counter, now);
assert(counter->next_timestamp > now);
sc_tick remaining = counter->next_timestamp - now;
// ignore the reason (timeout or signaled), we just loop anyway
sc_cond_timedwait(&counter->state_cond, &counter->mutex, remaining);
sc_cond_timedwait(&counter->state_cond, &counter->mutex,
counter->next_timestamp);
}
}
sc_mutex_unlock(&counter->mutex);