mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-10 00:28:20 +00:00
[client] all: use nanosleep instead of usleep for better precision
This commit is contained in:
parent
b0f2a2e39f
commit
2788394631
@ -305,7 +305,20 @@ static int cursorThread(void * unused)
|
||||
lgSignalEvent(e_frame);
|
||||
}
|
||||
|
||||
usleep(params.cursorPollInterval);
|
||||
const struct timespec req =
|
||||
{
|
||||
.tv_sec = 0,
|
||||
.tv_nsec = params.cursorPollInterval * 1000L
|
||||
};
|
||||
|
||||
struct timespec rem;
|
||||
while(nanosleep(&req, &rem) < 0)
|
||||
if (errno != -EINTR)
|
||||
{
|
||||
DEBUG_ERROR("nanosleep failed");
|
||||
break;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -439,7 +452,20 @@ static int frameThread(void * unused)
|
||||
{
|
||||
if (status == LGMP_ERR_QUEUE_EMPTY)
|
||||
{
|
||||
usleep(params.framePollInterval);
|
||||
const struct timespec req =
|
||||
{
|
||||
.tv_sec = 0,
|
||||
.tv_nsec = params.framePollInterval * 1000L
|
||||
};
|
||||
|
||||
struct timespec rem;
|
||||
while(nanosleep(&req, &rem) < 0)
|
||||
if (errno != -EINTR)
|
||||
{
|
||||
DEBUG_ERROR("nanosleep failed");
|
||||
break;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user