[c-host] don't hog CPU resources if queues are full

This commit is contained in:
Geoffrey McRae 2020-01-28 03:58:28 +11:00
parent 29e5f193f0
commit 228f5bfdff

View File

@ -117,6 +117,13 @@ static int frameThread(void * opaque)
while(app.running)
{
//wait until there is room in the queue
if(lgmpHostQueuePending(app.frameQueue) == LGMP_Q_FRAME_LEN)
{
usleep(1);
continue;
}
switch(app.iface->waitFrame(&frame))
{
case CAPTURE_RESULT_OK:
@ -149,13 +156,6 @@ static int frameThread(void * opaque)
}
}
//wait until there is room in the queue
if (lgmpHostQueuePending(app.frameQueue) == LGMP_Q_FRAME_LEN)
{
if (!app.running)
break;
}
LGMP_STATUS status;
// if we are repeating a frame just send the last frame again
@ -364,7 +364,10 @@ void capturePostPointerBuffer(CapturePointer pointer)
while ((status = lgmpHostQueuePost(app.pointerQueue, flags, mem)) != LGMP_OK)
{
if (status == LGMP_ERR_QUEUE_FULL)
{
usleep(1);
continue;
}
DEBUG_ERROR("lgmpHostQueuePost Failed (Pointer): %s", lgmpStatusString(status));
return;