mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-12-22 22:01:46 +00:00
[host] correct reinit logic when LGMP corruption is detected
This commit is contained in:
parent
9b202d5566
commit
6f39434bdc
1 changed files with 31 additions and 51 deletions
|
@ -326,7 +326,8 @@ bool startThreads(void)
|
|||
bool stopThreads(void)
|
||||
{
|
||||
app.iface->stop();
|
||||
if (app.state != APP_STATE_SHUTDOWN)
|
||||
if (app.state != APP_STATE_SHUTDOWN &&
|
||||
app.state != APP_STATE_REINIT)
|
||||
app.state = APP_STATE_IDLE;
|
||||
|
||||
if (!app.iface->asyncCapture)
|
||||
|
@ -512,6 +513,8 @@ static void lgmpShutdown()
|
|||
for(int i = 0; i < POINTER_SHAPE_BUFFERS; ++i)
|
||||
lgmpHostMemFree(&app.pointerShapeMemory[i]);
|
||||
lgmpHostFree(&app.lgmp);
|
||||
|
||||
app.pointerShapeValid = false;
|
||||
}
|
||||
|
||||
static bool lgmpSetup(struct IVSHMEM * shmDev)
|
||||
|
@ -724,6 +727,17 @@ int app_main(int argc, char * argv[])
|
|||
LG_LOCK_INIT(app.pointerLock);
|
||||
|
||||
while(app.state != APP_STATE_SHUTDOWN)
|
||||
{
|
||||
if (app.state == APP_STATE_REINIT)
|
||||
{
|
||||
DEBUG_INFO("Performing LGMP reinitialization");
|
||||
lgmpShutdown();
|
||||
if (!lgmpSetup(&shmDev))
|
||||
goto fail_lgmp;
|
||||
app.state = APP_STATE_RUNNING;
|
||||
}
|
||||
|
||||
if (app.state == APP_STATE_IDLE)
|
||||
{
|
||||
if(lgmpHostQueueHasSubs(app.pointerQueue) ||
|
||||
lgmpHostQueueHasSubs(app.frameQueue))
|
||||
|
@ -745,46 +759,14 @@ int app_main(int argc, char * argv[])
|
|||
usleep(100000);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
while(app.state != APP_STATE_SHUTDOWN && (
|
||||
lgmpHostQueueHasSubs(app.pointerQueue) ||
|
||||
lgmpHostQueueHasSubs(app.frameQueue)))
|
||||
{
|
||||
if (app.state == APP_STATE_RESTART || app.state == APP_STATE_REINIT)
|
||||
{
|
||||
if (!stopThreads())
|
||||
{
|
||||
exitcode = LG_HOST_EXIT_FAILED;
|
||||
goto fail_threads;
|
||||
}
|
||||
|
||||
if (!captureStop())
|
||||
{
|
||||
exitcode = LG_HOST_EXIT_FAILED;
|
||||
goto fail_capture;
|
||||
}
|
||||
|
||||
if (app.state == APP_STATE_REINIT)
|
||||
{
|
||||
lgmpShutdown();
|
||||
if (!lgmpSetup(&shmDev))
|
||||
goto fail_lgmp;
|
||||
}
|
||||
|
||||
if (!captureStart())
|
||||
{
|
||||
exitcode = LG_HOST_EXIT_FAILED;
|
||||
goto fail_capture;
|
||||
}
|
||||
|
||||
if (!startThreads())
|
||||
{
|
||||
exitcode = LG_HOST_EXIT_FAILED;
|
||||
goto fail_threads;
|
||||
}
|
||||
|
||||
app.state = APP_STATE_RUNNING;
|
||||
}
|
||||
break;
|
||||
|
||||
if (lgmpHostQueueNewSubs(app.pointerQueue) > 0)
|
||||
{
|
||||
|
@ -836,8 +818,6 @@ int app_main(int argc, char * argv[])
|
|||
|
||||
if (app.state != APP_STATE_SHUTDOWN)
|
||||
{
|
||||
DEBUG_INFO("No subscribers, going to sleep...");
|
||||
|
||||
if (!stopThreads())
|
||||
{
|
||||
exitcode = LG_HOST_EXIT_FAILED;
|
||||
|
|
Loading…
Reference in a new issue