From ba31c7841205fa3b3c9e0a13946506197d8c0bd2 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Thu, 2 Jan 2020 23:59:06 +1100 Subject: [PATCH] [client] switch from SDL_Thread to lgThread --- VERSION | 2 +- client/src/main.c | 28 +++++++++++++----------- client/src/main.h | 2 -- common/src/platform/linux/CMakeLists.txt | 2 ++ 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/VERSION b/VERSION index 06cfe81a..9453a16b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -B1-41-g0c6ff6822d+1 \ No newline at end of file +B1-42-g1c1d2a0568+1 \ No newline at end of file diff --git a/client/src/main.c b/client/src/main.c index 155d1cc4..c8ff72aa 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -39,6 +39,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include "common/crash.h" #include "common/KVMFR.h" #include "common/stringutils.h" +#include "common/thread.h" #include "utils.h" #include "kb.h" #include "ll.h" @@ -52,10 +53,11 @@ static bool b_startup = false; static SDL_mutex *m_startup; static SDL_cond *c_startup; -static SDL_Thread *t_spice = NULL; -static SDL_Thread *t_render = NULL; -static SDL_Thread *t_cursor = NULL; -static SDL_Cursor *cursor = NULL; +static LGThread *t_spice = NULL; +static LGThread *t_render = NULL; +static LGThread *t_cursor = NULL; +static LGThread *t_frame = NULL; +static SDL_Cursor *cursor = NULL; struct AppState state; @@ -171,10 +173,10 @@ static int renderThread(void * unused) state.running = false; if (t_cursor) - SDL_WaitThread(t_cursor, NULL); + lgJoinThread(t_cursor, NULL); - if (state.t_frame) - SDL_WaitThread(state.t_frame, NULL); + if (t_frame) + lgJoinThread(t_frame, NULL); state.lgr->deinitialize(state.lgrData); state.lgr = NULL; @@ -1107,7 +1109,7 @@ static int lg_run() return -1; } - if (!(t_spice = SDL_CreateThread(spiceThread, "spiceThread", NULL))) + if (!lgCreateThread("spiceThread", spiceThread, NULL, &t_spice)) { DEBUG_ERROR("spice create thread failed"); return -1; @@ -1271,7 +1273,7 @@ static int lg_run() c_startup = SDL_CreateCond(); // start the renderThread so we don't just display junk - if (!(t_render = SDL_CreateThread(renderThread, "renderThread", NULL))) + if (!lgCreateThread("renderThread", renderThread, NULL, &t_render)) { DEBUG_ERROR("render create thread failed"); return -1; @@ -1309,13 +1311,13 @@ static int lg_run() return -1; } - if (!(t_cursor = SDL_CreateThread(cursorThread, "cursorThread", NULL))) + if (!lgCreateThread("cursorThread", cursorThread, NULL, &t_cursor)) { DEBUG_ERROR("cursor create thread failed"); return 1; } - if (!(state.t_frame = SDL_CreateThread(frameThread, "frameThread", NULL))) + if (!lgCreateThread("frameThread", frameThread, NULL, &t_frame)) { DEBUG_ERROR("frame create thread failed"); return -1; @@ -1357,7 +1359,7 @@ static void lg_shutdown() state.running = false; if (t_render) - SDL_WaitThread(t_render, NULL); + lgJoinThread(t_render, NULL); if (m_startup) { @@ -1379,7 +1381,7 @@ static void lg_shutdown() } if (t_spice) - SDL_WaitThread(t_spice, NULL); + lgJoinThread(t_spice, NULL); spice_disconnect(); } diff --git a/client/src/main.h b/client/src/main.h index 276c9d41..1a9d742a 100644 --- a/client/src/main.h +++ b/client/src/main.h @@ -49,8 +49,6 @@ struct AppState void * lgrData; bool lgrResize; - SDL_Thread * t_frame; - const LG_Clipboard * lgc; SpiceDataType cbType; struct ll * cbRequestList; diff --git a/common/src/platform/linux/CMakeLists.txt b/common/src/platform/linux/CMakeLists.txt index 51128e44..81cd4aca 100644 --- a/common/src/platform/linux/CMakeLists.txt +++ b/common/src/platform/linux/CMakeLists.txt @@ -15,3 +15,5 @@ add_library(lg_common_platform_code STATIC if(ENABLE_BACKTRACE) target_link_libraries(lg_common_platform_code bfd) endif() + +target_link_libraries(lg_common_platform_code pthread)