Fix handling long wait times on POSIX's I_WaitVBL

usleep only works for sleeping up to one second. The function is also
deprecated and nanosleep should be used instead.
This commit is contained in:
Chris Robinson 2017-05-09 14:04:30 -07:00 committed by Christoph Oelckers
parent fd8613a11e
commit 7ad61a97ed
1 changed files with 6 additions and 1 deletions

View File

@ -113,7 +113,12 @@ void I_WaitVBL (int count)
{
// I_WaitVBL is never used to actually synchronize to the
// vertical blank. Instead, it's used for delay purposes.
usleep (1000000 * count / 70);
struct timespec delay, rem;
delay.tv_sec = count / 70;
/* Avoid overflow. Microsec res should be good enough. */
delay.tv_nsec = (count%70)*1000000/70 * 1000;
while(nanosleep(&delay, &rem) == -1 && errno == EINTR)
delay = rem;
}
//