From 3b47a4113fa13a1579bcc96e582536a524f3045b Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Thu, 21 May 2020 09:28:41 +1000 Subject: [PATCH] [client/obs] update to use new LGMP init api --- VERSION | 2 +- client/src/main.c | 65 +++++++++++++++++++++++++---------------------- obs/lg.c | 8 ++++-- repos/LGMP | 2 +- 4 files changed, 43 insertions(+), 34 deletions(-) diff --git a/VERSION b/VERSION index ace886c6..03ceb7b6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -B1-200-gf8ff3faf78+1 \ No newline at end of file +B1-201-ga6d6a49f82+1 \ No newline at end of file diff --git a/client/src/main.c b/client/src/main.c index 6157ba53..650e8693 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -1451,43 +1451,49 @@ static int lg_run() lgWaitEvent(e_startup, TIMEOUT_INFINITE); LGMP_STATUS status; - uint32_t udataSize; - KVMFR *udata; - int waitCount = 0; while(state.running) { - if ((status = lgmpClientInit(state.shm.mem, state.shm.size, &state.lgmp, - &udataSize, (uint8_t **)&udata)) == LGMP_OK) + if ((status = lgmpClientInit(state.shm.mem, state.shm.size, &state.lgmp)) == LGMP_OK) break; - if (status == LGMP_ERR_INVALID_SESSION || status == LGMP_ERR_INVALID_MAGIC) - { - if (waitCount++ == 0) - { - DEBUG_BREAK(); - DEBUG_INFO("The host application seems to not be running"); - DEBUG_INFO("Waiting for the host application to start..."); - } - - if (waitCount == 30) - { - DEBUG_BREAK(); - DEBUG_INFO("Please check the host application is running and is the correct version"); - DEBUG_INFO("Check the host log in your guest at %%TEMP%%\\looking-glass-host.txt"); - DEBUG_INFO("Continuing to wait..."); - } - - if (status == LGMP_ERR_INVALID_SESSION) - SDL_WaitEventTimeout(NULL, 1000); - - continue; - } - DEBUG_ERROR("lgmpClientInit Failed: %s", lgmpStatusString(status)); return -1; } + uint32_t udataSize; + KVMFR *udata; + + int waitCount = 0; + while(state.running) + { + if ((status = lgmpClientSessionInit(state.lgmp, &udataSize, (uint8_t **)&udata)) == LGMP_OK) + break; + + if (status != LGMP_ERR_INVALID_SESSION && status != LGMP_ERR_INVALID_MAGIC) + { + DEBUG_ERROR("lgmpClientSessionInit Failed: %s", lgmpStatusString(status)); + return -1; + } + + if (waitCount++ == 0) + { + DEBUG_BREAK(); + DEBUG_INFO("The host application seems to not be running"); + DEBUG_INFO("Waiting for the host application to start..."); + } + + if (waitCount == 30) + { + DEBUG_BREAK(); + DEBUG_INFO("Please check the host application is running and is the correct version"); + DEBUG_INFO("Check the host log in your guest at %%TEMP%%\\looking-glass-host.txt"); + DEBUG_INFO("Continuing to wait..."); + } + + SDL_WaitEventTimeout(NULL, 1000); + } + if (!state.running) return -1; @@ -1519,13 +1525,12 @@ static int lg_run() while(state.running) { - SDL_WaitEventTimeout(NULL, 1000); - if (!lgmpClientSessionValid(state.lgmp)) { DEBUG_WARN("Session is invalid, has the host shutdown?"); break; } + SDL_WaitEventTimeout(NULL, 1000); } return 0; diff --git a/obs/lg.c b/obs/lg.c index 7308cf70..dcb37506 100644 --- a/obs/lg.c +++ b/obs/lg.c @@ -171,8 +171,12 @@ static void lgUpdate(void * data, obs_data_t * settings) uint32_t udataSize; KVMFR * udata; - if (lgmpClientInit(this->shmDev.mem, this->shmDev.size, &this->lgmp, - &udataSize, (uint8_t **)&udata) != LGMP_OK) + if (lgmpClientInit(this->shmDev.mem, this->shmDev.size, &this->lgmp) + != LGMP_OK) + return; + + if (lgmpClientSessionInit(this->lgmp, &udataSize, (uint8_t **)&udata) + != LGMP_OK) return; if (udataSize != sizeof(KVMFR) || diff --git a/repos/LGMP b/repos/LGMP index 520350a8..19efde39 160000 --- a/repos/LGMP +++ b/repos/LGMP @@ -1 +1 @@ -Subproject commit 520350a8af533a8ef307da13fa95a19d5ae78762 +Subproject commit 19efde39f6f2d50799aabec55ca8260360711a42