mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-12-23 06:11:46 +00:00
[client] x11: prevent possible calibration underflow
This commit is contained in:
parent
a37b527bbd
commit
0603a55492
1 changed files with 19 additions and 6 deletions
|
@ -1175,9 +1175,19 @@ static bool x11WaitFrame(void)
|
||||||
/* every skip we back off the delay */
|
/* every skip we back off the delay */
|
||||||
if (deltamsc > 1)
|
if (deltamsc > 1)
|
||||||
{
|
{
|
||||||
delay -= 100;
|
/* prevent underflow */
|
||||||
calibrate = 1;
|
if (delay - 100 < delay)
|
||||||
deltamsc = 0;
|
{
|
||||||
|
delay -= 100;
|
||||||
|
calibrate = 1;
|
||||||
|
deltamsc = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* if underflow, we are simply too slow, no delay */
|
||||||
|
delay = 0;
|
||||||
|
calibrate = CALIBRATION_COUNT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if we have finished, print out the delay */
|
/* if we have finished, print out the delay */
|
||||||
|
@ -1191,11 +1201,14 @@ static bool x11WaitFrame(void)
|
||||||
lastmsc = msc;
|
lastmsc = msc;
|
||||||
|
|
||||||
/* minor adjustments if we are still seeing odd skips */
|
/* minor adjustments if we are still seeing odd skips */
|
||||||
if (deltamsc > 1)
|
if (deltamsc > 1 && delay - 10 < delay)
|
||||||
delay -= 10;
|
delay -= 10;
|
||||||
|
|
||||||
struct timespec ts = { .tv_nsec = delay * 1000 };
|
if (delay)
|
||||||
while(nanosleep(&ts, &ts)) {};
|
{
|
||||||
|
struct timespec ts = { .tv_nsec = delay * 1000 };
|
||||||
|
while(nanosleep(&ts, &ts)) {};
|
||||||
|
}
|
||||||
|
|
||||||
/* force rendering until we have finished calibration so we can take into
|
/* force rendering until we have finished calibration so we can take into
|
||||||
* account how long it takes for the scene to render */
|
* account how long it takes for the scene to render */
|
||||||
|
|
Loading…
Reference in a new issue