Skip to content
Extraits de code Groupes Projets
Vérifiée Valider ae24013c rédigé par Kubat's avatar Kubat
Parcourir les fichiers

MODULE: If an error occurred in the SDL worker thread we exit because the...

MODULE: If an error occurred in the SDL worker thread we exit because the "new" part of the module will return an error (the errors are now reported)
parent 7b4ad04f
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!166Continue fixes
...@@ -36,7 +36,9 @@ struct module_sdl2_window { ...@@ -36,7 +36,9 @@ struct module_sdl2_window {
/* Thread related */ /* Thread related */
struct poller_thread self; struct poller_thread self;
volatile int launched; /* SDL you sucks */ volatile int launched; /* SDL you sucks */
volatile bool is_in_preparation; /* Inside the MPV & SDL init */
volatile bool has_preparation_failed; /* The init failed */
/* Things from the server */ /* Things from the server */
struct queue *queue; struct queue *queue;
...@@ -303,12 +305,17 @@ static void * ...@@ -303,12 +305,17 @@ static void *
sdl_thread__(struct poller_thread_arg *arg) sdl_thread__(struct poller_thread_arg *arg)
{ {
struct module_sdl2_window *sdl2 = arg->args; struct module_sdl2_window *sdl2 = arg->args;
int redraw = 0;
bool ctrl = false;
sdl2->has_preparation_failed = true; // For now, will be cleared if no goto to end_of_init
SDL_Event event; SDL_Event event;
uint64_t flags; uint64_t flags;
int w, h, redraw = 0; int w, h;
bool ctrl = false;
const Uint8 *state; const Uint8 *state;
free(arg); free(arg);
struct lkt_module module = { struct lkt_module module = {
.handle = NULL, .handle = NULL,
.reg = sdl2_reg, .reg = sdl2_reg,
...@@ -342,7 +349,7 @@ sdl_thread__(struct poller_thread_arg *arg) ...@@ -342,7 +349,7 @@ sdl_thread__(struct poller_thread_arg *arg)
/* Init mpv here */ /* Init mpv here */
RETURN_IF(init_mpv__((mpv_handle **)&sdl2->mpv, sdl2->db), "Failed to init mpv", false); GOTO_IF(init_mpv__((mpv_handle **)&sdl2->mpv, sdl2->db), "Failed to init mpv", end_of_init);
mpv_render_param params[] = { { MPV_RENDER_PARAM_API_TYPE, MPV_RENDER_API_TYPE_OPENGL }, mpv_render_param params[] = { { MPV_RENDER_PARAM_API_TYPE, MPV_RENDER_API_TYPE_OPENGL },
{ MPV_RENDER_PARAM_OPENGL_INIT_PARAMS, { MPV_RENDER_PARAM_OPENGL_INIT_PARAMS,
...@@ -352,11 +359,16 @@ sdl_thread__(struct poller_thread_arg *arg) ...@@ -352,11 +359,16 @@ sdl_thread__(struct poller_thread_arg *arg)
{ MPV_RENDER_PARAM_ADVANCED_CONTROL, &(int){ 1 } }, { MPV_RENDER_PARAM_ADVANCED_CONTROL, &(int){ 1 } },
{ 0 } }; { 0 } };
RETURN_IF(init_mpv_gl__((mpv_handle *)sdl2->mpv, (mpv_render_context **)&sdl2->mpv_gl, params), GOTO_IF(init_mpv_gl__((mpv_handle *)sdl2->mpv, (mpv_render_context **)&sdl2->mpv_gl, params),
"Failed to init mpv_gl", false); "Failed to init mpv_gl", end_of_init);
sdl2->has_preparation_failed = false;
end_of_init:
while (!sdl2->launched) while (!sdl2->launched)
sched_yield(); sched_yield();
sdl2->is_in_preparation = 0;
if (sdl2->has_preparation_failed)
pthread_exit(NULL);
___unset_window_title(sdl2); ___unset_window_title(sdl2);
LOG_INFO("WINDOW", "Started SDL thread"); LOG_INFO("WINDOW", "Started SDL thread");
...@@ -475,9 +487,10 @@ module_sdl2_new(struct module_sdl2_window **win, struct queue *queue, lkt_db *db ...@@ -475,9 +487,10 @@ module_sdl2_new(struct module_sdl2_window **win, struct queue *queue, lkt_db *db
RETURN_UNLESS(*win, "Out of memory", false); RETURN_UNLESS(*win, "Out of memory", false);
memset(*win, 0, sizeof(struct module_sdl2_window)); memset(*win, 0, sizeof(struct module_sdl2_window));
(*win)->queue = queue; (*win)->queue = queue;
(*win)->db = db; (*win)->db = db;
(*win)->set_seek = -1; (*win)->set_seek = -1;
(*win)->is_in_preparation = true;
/* Start the SDL thread */ /* Start the SDL thread */
arg = LKT_ALLOC_STRUCT(poller_thread_arg); arg = LKT_ALLOC_STRUCT(poller_thread_arg);
...@@ -490,7 +503,9 @@ module_sdl2_new(struct module_sdl2_window **win, struct queue *queue, lkt_db *db ...@@ -490,7 +503,9 @@ module_sdl2_new(struct module_sdl2_window **win, struct queue *queue, lkt_db *db
/* Finish */ /* Finish */
SDL_DisableScreenSaver(); SDL_DisableScreenSaver();
(*win)->launched = 1; (*win)->launched = 1;
return true; while ((*win)->is_in_preparation)
sched_yield();
return !((*win)->has_preparation_failed);
} }
static void static void
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter