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
......@@ -37,6 +37,8 @@ struct module_sdl2_window {
/* Thread related */
struct poller_thread self;
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 */
struct queue *queue;
......@@ -303,12 +305,17 @@ static void *
sdl_thread__(struct poller_thread_arg *arg)
{
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;
uint64_t flags;
int w, h, redraw = 0;
bool ctrl = false;
int w, h;
const Uint8 *state;
free(arg);
struct lkt_module module = {
.handle = NULL,
.reg = sdl2_reg,
......@@ -342,7 +349,7 @@ sdl_thread__(struct poller_thread_arg *arg)
/* 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_OPENGL_INIT_PARAMS,
......@@ -352,11 +359,16 @@ sdl_thread__(struct poller_thread_arg *arg)
{ MPV_RENDER_PARAM_ADVANCED_CONTROL, &(int){ 1 } },
{ 0 } };
RETURN_IF(init_mpv_gl__((mpv_handle *)sdl2->mpv, (mpv_render_context **)&sdl2->mpv_gl, params),
"Failed to init mpv_gl", false);
GOTO_IF(init_mpv_gl__((mpv_handle *)sdl2->mpv, (mpv_render_context **)&sdl2->mpv_gl, params),
"Failed to init mpv_gl", end_of_init);
sdl2->has_preparation_failed = false;
end_of_init:
while (!sdl2->launched)
sched_yield();
sdl2->is_in_preparation = 0;
if (sdl2->has_preparation_failed)
pthread_exit(NULL);
___unset_window_title(sdl2);
LOG_INFO("WINDOW", "Started SDL thread");
......@@ -478,6 +490,7 @@ module_sdl2_new(struct module_sdl2_window **win, struct queue *queue, lkt_db *db
(*win)->queue = queue;
(*win)->db = db;
(*win)->set_seek = -1;
(*win)->is_in_preparation = true;
/* Start the SDL thread */
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
/* Finish */
SDL_DisableScreenSaver();
(*win)->launched = 1;
return true;
while ((*win)->is_in_preparation)
sched_yield();
return !((*win)->has_preparation_failed);
}
static void
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter