mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-12-23 14:21:57 +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
|
@ -1174,11 +1174,21 @@ static bool x11WaitFrame(void)
|
||||||
{
|
{
|
||||||
/* every skip we back off the delay */
|
/* every skip we back off the delay */
|
||||||
if (deltamsc > 1)
|
if (deltamsc > 1)
|
||||||
|
{
|
||||||
|
/* prevent underflow */
|
||||||
|
if (delay - 100 < delay)
|
||||||
{
|
{
|
||||||
delay -= 100;
|
delay -= 100;
|
||||||
calibrate = 1;
|
calibrate = 1;
|
||||||
deltamsc = 0;
|
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 */
|
||||||
if (++calibrate == CALIBRATION_COUNT)
|
if (++calibrate == CALIBRATION_COUNT)
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
if (delay)
|
||||||
|
{
|
||||||
struct timespec ts = { .tv_nsec = delay * 1000 };
|
struct timespec ts = { .tv_nsec = delay * 1000 };
|
||||||
while(nanosleep(&ts, &ts)) {};
|
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