mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-10 08:38:20 +00:00
[client] switch from SDL_Cond to LGEvent
This commit is contained in:
parent
ba31c78412
commit
c5baf212c8
@ -40,6 +40,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
#include "common/KVMFR.h"
|
#include "common/KVMFR.h"
|
||||||
#include "common/stringutils.h"
|
#include "common/stringutils.h"
|
||||||
#include "common/thread.h"
|
#include "common/thread.h"
|
||||||
|
#include "common/event.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "kb.h"
|
#include "kb.h"
|
||||||
#include "ll.h"
|
#include "ll.h"
|
||||||
@ -49,10 +50,7 @@ static int cursorThread(void * unused);
|
|||||||
static int renderThread(void * unused);
|
static int renderThread(void * unused);
|
||||||
static int frameThread (void * unused);
|
static int frameThread (void * unused);
|
||||||
|
|
||||||
static bool b_startup = false;
|
static LGEvent *e_startup = NULL;
|
||||||
static SDL_mutex *m_startup;
|
|
||||||
static SDL_cond *c_startup;
|
|
||||||
|
|
||||||
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;
|
static LGThread *t_cursor = NULL;
|
||||||
@ -110,19 +108,12 @@ static int renderThread(void * unused)
|
|||||||
state.running = false;
|
state.running = false;
|
||||||
|
|
||||||
/* unblock threads waiting on the condition */
|
/* unblock threads waiting on the condition */
|
||||||
SDL_LockMutex(m_startup);
|
lgSignalEvent(e_startup);
|
||||||
b_startup = true;
|
|
||||||
SDL_CondSignal(c_startup);
|
|
||||||
SDL_UnlockMutex(m_startup);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* signal to other threads that the renderer is ready */
|
/* signal to other threads that the renderer is ready */
|
||||||
SDL_LockMutex(m_startup);
|
lgSignalEvent(e_startup);
|
||||||
b_startup = true;
|
|
||||||
SDL_CondSignal(c_startup);
|
|
||||||
SDL_UnlockMutex(m_startup);
|
|
||||||
|
|
||||||
struct timespec time;
|
struct timespec time;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &time);
|
clock_gettime(CLOCK_MONOTONIC, &time);
|
||||||
@ -191,11 +182,7 @@ static int cursorThread(void * unused)
|
|||||||
|
|
||||||
memset(&header, 0, sizeof(KVMFRCursor));
|
memset(&header, 0, sizeof(KVMFRCursor));
|
||||||
|
|
||||||
SDL_LockMutex(m_startup);
|
lgWaitEvent(e_startup, TIMEOUT_INFINITE);
|
||||||
while(!b_startup)
|
|
||||||
SDL_CondWait(c_startup, m_startup);
|
|
||||||
SDL_UnlockMutex(m_startup);
|
|
||||||
|
|
||||||
while(state.running)
|
while(state.running)
|
||||||
{
|
{
|
||||||
// poll until we have cursor data
|
// poll until we have cursor data
|
||||||
@ -309,11 +296,7 @@ static int frameThread(void * unused)
|
|||||||
memset(&header, 0, sizeof(struct KVMFRFrame));
|
memset(&header, 0, sizeof(struct KVMFRFrame));
|
||||||
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
|
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
|
||||||
|
|
||||||
SDL_LockMutex(m_startup);
|
lgWaitEvent(e_startup, TIMEOUT_INFINITE);
|
||||||
while(!b_startup)
|
|
||||||
SDL_CondWait(c_startup, m_startup);
|
|
||||||
SDL_UnlockMutex(m_startup);
|
|
||||||
|
|
||||||
while(state.running)
|
while(state.running)
|
||||||
{
|
{
|
||||||
// poll until we have a new frame
|
// poll until we have a new frame
|
||||||
@ -1268,9 +1251,11 @@ static int lg_run()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// setup the startup condition
|
// setup the startup condition
|
||||||
b_startup = false;
|
if (!(e_startup = lgCreateEvent(false, 0)))
|
||||||
m_startup = SDL_CreateMutex();
|
{
|
||||||
c_startup = SDL_CreateCond();
|
DEBUG_ERROR("failed to create the startup event");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
// start the renderThread so we don't just display junk
|
// start the renderThread so we don't just display junk
|
||||||
if (!lgCreateThread("renderThread", renderThread, NULL, &t_render))
|
if (!lgCreateThread("renderThread", renderThread, NULL, &t_render))
|
||||||
@ -1361,10 +1346,10 @@ static void lg_shutdown()
|
|||||||
if (t_render)
|
if (t_render)
|
||||||
lgJoinThread(t_render, NULL);
|
lgJoinThread(t_render, NULL);
|
||||||
|
|
||||||
if (m_startup)
|
if (e_startup)
|
||||||
{
|
{
|
||||||
SDL_DestroyCond (c_startup);
|
lgFreeEvent(e_startup);
|
||||||
SDL_DestroyMutex(m_startup);
|
e_startup = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if spice is still connected send key up events for any pressed keys
|
// if spice is still connected send key up events for any pressed keys
|
||||||
|
Loading…
Reference in New Issue
Block a user