mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-12-22 22:01:46 +00:00
[host] app: improve throttleFPS logic
This commit is contained in:
parent
20b5957999
commit
875242fe15
1 changed files with 7 additions and 6 deletions
|
@ -901,19 +901,20 @@ int app_main(int argc, char * argv[])
|
||||||
LG_UNLOCK(app.pointerLock);
|
LG_UNLOCK(app.pointerLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint64_t now = microtime();
|
const uint64_t delta = microtime() - previousFrameTime;
|
||||||
const uint64_t delta = now - previousFrameTime;
|
|
||||||
if (delta < throttleUs)
|
if (delta < throttleUs)
|
||||||
{
|
{
|
||||||
nsleep((throttleUs - delta) * 1000);
|
const uint64_t us = throttleUs - delta;
|
||||||
previousFrameTime = microtime();
|
// only delay if the time is reasonable
|
||||||
|
if (us > 1000)
|
||||||
|
nsleep(us * 1000);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
previousFrameTime = now;
|
|
||||||
|
|
||||||
|
const uint64_t captureStart = microtime();
|
||||||
switch(iface->capture())
|
switch(iface->capture())
|
||||||
{
|
{
|
||||||
case CAPTURE_RESULT_OK:
|
case CAPTURE_RESULT_OK:
|
||||||
|
previousFrameTime = captureStart;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CAPTURE_RESULT_TIMEOUT:
|
case CAPTURE_RESULT_TIMEOUT:
|
||||||
|
|
Loading…
Reference in a new issue