[host] app: wait for space in the frame queue

We must always wait for space in the frame queue so that we do not
overwrite memory that is already queued and may be in use by a client.
This commit is contained in:
Geoffrey McRae 2021-07-12 17:30:06 +10:00
parent 7d0b9711bd
commit ce459c24ce

View File

@ -146,6 +146,18 @@ static bool sendFrame(void)
{
CaptureFrame frame = { 0 };
bool repeatFrame = false;
//wait until there is room in the queue
while(app.state == APP_STATE_RUNNING)
if(lgmpHostQueuePending(app.frameQueue) == LGMP_Q_FRAME_LEN)
{
usleep(1);
continue;
}
if (app.state != APP_STATE_RUNNING)
return false;
switch(app.iface->waitFrame(&frame, app.maxFrameSize))
{
case CAPTURE_RESULT_OK:
@ -249,13 +261,6 @@ static int frameThread(void * opaque)
while(app.state == APP_STATE_RUNNING)
{
//wait until there is room in the queue
if(lgmpHostQueuePending(app.frameQueue) == LGMP_Q_FRAME_LEN)
{
usleep(1);
continue;
}
if (!sendFrame())
break;
}