mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-12-22 21:43:40 +00:00
[client] stop the cursorThread if video feed is disabled
The cursorThread prevents the host from going to sleep when the video feed is disabled as it's subscribed to the cursor queue. Stopping the cursorThread will unsubscribe from the queue and allow the host application to disable capture.
This commit is contained in:
parent
24fa580519
commit
e914e56c48
@ -290,6 +290,30 @@ bool core_isValidPointerPos(int x, int y)
|
||||
return g_state.ds->isValidPointerPos(x, y);
|
||||
}
|
||||
|
||||
bool core_startCursorThread(void)
|
||||
{
|
||||
if (g_state.cursorThread)
|
||||
return true;
|
||||
|
||||
g_state.stopVideo = false;
|
||||
if (!lgCreateThread("cursorThread", main_cursorThread, NULL,
|
||||
&g_state.cursorThread))
|
||||
{
|
||||
DEBUG_ERROR("cursor create thread failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void core_stopCursorThread(void)
|
||||
{
|
||||
g_state.stopVideo = true;
|
||||
if (g_state.cursorThread)
|
||||
lgJoinThread(g_state.cursorThread, NULL);
|
||||
|
||||
g_state.cursorThread = NULL;
|
||||
}
|
||||
|
||||
bool core_startFrameThread(void)
|
||||
{
|
||||
if (g_state.frameThread)
|
||||
|
@ -31,6 +31,8 @@ bool core_warpPointer(int x, int y, bool exiting);
|
||||
void core_updatePositionInfo(void);
|
||||
void core_alignToGuest(void);
|
||||
bool core_isValidPointerPos(int x, int y);
|
||||
bool core_startCursorThread(void);
|
||||
void core_stopCursorThread(void);
|
||||
bool core_startFrameThread(void);
|
||||
void core_stopFrameThread(void);
|
||||
void core_handleGuestMouseUpdate(void);
|
||||
|
@ -43,9 +43,15 @@ static void bind_video(int sc, void * opaque)
|
||||
);
|
||||
|
||||
if (g_state.stopVideo)
|
||||
{
|
||||
core_stopCursorThread();
|
||||
core_stopFrameThread();
|
||||
}
|
||||
else
|
||||
{
|
||||
core_startCursorThread();
|
||||
core_startFrameThread();
|
||||
}
|
||||
}
|
||||
|
||||
static void bind_rotate(int sc, void * opaque)
|
||||
|
@ -64,13 +64,11 @@
|
||||
#include "util.h"
|
||||
|
||||
// forwards
|
||||
static int cursorThread(void * unused);
|
||||
static int renderThread(void * unused);
|
||||
|
||||
static LGEvent *e_startup = NULL;
|
||||
static LGThread *t_spice = NULL;
|
||||
static LGThread *t_render = NULL;
|
||||
static LGThread *t_cursor = NULL;
|
||||
|
||||
struct AppState g_state = { 0 };
|
||||
struct CursorState g_cursor;
|
||||
@ -292,9 +290,7 @@ static int renderThread(void * unused)
|
||||
|
||||
lgTimerDestroy(fpsTimer);
|
||||
|
||||
if (t_cursor)
|
||||
lgJoinThread(t_cursor, NULL);
|
||||
|
||||
core_stopCursorThread();
|
||||
core_stopFrameThread();
|
||||
|
||||
RENDERER(deinitialize);
|
||||
@ -304,7 +300,7 @@ static int renderThread(void * unused)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cursorThread(void * unused)
|
||||
int main_cursorThread(void * unused)
|
||||
{
|
||||
LGMP_STATUS status;
|
||||
LG_RendererCursor cursorType = LG_CURSOR_COLOR;
|
||||
@ -330,7 +326,7 @@ static int cursorThread(void * unused)
|
||||
break;
|
||||
}
|
||||
|
||||
while(g_state.state == APP_STATE_RUNNING)
|
||||
while(g_state.state == APP_STATE_RUNNING && !g_state.stopVideo)
|
||||
{
|
||||
LGMPMessage msg;
|
||||
if ((status = lgmpClientProcess(g_state.pointerQueue, &msg)) != LGMP_OK)
|
||||
@ -1156,13 +1152,7 @@ restart:
|
||||
|
||||
g_state.kvmfrFeatures = udata->features;
|
||||
|
||||
if (!lgCreateThread("cursorThread", cursorThread, NULL, &t_cursor))
|
||||
{
|
||||
DEBUG_ERROR("cursor create thread failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!core_startFrameThread())
|
||||
if (!core_startCursorThread() || !core_startFrameThread())
|
||||
return -1;
|
||||
|
||||
while(g_state.state == APP_STATE_RUNNING)
|
||||
@ -1181,9 +1171,7 @@ restart:
|
||||
lgSignalEvent(g_state.frameEvent);
|
||||
|
||||
core_stopFrameThread();
|
||||
|
||||
lgJoinThread(t_cursor, NULL);
|
||||
t_cursor = NULL;
|
||||
core_stopCursorThread();
|
||||
|
||||
lgInit();
|
||||
|
||||
|
@ -110,6 +110,7 @@ struct AppState
|
||||
PLGMPClientQueue pointerQueue;
|
||||
KVMFRFeatureFlags kvmfrFeatures;
|
||||
|
||||
LGThread * cursorThread;
|
||||
LGThread * frameThread;
|
||||
LGEvent * frameEvent;
|
||||
atomic_bool invalidateWindow;
|
||||
@ -287,6 +288,7 @@ extern struct AppState g_state;
|
||||
extern struct CursorState g_cursor;
|
||||
extern struct AppParams g_params;
|
||||
|
||||
int main_cursorThread(void * unused);
|
||||
int main_frameThread(void * unused);
|
||||
|
||||
#define RENDERER(fn, ...) g_state.lgr->ops.fn(g_state.lgr, ##__VA_ARGS__)
|
||||
|
Loading…
Reference in New Issue
Block a user