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

Solve segfault and always check mpv events

parent b6189d59
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!57Resolve "SDL2 module"
...@@ -36,7 +36,6 @@ struct module_sdl2_window { ...@@ -36,7 +36,6 @@ struct module_sdl2_window {
pthread_mutex_t mtx; pthread_mutex_t mtx;
struct lkt_thread self; struct lkt_thread self;
volatile int launched; volatile int launched;
volatile int mpv_wakeup;
}; };
/* Thread related functions */ /* Thread related functions */
...@@ -48,19 +47,19 @@ sdl_thread__(struct lkt_thread_arg *arg) ...@@ -48,19 +47,19 @@ sdl_thread__(struct lkt_thread_arg *arg)
struct lkt_thread *self = arg->self; struct lkt_thread *self = arg->self;
struct module_sdl2_window *sdl2 = win->window; struct module_sdl2_window *sdl2 = win->window;
SDL_Event event; SDL_Event event;
uint64_t flags, redraw = 0; uint64_t flags;
int w, h; int w, h, redraw = 0;
free(arg); free(arg);
(void) self; (void) self;
RETURN_UNLESS(sdl2 && sdl2->window, "Big nope here, the sdl window pointer is NULL", NULL); RETURN_UNLESS(sdl2 && sdl2->window, "Big nope here, the sdl window pointer is NULL", NULL);
fprintf(stderr, " * Started SDL thread\n"); fprintf(stderr, " * Started SDL thread\n");
loop: loop:
SDL_PollEvent(&event); if (SDL_PollEvent(&event))
sched_yield();
switch (event.type) { switch (event.type) {
case SDL_QUIT: case SDL_QUIT:
sched_yield();
break; break;
case SDL_WINDOWEVENT: case SDL_WINDOWEVENT:
...@@ -92,9 +91,6 @@ loop: ...@@ -92,9 +91,6 @@ loop:
if (flags & MPV_RENDER_UPDATE_FRAME) if (flags & MPV_RENDER_UPDATE_FRAME)
redraw = 1; redraw = 1;
} }
/* Handle mpv events are not done here. */
if (event.type == wakeup_on_mpv_events)
sdl2->mpv_wakeup = 1;
} }
if (redraw) { if (redraw) {
...@@ -336,10 +332,6 @@ module_sdl2_handle_events(struct lkt_win *const win, sqlite3 *db, enum mpd_idle_ ...@@ -336,10 +332,6 @@ module_sdl2_handle_events(struct lkt_win *const win, sqlite3 *db, enum mpd_idle_
{ {
struct module_sdl2_window *sdl2 = win->window; struct module_sdl2_window *sdl2 = win->window;
RETURN_UNLESS(sdl2, "Can't handle events from a NULL window", false); RETURN_UNLESS(sdl2, "Can't handle events from a NULL window", false);
if (sdl2->mpv_wakeup) { return ! lmpv_handle(win, (mpv_handle *) sdl2->mpv, db, mpd_idle_events,
sdl2->mpv_wakeup = 0; (int *) &sdl2->mpv_time_pos, (int *) &sdl2->mpv_duration);
return ! lmpv_handle(win, (mpv_handle *) sdl2->mpv, db, mpd_idle_events,
(int *) &sdl2->mpv_time_pos, (int *) &sdl2->mpv_duration);
} else
return true;
} }
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
void void
lmpv_free(mpv_handle **ctx) lmpv_free(mpv_handle **ctx)
{ {
RETURN_UNLESS(ctx, "Missing mpv ctx", NOTHING); RETURN_UNLESS(ctx && *ctx, "Missing mpv ctx", NOTHING);
static const char *cmd[] = {"quit", NULL}; static const char *cmd[] = {"quit", NULL};
mpv_command(*ctx, cmd); mpv_command(*ctx, cmd);
mpv_destroy(*ctx); mpv_destroy(*ctx);
......
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