diff --git a/inc/lektor/commands.h b/inc/lektor/commands.h
index 8ea3e82fbb321e50a1f17a144296a5949fb4f52c..e23c4b257ef92020fa3e69c76f06c6064296e265 100644
--- a/inc/lektor/commands.h
+++ b/inc/lektor/commands.h
@@ -18,36 +18,36 @@ bool command_currentsong(struct lkt_state *srv, size_t c);
 bool command_status     (struct lkt_state *srv, size_t c);
 
 /* Controlling playback */
-bool command_next    (sqlite3 *db, struct lkt_win *win,                                   enum mpd_idle_flag *watch_mask_ptr);
-bool command_pause   (sqlite3 *db, struct lkt_win *win,                                   enum mpd_idle_flag *watch_mask_ptr);
-bool command_previous(sqlite3 *db, struct lkt_win *win,                                   enum mpd_idle_flag *watch_mask_ptr);
-bool command_play    (sqlite3 *db, struct lkt_win *win, char *args[LKT_MESSAGE_ARGS_MAX], enum mpd_idle_flag *watch_mask_ptr);
-bool command_stop    (sqlite3 *db, struct lkt_win *win,                                   enum mpd_idle_flag *watch_mask_ptr);
+bool command_next    (volatile sqlite3 *db, struct lkt_win *win,                                   mpd_idle_flag *watch_mask_ptr);
+bool command_pause   (volatile sqlite3 *db, struct lkt_win *win,                                   mpd_idle_flag *watch_mask_ptr);
+bool command_previous(volatile sqlite3 *db, struct lkt_win *win,                                   mpd_idle_flag *watch_mask_ptr);
+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(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, enum mpd_idle_flag *watch_mask_ptr, int index);
 
 /* The queue */
-bool command_add    (sqlite3 *db, struct lkt_win *win, char *args[LKT_MESSAGE_ARGS_MAX], enum mpd_idle_flag *watch_mask_ptr);
-bool command_addid  (sqlite3 *db, struct lkt_win *win, char *args[LKT_MESSAGE_ARGS_MAX], enum mpd_idle_flag *watch_mask_ptr);
-bool command_del    (sqlite3 *db, struct lkt_win *win, char *pos_range,                  enum mpd_idle_flag *watch_mask_ptr);
-bool command_delid  (sqlite3 *db, struct lkt_win *win, char *id,                         enum mpd_idle_flag *watch_mask_ptr);
-bool command_clear  (sqlite3 *db,                                                        enum mpd_idle_flag *watch_mask_ptr);
-bool command_crop   (sqlite3 *db,                                                        enum mpd_idle_flag *watch_mask_ptr);
-bool command_move   (sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX],                      enum mpd_idle_flag *watch_mask_ptr);
-bool command_shuffle(sqlite3 *db,                                                        enum mpd_idle_flag *watch_mask_ptr);
-bool command_playid (sqlite3 *db, struct lkt_win *win, char *args[LKT_MESSAGE_ARGS_MAX], enum mpd_idle_flag *watch_mask_ptr);
+bool command_add    (volatile sqlite3 *db, struct lkt_win *win, char *args[LKT_MESSAGE_ARGS_MAX], mpd_idle_flag *watch_mask_ptr);
+bool command_addid  (volatile sqlite3 *db, struct lkt_win *win, char *args[LKT_MESSAGE_ARGS_MAX], mpd_idle_flag *watch_mask_ptr);
+bool command_del    (volatile sqlite3 *db, struct lkt_win *win, char *pos_range,                  mpd_idle_flag *watch_mask_ptr);
+bool command_delid  (volatile sqlite3 *db, struct lkt_win *win, char *id,                         mpd_idle_flag *watch_mask_ptr);
+bool command_clear  (volatile sqlite3 *db,                                                        mpd_idle_flag *watch_mask_ptr);
+bool command_crop   (volatile sqlite3 *db,                                                        mpd_idle_flag *watch_mask_ptr);
+bool command_move   (volatile sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX],                      mpd_idle_flag *watch_mask_ptr);
+bool command_shuffle(volatile sqlite3 *db,                                                        mpd_idle_flag *watch_mask_ptr);
+bool command_playid (volatile sqlite3 *db, struct lkt_win *win, char *args[LKT_MESSAGE_ARGS_MAX], mpd_idle_flag *watch_mask_ptr);
 
 bool command_queue_list(struct lkt_state *srv, size_t c, char *args[LKT_MESSAGE_ARGS_MAX]);
 bool command_queue_find(struct lkt_state *srv, size_t c, char *cmd_args[LKT_MESSAGE_ARGS_MAX], long continuation);
 
 /* The playlists */
-bool command_plt_create(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], enum mpd_idle_flag *watch_mask_ptr);
-bool command_plt_remove(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], enum mpd_idle_flag *watch_mask_ptr);
-bool command_plt_clear (sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], enum mpd_idle_flag *watch_mask_ptr);
-bool command_plt_rename(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], enum mpd_idle_flag *watch_mask_ptr);
-bool command_plt_export(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], enum mpd_idle_flag *watch_mask_ptr);
-bool command_plt_import(sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], enum mpd_idle_flag *watch_mask_ptr);
-bool command_plt_add   (sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], enum mpd_idle_flag *watch_mask_ptr);
+bool command_plt_create(volatile sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], mpd_idle_flag *watch_mask_ptr);
+bool command_plt_remove(volatile sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], mpd_idle_flag *watch_mask_ptr);
+bool command_plt_clear (volatile sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], mpd_idle_flag *watch_mask_ptr);
+bool command_plt_rename(volatile sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], mpd_idle_flag *watch_mask_ptr);
+bool command_plt_export(volatile sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], mpd_idle_flag *watch_mask_ptr);
+bool command_plt_import(volatile sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], mpd_idle_flag *watch_mask_ptr);
+bool command_plt_add   (volatile sqlite3 *db, char *args[LKT_MESSAGE_ARGS_MAX], mpd_idle_flag *watch_mask_ptr);
 
 /* The help */
 bool command_help(struct lkt_state *srv, size_t c);
diff --git a/inc/lektor/common.h b/inc/lektor/common.h
index 3495f2519ccaadb965b05807dab896e78c3056c5..ebb7faabb2356896afd2c17fd0c5f8a8b32745e5 100644
--- a/inc/lektor/common.h
+++ b/inc/lektor/common.h
@@ -36,7 +36,7 @@
 #define LKT_MESSAGE_MAX                 2048
 #define LKT_DEFAULT_LIST_SIZE           10
 
-enum mpd_idle_flag {
+typedef volatile enum {
     MPD_IDLE_NONE               = 0,
 
     MPD_IDLE_DATABASE           = ( 1 << 1  ),
@@ -57,7 +57,7 @@ enum mpd_idle_flag {
         MPD_IDLE_PLAYLIST | MPD_IDLE_PLAYER | MPD_IDLE_MIXER            |
         MPD_IDLE_OUTPUT | MPD_IDLE_OPTIONS | MPD_IDLE_PARTITION         |
         MPD_IDLE_STICKER | MPD_IDLE_SUBSCRIPTION | MPD_IDLE_MESSAGE,
-};
+} mpd_idle_flag;
 
 #define LKT_BACKLOG         32
 #define COMMAND_LIST_MAX    64
diff --git a/inc/lektor/config.h b/inc/lektor/config.h
index 618de57c06aacfaf1cb041d704032f1e7dbe7441..323e900ba5c80c9aebe43a449fed2052e33c7bdd 100644
--- a/inc/lektor/config.h
+++ b/inc/lektor/config.h
@@ -50,7 +50,7 @@ static const char *const lkt_default_config_file =
 /* It is just an alias to the consecutive use of config_detect_file and
    config_new function, with the return an '&&' between the two returns of the
    two other functions. */
-int config_open(sqlite3 *db);
+int config_open(volatile sqlite3 *db);
 
 /* Get the path to the config file that may be red, taking into account the
    priority between existing files. The returned path is a path to an existing
@@ -60,9 +60,9 @@ int config_detect_file(char *conf, size_t conf_len);
 /* Create and read the configuration in the conf file and write it into
    lkt_conf. The type is opaque because it's a C++ class.
    Return 0 if the read operation was a success, a non zero value otherwise. */
-int config_new(sqlite3 *db, const char *conf);
+int config_new(volatile sqlite3 *db, const char *conf);
 
 /* Load a module by its name. Also initialize the mod pointer. No check on data
    type is done, it is up to the user to check if the structure passed as a
    `void*` is the right structure. */
-int load_module_by_name(sqlite3 *db, const char *name, void *mod);
+int load_module_by_name(volatile sqlite3 *db, const char *name, void *mod);
diff --git a/inc/lektor/database.h b/inc/lektor/database.h
index f74e2a16332743df3e584b1da30aa229c5bad011..e1bffe157531612952a744378f9b7bff822c5604 100644
--- a/inc/lektor/database.h
+++ b/inc/lektor/database.h
@@ -23,61 +23,61 @@ struct lkt_queue_state {
 };
 
 long database_get_timestamp(volatile sqlite3 *db);
-void database_stamp(volatile sqlite3 *db);
-void database_updated(volatile sqlite3 *db);
+void database_stamp        (volatile sqlite3 *db);
+void database_updated      (volatile sqlite3 *db);
 
 /* Open correctly a database for lektor. */
-bool database_new   (sqlite3 **db);
+bool database_new   (volatile sqlite3 **db);
 bool database_init  (const char *dbpath);
-bool database_open  (sqlite3 *db, const char *dbpath);
-bool database_attach(sqlite3 *db, const char *name, const char *dbpath);
-bool database_detach(sqlite3 *db, const char *name);
+bool database_open  (volatile sqlite3 *db, const char *dbpath);
+bool database_attach(volatile sqlite3 *db, const char *name, const char *dbpath);
+bool database_detach(volatile sqlite3 *db, const char *name);
 
 /* Get information on the queue and currently playing kara. */
-bool database_queue_state       (sqlite3 *db, struct lkt_queue_state *res);
-bool database_queue_current_kara(sqlite3 *db, struct kara_metadata *res, int *id);
+bool database_queue_state       (volatile sqlite3 *db, struct lkt_queue_state *res);
+bool database_queue_current_kara(volatile sqlite3 *db, struct kara_metadata *res, int *id);
 
-bool database_queue_set_paused       (sqlite3 *db, bool paused);
-bool database_queue_set_current_index(sqlite3 *db, int idx);
-bool database_queue_get_current_file (sqlite3 *db, char filepath[PATH_MAX]);
+bool database_queue_set_paused       (volatile sqlite3 *db, bool paused);
+bool database_queue_set_current_index(volatile sqlite3 *db, int idx);
+bool database_queue_get_current_file (volatile sqlite3 *db, char filepath[PATH_MAX]);
 
 /* Mpv and database synchronisation. */
-bool database_sync_mpv_state(sqlite3 *db, mpv_handle **mpv);
+bool database_sync_mpv_state(volatile sqlite3 *db, mpv_handle **mpv);
 
 /* Update the database. */
-bool database_update(volatile sqlite3 *db, const char *kara_dir);
-bool database_update_add(volatile sqlite3 *db, const char *kara_path, struct kara_metadata *mdt, uint64_t id, bool avail);
+bool database_update              (volatile sqlite3 *db, const char *kara_dir);
+bool database_update_add          (volatile sqlite3 *db, const char *kara_path, struct kara_metadata *mdt, uint64_t id, bool avail);
 bool database_update_set_available(volatile sqlite3 *db, uint64_t id);
 
 /* Control the content of the queue. */
-bool database_queue_add_id      (sqlite3 *db, int id,               int priority);
-bool database_queue_add_query   (sqlite3 *db, const char *query,    int priority);
-bool database_queue_add_author  (sqlite3 *db, const char *author,   int priority);
-bool database_queue_add_language(sqlite3 *db, const char *author,   int priority);
-bool database_queue_add_category(sqlite3 *db, const char *author,   int priority);
-bool database_queue_add_type    (sqlite3 *db, const char *author,   int priority);
-bool database_queue_add_plt     (sqlite3 *db, const char *plt_name, int priority);
-
-bool database_queue_insert_query   (sqlite3 *db, const char *query, int pos);
-bool database_queue_insert_id      (sqlite3 *db, int id);
-bool database_queue_insert_author  (sqlite3 *db, const char *author);
-bool database_queue_insert_language(sqlite3 *db, const char *author);
-bool database_queue_insert_category(sqlite3 *db, const char *author);
-bool database_queue_insert_type    (sqlite3 *db, const char *author);
-bool database_queue_insert_plt     (sqlite3 *db, const char *plt_name);
-
-bool database_queue_del_id (sqlite3 *db, int id);
-bool database_queue_del_pos(sqlite3 *db, int pos);
-bool database_queue_clear  (sqlite3 *db);
-bool database_queue_crop   (sqlite3 *db);
-bool database_queue_move   (sqlite3 *db, int from, int to);
-bool database_queue_shuffle(sqlite3 *db);
-bool database_queue_seekid (sqlite3 *db, int id, int *out_pos);
+bool database_queue_add_id      (volatile sqlite3 *db, int id,               int priority);
+bool database_queue_add_query   (volatile sqlite3 *db, const char *query,    int priority);
+bool database_queue_add_author  (volatile sqlite3 *db, const char *author,   int priority);
+bool database_queue_add_language(volatile sqlite3 *db, const char *author,   int priority);
+bool database_queue_add_category(volatile sqlite3 *db, const char *author,   int priority);
+bool database_queue_add_type    (volatile sqlite3 *db, const char *author,   int priority);
+bool database_queue_add_plt     (volatile sqlite3 *db, const char *plt_name, int priority);
+
+bool database_queue_insert_query   (volatile sqlite3 *db, const char *query, int pos);
+bool database_queue_insert_id      (volatile sqlite3 *db, int id);
+bool database_queue_insert_author  (volatile sqlite3 *db, const char *author);
+bool database_queue_insert_language(volatile sqlite3 *db, const char *author);
+bool database_queue_insert_category(volatile sqlite3 *db, const char *author);
+bool database_queue_insert_type    (volatile sqlite3 *db, const char *author);
+bool database_queue_insert_plt     (volatile sqlite3 *db, const char *plt_name);
+
+bool database_queue_del_id (volatile sqlite3 *db, int id);
+bool database_queue_del_pos(volatile sqlite3 *db, int pos);
+bool database_queue_clear  (volatile sqlite3 *db);
+bool database_queue_crop   (volatile sqlite3 *db);
+bool database_queue_move   (volatile sqlite3 *db, int from, int to);
+bool database_queue_shuffle(volatile sqlite3 *db);
+bool database_queue_seekid (volatile sqlite3 *db, int id, int *out_pos);
 
 /* Control the playing state of the queue. */
-bool database_queue_toggle_pause(sqlite3 *db);
-bool database_queue_play        (sqlite3 *db, int pos);
-bool database_queue_stop        (sqlite3 *db);
+bool database_queue_toggle_pause(volatile sqlite3 *db);
+bool database_queue_play        (volatile sqlite3 *db, int pos);
+bool database_queue_stop        (volatile sqlite3 *db);
 
 /* A search callback to be called after each matched row */
 struct lkt_callback {
@@ -88,11 +88,11 @@ struct lkt_callback {
 };
 
 /* List the content of the queue */
-bool database_queue_list(sqlite3 *db, size_t from, size_t to, struct lkt_callback *callback);
+bool database_queue_list(volatile sqlite3 *db, size_t from, size_t to, struct lkt_callback *callback);
 
 /* Search the database */
 struct lkt_search {
-    sqlite3 *db;
+    volatile sqlite3 *db;
     sqlite3_stmt *stmt;
     enum lkt_search_type {
         lkt_search_database,
@@ -109,24 +109,24 @@ struct lkt_search {
 typedef bool (*lkt_search_database_func)(struct lkt_state *srv, size_t c, int id, int id_len,
         const char *row);
 
-bool database_search_database_init(sqlite3 *db, char *col_name, char *rgx, struct lkt_search *ret);
-bool database_search_queue_init   (sqlite3 *db, char *col_name, char *rgx, struct lkt_search *ret);
+bool database_search_database_init(volatile sqlite3 *db, char *col_name, char *rgx, struct lkt_search *ret);
+bool database_search_queue_init   (volatile sqlite3 *db, char *col_name, char *rgx, struct lkt_search *ret);
 bool database_search_iter(struct lkt_search *item);
 
 /* Next and prev operation on the queue. */
-bool database_queue_next(sqlite3 *db, char filepath[PATH_MAX]);
-bool database_queue_prev(sqlite3 *db, char filepath[PATH_MAX]);
+bool database_queue_next(volatile sqlite3 *db, char filepath[PATH_MAX]);
+bool database_queue_prev(volatile sqlite3 *db, char filepath[PATH_MAX]);
 
 /* Set a value in the config table */
-bool database_config_set     (sqlite3 *db, const char *section, const char *key, const char *value);
-bool database_config_get_text(sqlite3 *db, const char *section, const char *key, char *value, size_t len);
-bool database_config_get_int (sqlite3 *db, const char *section, const char *key, int *value);
-bool database_config_exists  (sqlite3 *db, const char *section, const char *key);
-bool database_config_queue   (sqlite3 *db, const char *option,  int value);
-bool database_config_queue_default(sqlite3 *db);
+bool database_config_set     (volatile sqlite3 *db, const char *section, const char *key, const char *value);
+bool database_config_get_text(volatile sqlite3 *db, const char *section, const char *key, char *value, size_t len);
+bool database_config_get_int (volatile sqlite3 *db, const char *section, const char *key, int *value);
+bool database_config_exists  (volatile sqlite3 *db, const char *section, const char *key);
+bool database_config_queue   (volatile sqlite3 *db, const char *option,  int value);
+bool database_config_queue_default(volatile sqlite3 *db);
 
 /* Get a value from the config table */
-bool database_get_config(sqlite3 *db, const char *option, int *value);
+bool database_get_config(volatile sqlite3 *db, const char *option, int *value);
 
 /* Playlists */
 struct lkt_playlist_metadata {
@@ -136,20 +136,20 @@ struct lkt_playlist_metadata {
 };
 
 /* Control playlists */
-bool database_plt_create    (sqlite3 *db, const char *name);
-bool database_plt_remove    (sqlite3 *db, const char *name);
-bool database_plt_remove_pos(sqlite3 *db, const char *name, int pos);
-bool database_plt_clear     (sqlite3 *db, const char *name);
-bool database_plt_rename    (sqlite3 *db, const char *old_name, const char *new_name);
+bool database_plt_create    (volatile sqlite3 *db, const char *name);
+bool database_plt_remove    (volatile sqlite3 *db, const char *name);
+bool database_plt_remove_pos(volatile sqlite3 *db, const char *name, int pos);
+bool database_plt_clear     (volatile sqlite3 *db, const char *name);
+bool database_plt_rename    (volatile sqlite3 *db, const char *old_name, const char *new_name);
 
-bool database_plt_export(sqlite3 *db, const char *name);
-bool database_plt_import(sqlite3 *db, const char *name);
+bool database_plt_export(volatile sqlite3 *db, const char *name);
+bool database_plt_import(volatile sqlite3 *db, const char *name);
 
-bool database_plt_add_uri(sqlite3 *db, const char *name, struct lkt_uri *uri);
+bool database_plt_add_uri(volatile sqlite3 *db, const char *name, struct lkt_uri *uri);
 
 /* User control, yeah, MPD authentification sucks. */
-bool database_user_authentificate(sqlite3 *db, const char *password);
-bool database_user_add(sqlite3 *db, const char *username, const char *password);
+bool database_user_authentificate(volatile sqlite3 *db, const char *password);
+bool database_user_add(volatile sqlite3 *db, const char *username, const char *password);
 
 /* Stickers manipulations. */
 struct sticker_callback {
@@ -160,9 +160,9 @@ struct sticker_callback {
     bool (*call)(void *args, const char *sticker, const char *type, int uri, int value);
 };
 
-bool database_sticker_create        (sqlite3 *db, const char *name);
-bool database_sticker_delete        (sqlite3 *db, const char *name);
-bool database_sticker_delete_specify(sqlite3 *sb, const char *type, int uri, const char *name);
-bool database_sticker_list          (sqlite3 *db, const char *type, struct sticker_callback *call);
-bool database_sticker_set           (sqlite3 *db, const char *type, const char *name, int uri, int value);
-bool database_sticker_get           (sqlite3 *db, const char *type, const char *name, int uri, struct sticker_callback *call);
+bool database_sticker_create        (volatile sqlite3 *db, const char *name);
+bool database_sticker_delete        (volatile sqlite3 *db, const char *name);
+bool database_sticker_delete_specify(volatile sqlite3 *sb, const char *type, int uri, const char *name);
+bool database_sticker_list          (volatile sqlite3 *db, const char *type, struct sticker_callback *call);
+bool database_sticker_set           (volatile sqlite3 *db, const char *type, const char *name, int uri, int value);
+bool database_sticker_get           (volatile sqlite3 *db, const char *type, const char *name, int uri, struct sticker_callback *call);
diff --git a/inc/lektor/module/module_sdl2.h b/inc/lektor/module/module_sdl2.h
index 90eacc578aa4d769643c33c59e9eff5ff847fd22..5d63ef14c6be730455829b99d3ef23444b4317c2 100644
--- a/inc/lektor/module/module_sdl2.h
+++ b/inc/lektor/module/module_sdl2.h
@@ -24,4 +24,4 @@ bool module_sdl2_set_volume(struct lkt_win *const win, int vol);
 bool module_sdl2_get_duration(struct lkt_win *const win, int *dur_sec);
 bool module_sdl2_get_elapsed(struct lkt_win *const win, int *elapsed_sec);
 
-bool module_sdl2_handle_events(struct lkt_win *const win, sqlite3 *db, enum mpd_idle_flag *mpd_idle_events);
+bool module_sdl2_handle_events(struct lkt_win *const win, volatile sqlite3 *db, mpd_idle_flag *mpd_idle_events);
diff --git a/inc/lektor/module/module_x11.h b/inc/lektor/module/module_x11.h
index 0ea84737be6fed8b92296da2d9dc3b46483ed552..8d4dcb57eadc33ad4c5cd071583d639fe6f66774 100644
--- a/inc/lektor/module/module_x11.h
+++ b/inc/lektor/module/module_x11.h
@@ -24,4 +24,4 @@ bool module_x11_set_volume(struct lkt_win *const win, int vol);
 bool module_x11_get_duration(struct lkt_win *const win, int *dur_sec);
 bool 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);
+bool module_x11_handle_events(struct lkt_win *const win, volatile sqlite3 *db, mpd_idle_flag *mpd_idle_events);
diff --git a/inc/lektor/module/mpv.h b/inc/lektor/module/mpv.h
index ce9c63e64d5ec03fc5fdb4ad9f00dcb3366b69de..4f00195c0683bb54032ec966baed91049df65e90 100644
--- a/inc/lektor/module/mpv.h
+++ b/inc/lektor/module/mpv.h
@@ -12,5 +12,5 @@ mpv_handle *lmpv_prepare(void);
 int lmpv_set_volume(mpv_handle *ctx, int vol);
 int lmpv_load_file(mpv_handle *ctx, const char *file);
 int lmpv_toggle_pause(mpv_handle *ctx);
-int lmpv_handle(struct lkt_win *win, mpv_handle *ctx, sqlite3 *db, enum mpd_idle_flag *mpd_idle_flag,
-                int *time_pos, int *time_duration);
+int lmpv_handle(struct lkt_win *win, mpv_handle *ctx, volatile sqlite3 *db, mpd_idle_flag *mpd_idle_flag,
+                volatile int *time_pos, volatile int *time_duration);
diff --git a/inc/lektor/net.h b/inc/lektor/net.h
index f6a7f4afc8349ccb53c491ee70d69697a7ffbe8c..111f38d0ce51b904fdaa6320f6207275b059f58b 100644
--- a/inc/lektor/net.h
+++ b/inc/lektor/net.h
@@ -73,7 +73,7 @@ struct lkt_state {
 
     struct lkt_repo repo;
 
-    volatile enum mpd_idle_flag mpd_idle_events;
+    mpd_idle_flag mpd_idle_events;
 
     struct lkt_win win;
 };
diff --git a/inc/lektor/window.h b/inc/lektor/window.h
index 624c05c8284414c2f9b00e2c9ce570d7a9a4b281..ab5f43b8b7e453874f393558029a0a6eb60e69fd 100644
--- a/inc/lektor/window.h
+++ b/inc/lektor/window.h
@@ -30,7 +30,7 @@ struct lkt_win {
     bool (*get_elapsed)(struct lkt_win *win, int *elapsed_sec);
 
     /* Handle loop event */
-    bool (*handle_events)(struct lkt_win *win, sqlite3 *db, enum mpd_idle_flag *mpd_idle_events);
+    bool (*handle_events)(struct lkt_win *win, volatile sqlite3 *db, mpd_idle_flag *mpd_idle_events);
 };
 
 enum lkt_win_type {