From 3d1a32cda83fc121a2635b382559e6bc48bc3713 Mon Sep 17 00:00:00 2001 From: Kubat <mael.martin31@gmail.com> Date: Wed, 27 May 2020 13:38:53 +0200 Subject: [PATCH] player module is working --- src/commands.c | 14 +++++++------- src/module/module_sdl2.c | 3 ++- src/net/listen.c | 2 +- src/reg.c | 4 ++++ 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/commands.c b/src/commands.c index 5a6c19b8..54c7e5b8 100644 --- a/src/commands.c +++ b/src/commands.c @@ -168,7 +168,7 @@ command_next(struct lkt_state *srv) char filepath[PATH_MAX]; if (!database_queue_next(srv->db, filepath)) return false; - return ! MOD_CALL(srv->window_mod, "load_file", filepath); + return ! MOD_CALL(srv->window_mod, "load", filepath); } bool @@ -187,7 +187,7 @@ command_previous(struct lkt_state *srv) char filepath[PATH_MAX]; if (!database_queue_prev(srv->db, filepath)) return false; - return ! MOD_CALL(srv->window_mod, "load_file", filepath); + return ! MOD_CALL(srv->window_mod, "load", filepath); } static inline bool @@ -197,7 +197,7 @@ __play_that_file(struct lkt_state *win, int pos) RETURN_UNLESS(pos, "Invalid argument", false); RETURN_UNLESS(database_queue_play(win->db, (int) pos), "DB error", false); RETURN_UNLESS(database_queue_get_current_file(win->db, filepath), "Can't get current kara", false); - RETURN_IF(MOD_CALL(win->window_mod, "load_file", filepath), "Can't load file", false); + RETURN_IF(MOD_CALL(win->window_mod, "load", filepath), "Can't load file", false); return true; } @@ -215,8 +215,8 @@ command_play(struct lkt_state *srv, char *args[LKT_MESSAGE_ARGS_MAX]) /* Do the actual job here. */ database_queue_stop(srv->db); - RETURN_UNLESS(MOD_CALL(srv->window_mod, "new", srv->queue, srv->db), - "Can't create window", false); + RETURN_IF(MOD_CALL(srv->window_mod, "new", &srv->queue, srv->db), + "Can't create window", false); srv->mpd_idle_events |= MPD_IDLE_PLAYER; return __play_that_file(srv, pos); } @@ -316,7 +316,7 @@ command_delid(struct lkt_state *srv, char *id_str) if (id == (long) uri) { if (database_queue_skip_current(srv->db, filepath)) { - if (MOD_CALL(srv->window_mod, "load_file", filepath)) { + if (MOD_CALL(srv->window_mod, "load", filepath)) { LOG_ERROR("COMMAND", "Failed to skip current kara to delete id %ld", id); return false; } @@ -572,7 +572,7 @@ command_set_pos(struct lkt_state *srv, int index) srv->mpd_idle_events |= MPD_IDLE_PLAYER; RETURN_UNLESS(database_queue_set_current_index(srv->db, index), "Failed to set position in queue", false); RETURN_UNLESS(database_queue_get_current_file(srv->db, filepath), "Failed to get filename", false); - return ! MOD_CALL(srv->window_mod, "load_file", filepath); + return ! MOD_CALL(srv->window_mod, "load", filepath); } bool diff --git a/src/module/module_sdl2.c b/src/module/module_sdl2.c index 718852ba..87ee2638 100644 --- a/src/module/module_sdl2.c +++ b/src/module/module_sdl2.c @@ -419,7 +419,8 @@ module_sdl2_new(struct module_sdl2_window **win, struct queue *queue, arg->args = *win; RETURN_IF(poller_new(&(*win)->self, sdl_thread__, arg), "Failed to launch the SDL thread", false); - } + } else + LOG_DEBUG("WINDOW", "%s", "SDL window already created"); /* Finish */ SDL_SetWindowTitle((SDL_Window *) (*win)->window, "Lektord"); diff --git a/src/net/listen.c b/src/net/listen.c index 18183cbb..49b3e977 100644 --- a/src/net/listen.c +++ b/src/net/listen.c @@ -766,7 +766,7 @@ redo: if (NULL == (string = malloc(PATH_MAX * sizeof(char)))) return; database_queue_skip_current(srv->db, string); - MOD_CALL(srv->window_mod, "load_file", string); + MOD_CALL(srv->window_mod, "load", string); free(string); break; diff --git a/src/reg.c b/src/reg.c index 8d421eea..42192654 100644 --- a/src/reg.c +++ b/src/reg.c @@ -90,6 +90,10 @@ int reg_call(struct module_reg *reg, const char *name, int count, ...) { reg_func func = __reg_func(reg, name); + if (!func) { + LOG_ERROR("REG", "No function named '%s'", name); + return 2; + } va_list va; va_start(va, count); int ret = func(&va); -- GitLab