diff --git a/README.md b/README.md index 51dcdb1274c83198d4be6852f7aa94561f57b2d3..cde27020d2b5ea15e0cdbea21c007060b551a008 100644 --- a/README.md +++ b/README.md @@ -274,6 +274,7 @@ For the compatibility column, the possible values are the following: | `__rescan` | same as `rescan`, but force populating without timestamp check | | `sticker __add {name}` | create a sticker | | `__insert {uri}` | do the `add` command, but with the maximum priority | +| `__flat` | flat is justice => all prio are now 1 in the queue | ### Commands with no plan for support diff --git a/inc/lektor/commands.h b/inc/lektor/commands.h index 7fc6240f78405acfb545b862820d136f715726c3..65affefaa03349d5ef5c2e2e67d0a1238953d7ed 100644 --- a/inc/lektor/commands.h +++ b/inc/lektor/commands.h @@ -44,6 +44,7 @@ bool command_move (struct lkt_state *srv, char *args[LKT_MESSAGE_ARGS_MAX]); bool command_shuffle(struct lkt_state *srv, char *args[LKT_MESSAGE_ARGS_MAX]); bool command_dump (struct lkt_state *srv, char *args[LKT_MESSAGE_ARGS_MAX]); bool command_swap (struct lkt_state *srv, char *args[LKT_MESSAGE_ARGS_MAX]); +bool command_flat (struct lkt_state *srv, char *args[LKT_MESSAGE_ARGS_MAX]); bool command_queue_list(struct lkt_state *srv, size_t c, char *args[LKT_MESSAGE_ARGS_MAX]); diff --git a/inc/lektor/database.h b/inc/lektor/database.h index 86f8672c9288ccd8012cae4cf6306abfc91b144c..fa74abee07f0c89f94b8a0904e4718229e39041d 100644 --- a/inc/lektor/database.h +++ b/inc/lektor/database.h @@ -64,6 +64,7 @@ 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_flat (volatile sqlite3 *db); bool database_queue_move (volatile sqlite3 *db, int from, int to); bool database_queue_swap (volatile sqlite3 *db, int from, int to); bool database_queue_shuffle(volatile sqlite3 *db); diff --git a/src/base/commands.c b/src/base/commands.c index 97fc71db1f8c134bd4142c76ae030c25a4e0e752..fd61a9dc347e8ab8f7808be95ffcf9ac110bd9d6 100644 --- a/src/base/commands.c +++ b/src/base/commands.c @@ -368,6 +368,13 @@ command_crop(struct lkt_state *srv, char UNUSED *args[LKT_MESSAGE_ARGS_MAX]) return database_queue_crop(srv->db); } +inline bool +command_flat(struct lkt_state *srv, char UNUSED *args[LKT_MESSAGE_ARGS_MAX]) +{ + srv->mpd_idle_events |= MPD_IDLE_PLAYLIST; + return database_queue_flat(srv->db); +} + static inline bool __skip_current(struct lkt_state *srv) { diff --git a/src/database/queue.c b/src/database/queue.c index 2c8ac9307c9ddbe3bb611a1e317589cbe45323e8..61bb64a1bc799cbeefa41e7cae21fe9affd78f90 100644 --- a/src/database/queue.c +++ b/src/database/queue.c @@ -31,6 +31,7 @@ sqlite_just_exec(database_queue_clear, "DELETE FROM queue;" sqlite_just_exec(database_config_queue_default, "UPDATE queue_state SET volume = 100, paused = 1," " random = 0, repeat = 0, single = 0, consume = 0," " current = NULL, duration = 0;") +sqlite_just_exec(database_queue_flat, "UPDATE queue SET priority = 1;"); #undef sqlite_just_exec // *INDENT-ON* diff --git a/src/net/listen.c b/src/net/listen.c index 89617e16313680f1e716ee8fb15003a9575ad5bd..c97aae3212c6097b9e8d7b0524730a4e8918e49f 100644 --- a/src/net/listen.c +++ b/src/net/listen.c @@ -205,6 +205,8 @@ handle_simple_command(struct lkt_state *srv, size_t c, struct lkt_command cmd) err = ! command_shuffle(srv, NULL); else if (STR_MATCH(cmd.name, "swap")) err = ! command_swap(srv, cmd.args); + else if (STR_MATCH(cmd.name, "__flat")) + err = ! command_flat(srv, cmd.args); else if (STR_MATCH(cmd.name, "seek")) err = ! command_seek(srv, cmd.args);