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

Take into account events (bug solve ?)

parent 74f2c5a2
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!102Modules
...@@ -28,8 +28,12 @@ enum lkt_event_type { ...@@ -28,8 +28,12 @@ enum lkt_event_type {
lkt_event_skip_current = (1 << 9), // NULL lkt_event_skip_current = (1 << 9), // NULL
}; };
#define lkt_event_play (lkt_event_play_pos | lkt_event_play_file | \ #define lkt_event_play ( lkt_event_play_pos | lkt_event_play_file | \
lkt_event_play_next | lkt_event_play_prev \ lkt_event_play_next | lkt_event_play_prev | \
lkt_event_play_toggle | lkt_event_skip_current \
)
#define lkt_event_prop ( lkt_event_prop_vol | lkt_event_prop_dur | \
lkt_event_prop_time \
) )
typedef struct { typedef struct {
......
...@@ -121,6 +121,7 @@ normal_launch: ...@@ -121,6 +121,7 @@ normal_launch:
if (!env_get(LKT_ENV_RESTART) && autoclear) if (!env_get(LKT_ENV_RESTART) && autoclear)
database_queue_clear(srv.db); database_queue_clear(srv.db);
lkt_queue_make_available(&srv.queue, lkt_event_prop);
RETURN_IF(load_module_by_name(&srv, "player", &srv.win), "Can't load module player", 3); RETURN_IF(load_module_by_name(&srv, "player", &srv.win), "Can't load module player", 3);
RETURN_IF(load_module_by_name(&srv, "repo", &srv.repo), "Can't load module repo", 3); RETURN_IF(load_module_by_name(&srv, "repo", &srv.repo), "Can't load module repo", 3);
......
...@@ -166,7 +166,8 @@ loop: ...@@ -166,7 +166,8 @@ loop:
case SDL_WINDOWEVENT: case SDL_WINDOWEVENT:
if (event.window.event == SDL_WINDOWEVENT_EXPOSED) { if (event.window.event == SDL_WINDOWEVENT_EXPOSED) {
lkt_set_event_available(win->srv, lkt_event_play); lkt_queue_make_available(&win->srv->queue, lkt_event_play);
lkt_queue_make_available(&win->srv->queue, lkt_event_prop);
redraw = 1; redraw = 1;
} }
break; break;
...@@ -206,10 +207,7 @@ loop: ...@@ -206,10 +207,7 @@ loop:
lkt_queue_send(sdl2->queue, lkt_event_play_next, NULL); lkt_queue_send(sdl2->queue, lkt_event_play_next, NULL);
else if (STR_MATCH(event.text.text, "<")) else if (STR_MATCH(event.text.text, "<"))
lkt_queue_send(sdl2->queue, lkt_event_play_prev, NULL); lkt_queue_send(sdl2->queue, lkt_event_play_prev, NULL);
else if (STR_MATCH(event.text.text, "o")) { else if (STR_MATCH(event.text.text, "i")) {
const char *cmd[] = { "show-progress", NULL };
mpv_command_async((mpv_handle *) sdl2->mpv, 0, cmd);
} else if (STR_MATCH(event.text.text, "i")) {
/* /*
struct kara_metadata mdt; struct kara_metadata mdt;
int id; int id;
......
...@@ -44,8 +44,7 @@ void ...@@ -44,8 +44,7 @@ void
lkt_queue_send(struct queue *queue, enum lkt_event_type _type, void *_attr) lkt_queue_send(struct queue *queue, enum lkt_event_type _type, void *_attr)
{ {
pthread_mutex_lock(&queue->lock); pthread_mutex_lock(&queue->lock);
if (!queue) GOTO_UNLESS(queue, "Invalid argument", end)
goto end;
volatile lkt_event *new; volatile lkt_event *new;
if (queue->size == queue->last) { if (queue->size == queue->last) {
...@@ -63,6 +62,9 @@ lkt_queue_send(struct queue *queue, enum lkt_event_type _type, void *_attr) ...@@ -63,6 +62,9 @@ lkt_queue_send(struct queue *queue, enum lkt_event_type _type, void *_attr)
.attr = _attr, .attr = _attr,
}; };
queue->contents[(queue->last)++] = evt; queue->contents[(queue->last)++] = evt;
if (! (_type & queue->available))
LOG_WARN("QUEUE", "The event %d is not available, push it anyway", _type);
end: end:
pthread_mutex_unlock(&queue->lock); pthread_mutex_unlock(&queue->lock);
} }
...@@ -72,13 +74,17 @@ lkt_queue_handle(struct queue *queue) ...@@ -72,13 +74,17 @@ lkt_queue_handle(struct queue *queue)
{ {
pthread_mutex_lock(&queue->lock); pthread_mutex_lock(&queue->lock);
lkt_event ret = {0}; lkt_event ret = {0};
if (!queue || !queue->last)
if (!queue || !queue->last ||
!(queue->contents[0].type & queue->available))
goto end; goto end;
if (! (queue->contents[0].type & queue->available) &&
queue->contents[0].type) {
LOG_WARN("QUEUE", "Event %d is not available", queue->contents[0].type);
goto end;
}
ret = queue->contents[0]; ret = queue->contents[0];
memmove((void *) queue->contents, (void *) (queue->contents + 1), --(queue->last)); memmove((void *) queue->contents, (void *) (queue->contents + 1),
--(queue->last));
end: end:
pthread_mutex_unlock(&queue->lock); pthread_mutex_unlock(&queue->lock);
return ret; return ret;
......
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