[client] all: use nanosleep instead of usleep for better precision

This commit is contained in:
Geoffrey McRae 2021-01-08 08:27:12 +11:00
parent b0f2a2e39f
commit 2788394631

View File

@ -305,7 +305,20 @@ static int cursorThread(void * unused)
lgSignalEvent(e_frame); 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; continue;
} }
@ -439,7 +452,20 @@ static int frameThread(void * unused)
{ {
if (status == LGMP_ERR_QUEUE_EMPTY) 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; continue;
} }