mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-26 07:17:23 +00:00
[host] correct reinit logic when LGMP corruption is detected
This commit is contained in:
parent
9b202d5566
commit
6f39434bdc
@ -326,7 +326,8 @@ bool startThreads(void)
|
|||||||
bool stopThreads(void)
|
bool stopThreads(void)
|
||||||
{
|
{
|
||||||
app.iface->stop();
|
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;
|
app.state = APP_STATE_IDLE;
|
||||||
|
|
||||||
if (!app.iface->asyncCapture)
|
if (!app.iface->asyncCapture)
|
||||||
@ -512,6 +513,8 @@ static void lgmpShutdown()
|
|||||||
for(int i = 0; i < POINTER_SHAPE_BUFFERS; ++i)
|
for(int i = 0; i < POINTER_SHAPE_BUFFERS; ++i)
|
||||||
lgmpHostMemFree(&app.pointerShapeMemory[i]);
|
lgmpHostMemFree(&app.pointerShapeMemory[i]);
|
||||||
lgmpHostFree(&app.lgmp);
|
lgmpHostFree(&app.lgmp);
|
||||||
|
|
||||||
|
app.pointerShapeValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool lgmpSetup(struct IVSHMEM * shmDev)
|
static bool lgmpSetup(struct IVSHMEM * shmDev)
|
||||||
@ -724,6 +727,17 @@ int app_main(int argc, char * argv[])
|
|||||||
LG_LOCK_INIT(app.pointerLock);
|
LG_LOCK_INIT(app.pointerLock);
|
||||||
|
|
||||||
while(app.state != APP_STATE_SHUTDOWN)
|
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) ||
|
if(lgmpHostQueueHasSubs(app.pointerQueue) ||
|
||||||
lgmpHostQueueHasSubs(app.frameQueue))
|
lgmpHostQueueHasSubs(app.frameQueue))
|
||||||
@ -745,46 +759,14 @@ int app_main(int argc, char * argv[])
|
|||||||
usleep(100000);
|
usleep(100000);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while(app.state != APP_STATE_SHUTDOWN && (
|
while(app.state != APP_STATE_SHUTDOWN && (
|
||||||
lgmpHostQueueHasSubs(app.pointerQueue) ||
|
lgmpHostQueueHasSubs(app.pointerQueue) ||
|
||||||
lgmpHostQueueHasSubs(app.frameQueue)))
|
lgmpHostQueueHasSubs(app.frameQueue)))
|
||||||
{
|
{
|
||||||
if (app.state == APP_STATE_RESTART || app.state == APP_STATE_REINIT)
|
if (app.state == APP_STATE_RESTART || app.state == APP_STATE_REINIT)
|
||||||
{
|
break;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lgmpHostQueueNewSubs(app.pointerQueue) > 0)
|
if (lgmpHostQueueNewSubs(app.pointerQueue) > 0)
|
||||||
{
|
{
|
||||||
@ -836,8 +818,6 @@ int app_main(int argc, char * argv[])
|
|||||||
|
|
||||||
if (app.state != APP_STATE_SHUTDOWN)
|
if (app.state != APP_STATE_SHUTDOWN)
|
||||||
{
|
{
|
||||||
DEBUG_INFO("No subscribers, going to sleep...");
|
|
||||||
|
|
||||||
if (!stopThreads())
|
if (!stopThreads())
|
||||||
{
|
{
|
||||||
exitcode = LG_HOST_EXIT_FAILED;
|
exitcode = LG_HOST_EXIT_FAILED;
|
||||||
|
Loading…
Reference in New Issue
Block a user