mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-12-22 22:01:46 +00:00
[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:
parent
7d0b9711bd
commit
ce459c24ce
1 changed files with 12 additions and 7 deletions
|
@ -146,6 +146,18 @@ static bool sendFrame(void)
|
||||||
{
|
{
|
||||||
CaptureFrame frame = { 0 };
|
CaptureFrame frame = { 0 };
|
||||||
bool repeatFrame = false;
|
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))
|
switch(app.iface->waitFrame(&frame, app.maxFrameSize))
|
||||||
{
|
{
|
||||||
case CAPTURE_RESULT_OK:
|
case CAPTURE_RESULT_OK:
|
||||||
|
@ -249,13 +261,6 @@ static int frameThread(void * opaque)
|
||||||
|
|
||||||
while(app.state == APP_STATE_RUNNING)
|
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())
|
if (!sendFrame())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue