diff --git a/inc/lektor/commands.h b/inc/lektor/commands.h index e23c4b257ef92020fa3e69c76f06c6064296e265..56b7b52043263b9331528e2d15227f5cc5ff8940 100644 --- a/inc/lektor/commands.h +++ b/inc/lektor/commands.h @@ -24,7 +24,7 @@ bool command_previous(volatile sqlite3 *db, struct lkt_win *win, bool command_play (volatile sqlite3 *db, struct lkt_win *win, char *args[LKT_MESSAGE_ARGS_MAX], mpd_idle_flag *watch_mask_ptr); bool command_stop (volatile sqlite3 *db, struct lkt_win *win, mpd_idle_flag *watch_mask_ptr); -bool command_set_pos(volatile sqlite3 *db, struct lkt_win *win, enum mpd_idle_flag *watch_mask_ptr, int index); +bool command_set_pos(volatile sqlite3 *db, struct lkt_win *win, mpd_idle_flag *watch_mask_ptr, int index); /* The queue */ bool command_add (volatile sqlite3 *db, struct lkt_win *win, char *args[LKT_MESSAGE_ARGS_MAX], mpd_idle_flag *watch_mask_ptr); diff --git a/inc/lektor/module/mpv.h b/inc/lektor/module/mpv.h index 4f00195c0683bb54032ec966baed91049df65e90..a05fdaf900d5e2ad7a42de29dfaa929551fe7f87 100644 --- a/inc/lektor/module/mpv.h +++ b/inc/lektor/module/mpv.h @@ -3,6 +3,7 @@ #include <sqlite3.h> #include <mpv/client.h> #include <lektor/net.h> +#include <lektor/common.h> void lmpv_free(mpv_handle **ctx); mpv_handle *lmpv_new(unsigned long int wid); diff --git a/inc/lektor/net.h b/inc/lektor/net.h index 111f38d0ce51b904fdaa6320f6207275b059f58b..fa721922d37e843e5d50cb0c82554779421a5950 100644 --- a/inc/lektor/net.h +++ b/inc/lektor/net.h @@ -89,7 +89,7 @@ void lkt_set_continuation(struct lkt_state *srv, size_t c, int i); /* Get the mask to watch for events for a given client, to be used with the `idle` command. * Return a pointer to the client's mask */ -enum mpd_idle_flag *lkt_client_get_mask(struct lkt_state *srv, size_t c); +mpd_idle_flag *lkt_client_get_mask(struct lkt_state *srv, size_t c); /* Register a client as authentificated. */ bool lkt_client_auth(struct lkt_state *srv, size_t c, bool set_auth); diff --git a/src/commands.c b/src/commands.c index a4a5d3f79701db45d62fb63200561db3aa5d838a..cc53c0c4a97f77739c24b2d270c2a7c276f1cf6b 100644 --- a/src/commands.c +++ b/src/commands.c @@ -383,7 +383,7 @@ command_help(struct lkt_state *srv, size_t c) bool command_idle(struct lkt_state *srv, size_t c, struct lkt_command *cmd) { - enum mpd_idle_flag *clt_mask = lkt_client_get_mask(srv, c); + mpd_idle_flag *clt_mask = lkt_client_get_mask(srv, c); bool once = false; for (size_t i = 0; cmd->args[i]; ++i) { @@ -428,7 +428,7 @@ command_idle(struct lkt_state *srv, size_t c, struct lkt_command *cmd) inline bool command_noidle(struct lkt_state *srv, size_t c) { - enum mpd_idle_flag *clt_mask = lkt_client_get_mask(srv, c); + mpd_idle_flag *clt_mask = lkt_client_get_mask(srv, c); *clt_mask = MPD_IDLE_NONE; return true; } diff --git a/src/module/module_sdl2.c b/src/module/module_sdl2.c index 2432ca9d591188348e67630ebf577fe0cb9b634a..bce1e3b6477a10186a90fa27d08bbe84a9bcdb8c 100644 --- a/src/module/module_sdl2.c +++ b/src/module/module_sdl2.c @@ -39,7 +39,7 @@ struct module_sdl2_window { /* Things from the server */ volatile sqlite3 *db; - volatile enum mpd_idle_flag *mpd_idle_events; + mpd_idle_flag *mpd_idle_events; }; /* Private functions. */ @@ -188,9 +188,8 @@ loop: } if (event.type == wakeup_on_mpv_events) - lmpv_handle((struct lkt_win *) win, (mpv_handle *) sdl2->mpv, (sqlite3 *) sdl2->db, - (enum mpd_idle_flag *) &sdl2->mpd_idle_events, (int *) &sdl2->mpv_time_pos, - (int *) &sdl2->mpv_duration); + lmpv_handle((struct lkt_win *) win, (mpv_handle *) sdl2->mpv, sdl2->db, + sdl2->mpd_idle_events, &sdl2->mpv_time_pos, &sdl2->mpv_duration); } if (redraw) { @@ -346,7 +345,7 @@ module_sdl2_attach(struct lkt_win *const win, void *server) } bool -module_sdl2_handle_events(struct lkt_win *const win, sqlite3 *db, enum mpd_idle_flag *mpd_idle_events) +module_sdl2_handle_events(struct lkt_win *const win, volatile sqlite3 *db, mpd_idle_flag *mpd_idle_events) { UNUSED(win, db, mpd_idle_events); return true; diff --git a/src/module/module_x11.c b/src/module/module_x11.c index bec80557594f741c7df43ad4f07fa5230d75afec..8fd16618577280c9f22cdb50e4e6714c8702bebf 100644 --- a/src/module/module_x11.c +++ b/src/module/module_x11.c @@ -265,11 +265,10 @@ module_x11_get_elapsed(struct lkt_win *const win, int *elapsed_sec) } bool -module_x11_handle_events(struct lkt_win *const win, sqlite3 *db, enum mpd_idle_flag *mpd_idle_events) +module_x11_handle_events(struct lkt_win *const win, volatile sqlite3 *db, mpd_idle_flag *mpd_idle_events) { RETURN_UNLESS(win && win->window, "Invalid arguments", false); struct module_x11_window *xwin = win->window; return lx11_handle(xwin) && - ! lmpv_handle(win, xwin->mpv, db, mpd_idle_events, (int *) &xwin->mpv_time_pos, - (int *) &xwin->mpv_duration); + ! lmpv_handle(win, xwin->mpv, db, mpd_idle_events, &xwin->mpv_time_pos, &xwin->mpv_duration); } diff --git a/src/module/mpv.c b/src/module/mpv.c index 735ba8d91509a97efeef61f41e4e9a62c0b9fc46..2fc401d0166cf1898fc1dd121d341fa5072e7956 100644 --- a/src/module/mpv.c +++ b/src/module/mpv.c @@ -126,8 +126,8 @@ lmpv_toggle_pause(mpv_handle *ctx) } int -lmpv_handle(struct lkt_win *win, mpv_handle *ctx, sqlite3 *db, enum mpd_idle_flag *mpd_idle_events, - int *time_pos, int *time_duration) +lmpv_handle(struct lkt_win *win, mpv_handle *ctx, volatile sqlite3 *db, mpd_idle_flag *mpd_idle_events, + volatile int *time_pos, volatile int *time_duration) { int ao_volume; struct lkt_queue_state state; diff --git a/src/net/listen.c b/src/net/listen.c index 372b307a9d8d7d9d0be5b26638f7878296ed6451..35aa74ed7eef616239504b80e3e1788f73e9f021 100644 --- a/src/net/listen.c +++ b/src/net/listen.c @@ -41,7 +41,7 @@ struct lkt_client { size_t command_list_len; enum lkt_command_list_mode command_list_mode; - enum mpd_idle_flag mpd_idle_watch; + mpd_idle_flag mpd_idle_watch; bool request_close; bool authentificated; @@ -175,26 +175,25 @@ handle_simple_command(struct lkt_state *srv, size_t c, struct lkt_command cmd) err = 0; else if (!strcmp(cmd.name, "next")) - err = !command_next((sqlite3 *) srv->db, &srv->win, (enum mpd_idle_flag *) &srv->mpd_idle_events); + err = !command_next((sqlite3 *) srv->db, &srv->win, &srv->mpd_idle_events); else if (!strcmp(cmd.name, "pause")) - err = !command_pause((sqlite3 *) srv->db, &srv->win, (enum mpd_idle_flag *) &srv->mpd_idle_events); + err = !command_pause((sqlite3 *) srv->db, &srv->win, &srv->mpd_idle_events); else if (!strcmp(cmd.name, "previous")) - err = !command_previous((sqlite3 *) srv->db, &srv->win, (enum mpd_idle_flag *) &srv->mpd_idle_events); + err = !command_previous((sqlite3 *) srv->db, &srv->win, &srv->mpd_idle_events); else if (!strcmp(cmd.name, "play")) - err = ! command_play((sqlite3 *) srv->db, &srv->win, cmd.args, (enum mpd_idle_flag *) &srv->mpd_idle_events); + err = ! command_play((sqlite3 *) srv->db, &srv->win, cmd.args, &srv->mpd_idle_events); else if (!strcmp(cmd.name, "playid")) - err = ! command_playid((sqlite3 *) srv->db, &srv->win, cmd.args, - (enum mpd_idle_flag *) &srv->mpd_idle_events); + err = ! command_playid((sqlite3 *) srv->db, &srv->win, cmd.args, &srv->mpd_idle_events); else if (!strcmp(cmd.name, "stop")) - err = !command_stop((sqlite3 *) srv->db, &srv->win, (enum mpd_idle_flag *) &srv->mpd_idle_events); + err = !command_stop((sqlite3 *) srv->db, &srv->win, &srv->mpd_idle_events); else if (!strcmp(cmd.name, "clear")) - err = !command_clear((sqlite3 *) srv->db, (enum mpd_idle_flag *) &srv->mpd_idle_events); + err = !command_clear((sqlite3 *) srv->db, &srv->mpd_idle_events); else if (!strcmp(cmd.name, "crop")) - err = !command_crop((sqlite3 *) srv->db, (enum mpd_idle_flag *) &srv->mpd_idle_events); + err = !command_crop((sqlite3 *) srv->db, &srv->mpd_idle_events); else if (!strcmp(cmd.name, "moveid")) - err = !command_move((sqlite3 *) srv->db, cmd.args, (enum mpd_idle_flag *) &srv->mpd_idle_events); + err = !command_move((sqlite3 *) srv->db, cmd.args, &srv->mpd_idle_events); else if (!strcmp(cmd.name, "shuffle")) - err = !command_shuffle((sqlite3 *) srv->db, (enum mpd_idle_flag *) &srv->mpd_idle_events); + err = !command_shuffle((sqlite3 *) srv->db, &srv->mpd_idle_events); else if (!strcmp(cmd.name, "playlist") || !strcmp(cmd.name, "playlistinfo")) err = !command_queue_list(srv, c, cmd.args); @@ -216,27 +215,27 @@ handle_simple_command(struct lkt_state *srv, size_t c, struct lkt_command cmd) err = !command_help(srv, c); else if (!strcmp(cmd.name, "add")) - err = !command_add((sqlite3 *) srv->db, &srv->win, cmd.args, (enum mpd_idle_flag *) &srv->mpd_idle_events); + err = !command_add((sqlite3 *) srv->db, &srv->win, cmd.args, &srv->mpd_idle_events); else if (!strcmp(cmd.name, "addid")) - err = !command_addid((sqlite3 *) srv->db, &srv->win, cmd.args, (enum mpd_idle_flag *) &srv->mpd_idle_events); + err = !command_addid((sqlite3 *) srv->db, &srv->win, cmd.args, &srv->mpd_idle_events); else if (!strcmp(cmd.name, "deleteid")) err = ! (cmd.args[0] != NULL && - command_delid((sqlite3 *) srv->db, &srv->win, cmd.args[0], (enum mpd_idle_flag *) &srv->mpd_idle_events)); + command_delid((sqlite3 *) srv->db, &srv->win, cmd.args[0], &srv->mpd_idle_events)); else if (!strcmp(cmd.name, "playlistclear")) - err = ! command_plt_clear((sqlite3 *) srv->db, cmd.args, (enum mpd_idle_flag *) &srv->mpd_idle_events); + err = ! command_plt_clear((sqlite3 *) srv->db, cmd.args, &srv->mpd_idle_events); else if (!strcmp(cmd.name, "rename")) - err = ! command_plt_rename((sqlite3 * ) srv->db, cmd.args, (enum mpd_idle_flag *) &srv->mpd_idle_events); + err = ! command_plt_rename((sqlite3 * ) srv->db, cmd.args, &srv->mpd_idle_events); else if (!strcmp(cmd.name, "playlistdelete")) - err = ! command_plt_remove((sqlite3 *) srv->db, cmd.args, (enum mpd_idle_flag *) &srv->mpd_idle_events); + err = ! command_plt_remove((sqlite3 *) srv->db, cmd.args, &srv->mpd_idle_events); else if (!strcmp(cmd.name, "playlistadd")) - err = ! command_plt_add((sqlite3 *) srv->db, cmd.args, (enum mpd_idle_flag *) &srv->mpd_idle_events); + err = ! command_plt_add((sqlite3 *) srv->db, cmd.args, &srv->mpd_idle_events); else if (!strcmp(cmd.name, "rm") && cmd.args[0] != NULL && cmd.args[1] == NULL) - err = ! command_plt_remove((sqlite3 *) srv->db, cmd.args, (enum mpd_idle_flag *) &srv->mpd_idle_events); + err = ! command_plt_remove((sqlite3 *) srv->db, cmd.args, &srv->mpd_idle_events); else if (!strcmp(cmd.name, "save")) - err = ! command_plt_export((sqlite3 *) srv->db, cmd.args, (enum mpd_idle_flag *) &srv->mpd_idle_events); + err = ! command_plt_export((sqlite3 *) srv->db, cmd.args, &srv->mpd_idle_events); else if (!strcmp(cmd.name, "__import")) - err = ! command_plt_import((sqlite3 *) srv->db, cmd.args, (enum mpd_idle_flag *) &srv->mpd_idle_events); + err = ! command_plt_import((sqlite3 *) srv->db, cmd.args, &srv->mpd_idle_events); else if (!strcmp(cmd.name, "random")) err = !command_set_playback_option(srv, c, lkt_playback_option_random, cmd.args); @@ -611,7 +610,7 @@ handle_idle_events(struct lkt_state *srv) { struct lkt_client *current_client; struct lkt_message *msg; - enum mpd_idle_flag common_mask; + mpd_idle_flag common_mask; bool once = false; // No new events @@ -674,8 +673,9 @@ handle_idle_events(struct lkt_state *srv) return 0; } -enum mpd_idle_flag * -lkt_client_get_mask(struct lkt_state *srv, size_t c) { +mpd_idle_flag * +lkt_client_get_mask(struct lkt_state *srv, size_t c) +{ return &(srv->clients[c - 1].mpd_idle_watch); }