mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-07-07 03:59:52 +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);
|
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)
|
bool core_startFrameThread(void)
|
||||||
{
|
{
|
||||||
if (g_state.frameThread)
|
if (g_state.frameThread)
|
||||||
|
@ -31,6 +31,8 @@ bool core_warpPointer(int x, int y, bool exiting);
|
|||||||
void core_updatePositionInfo(void);
|
void core_updatePositionInfo(void);
|
||||||
void core_alignToGuest(void);
|
void core_alignToGuest(void);
|
||||||
bool core_isValidPointerPos(int x, int y);
|
bool core_isValidPointerPos(int x, int y);
|
||||||
|
bool core_startCursorThread(void);
|
||||||
|
void core_stopCursorThread(void);
|
||||||
bool core_startFrameThread(void);
|
bool core_startFrameThread(void);
|
||||||
void core_stopFrameThread(void);
|
void core_stopFrameThread(void);
|
||||||
void core_handleGuestMouseUpdate(void);
|
void core_handleGuestMouseUpdate(void);
|
||||||
|
@ -43,10 +43,16 @@ static void bind_video(int sc, void * opaque)
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (g_state.stopVideo)
|
if (g_state.stopVideo)
|
||||||
|
{
|
||||||
|
core_stopCursorThread();
|
||||||
core_stopFrameThread();
|
core_stopFrameThread();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
core_startCursorThread();
|
||||||
core_startFrameThread();
|
core_startFrameThread();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void bind_rotate(int sc, void * opaque)
|
static void bind_rotate(int sc, void * opaque)
|
||||||
{
|
{
|
||||||
|
@ -64,13 +64,11 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
// forwards
|
// forwards
|
||||||
static int cursorThread(void * unused);
|
|
||||||
static int renderThread(void * unused);
|
static int renderThread(void * unused);
|
||||||
|
|
||||||
static LGEvent *e_startup = NULL;
|
static LGEvent *e_startup = NULL;
|
||||||
static LGThread *t_spice = NULL;
|
static LGThread *t_spice = NULL;
|
||||||
static LGThread *t_render = NULL;
|
static LGThread *t_render = NULL;
|
||||||
static LGThread *t_cursor = NULL;
|
|
||||||
|
|
||||||
struct AppState g_state = { 0 };
|
struct AppState g_state = { 0 };
|
||||||
struct CursorState g_cursor;
|
struct CursorState g_cursor;
|
||||||
@ -292,9 +290,7 @@ static int renderThread(void * unused)
|
|||||||
|
|
||||||
lgTimerDestroy(fpsTimer);
|
lgTimerDestroy(fpsTimer);
|
||||||
|
|
||||||
if (t_cursor)
|
core_stopCursorThread();
|
||||||
lgJoinThread(t_cursor, NULL);
|
|
||||||
|
|
||||||
core_stopFrameThread();
|
core_stopFrameThread();
|
||||||
|
|
||||||
RENDERER(deinitialize);
|
RENDERER(deinitialize);
|
||||||
@ -304,7 +300,7 @@ static int renderThread(void * unused)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cursorThread(void * unused)
|
int main_cursorThread(void * unused)
|
||||||
{
|
{
|
||||||
LGMP_STATUS status;
|
LGMP_STATUS status;
|
||||||
LG_RendererCursor cursorType = LG_CURSOR_COLOR;
|
LG_RendererCursor cursorType = LG_CURSOR_COLOR;
|
||||||
@ -330,7 +326,7 @@ static int cursorThread(void * unused)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(g_state.state == APP_STATE_RUNNING)
|
while(g_state.state == APP_STATE_RUNNING && !g_state.stopVideo)
|
||||||
{
|
{
|
||||||
LGMPMessage msg;
|
LGMPMessage msg;
|
||||||
if ((status = lgmpClientProcess(g_state.pointerQueue, &msg)) != LGMP_OK)
|
if ((status = lgmpClientProcess(g_state.pointerQueue, &msg)) != LGMP_OK)
|
||||||
@ -1156,13 +1152,7 @@ restart:
|
|||||||
|
|
||||||
g_state.kvmfrFeatures = udata->features;
|
g_state.kvmfrFeatures = udata->features;
|
||||||
|
|
||||||
if (!lgCreateThread("cursorThread", cursorThread, NULL, &t_cursor))
|
if (!core_startCursorThread() || !core_startFrameThread())
|
||||||
{
|
|
||||||
DEBUG_ERROR("cursor create thread failed");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!core_startFrameThread())
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
while(g_state.state == APP_STATE_RUNNING)
|
while(g_state.state == APP_STATE_RUNNING)
|
||||||
@ -1181,9 +1171,7 @@ restart:
|
|||||||
lgSignalEvent(g_state.frameEvent);
|
lgSignalEvent(g_state.frameEvent);
|
||||||
|
|
||||||
core_stopFrameThread();
|
core_stopFrameThread();
|
||||||
|
core_stopCursorThread();
|
||||||
lgJoinThread(t_cursor, NULL);
|
|
||||||
t_cursor = NULL;
|
|
||||||
|
|
||||||
lgInit();
|
lgInit();
|
||||||
|
|
||||||
|
@ -110,6 +110,7 @@ struct AppState
|
|||||||
PLGMPClientQueue pointerQueue;
|
PLGMPClientQueue pointerQueue;
|
||||||
KVMFRFeatureFlags kvmfrFeatures;
|
KVMFRFeatureFlags kvmfrFeatures;
|
||||||
|
|
||||||
|
LGThread * cursorThread;
|
||||||
LGThread * frameThread;
|
LGThread * frameThread;
|
||||||
LGEvent * frameEvent;
|
LGEvent * frameEvent;
|
||||||
atomic_bool invalidateWindow;
|
atomic_bool invalidateWindow;
|
||||||
@ -287,6 +288,7 @@ extern struct AppState g_state;
|
|||||||
extern struct CursorState g_cursor;
|
extern struct CursorState g_cursor;
|
||||||
extern struct AppParams g_params;
|
extern struct AppParams g_params;
|
||||||
|
|
||||||
|
int main_cursorThread(void * unused);
|
||||||
int main_frameThread(void * unused);
|
int main_frameThread(void * unused);
|
||||||
|
|
||||||
#define RENDERER(fn, ...) g_state.lgr->ops.fn(g_state.lgr, ##__VA_ARGS__)
|
#define RENDERER(fn, ...) g_state.lgr->ops.fn(g_state.lgr, ##__VA_ARGS__)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user