From 3886ec6638c89c2d6c2ffa0ae4f545aa52047549 Mon Sep 17 00:00:00 2001 From: chme Date: Sun, 3 May 2015 10:34:49 +0200 Subject: [PATCH] Add version number for playlist (queue) This is necessary to return a valid playlist id for mpd status command. --- src/mpd.c | 3 ++- src/player.c | 12 ++++++++++++ src/player.h | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/mpd.c b/src/mpd.c index 965db31f..ac62bc94 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -790,7 +790,7 @@ mpd_command_status(struct evbuffer *evbuf, int argc, char **argv, char **errmsg) status.shuffle, (status.repeat == REPEAT_SONG ? 1 : 0), 0 /* consume: not supported by forked-daapd, always return 'off' */, - status.plid, + status.plversion, status.playlistlength, state); @@ -1815,6 +1815,7 @@ mpd_command_playlistinfo(struct evbuffer *evbuf, int argc, char **argv, char **e static int mpd_command_plchanges(struct evbuffer *evbuf, int argc, char **argv, char **errmsg) { + DPRINTF(E_WARN, L_MPD, "Ignore command %s\n", argv[0]); return 0; } diff --git a/src/player.c b/src/player.c index bd1f9fa6..44d7babb 100644 --- a/src/player.c +++ b/src/player.c @@ -256,6 +256,7 @@ static struct player_source *shuffle_head; static struct player_source *cur_playing; static struct player_source *cur_streaming; static uint32_t cur_plid; +static uint32_t cur_plversion; static struct evbuffer *audio_buf; /* Play history */ @@ -2513,6 +2514,7 @@ get_status(struct player_command *cmd) status->volume = master_volume; status->plid = cur_plid; + status->plversion = cur_plversion; switch (player_state) { @@ -3870,6 +3872,7 @@ queue_add(struct player_command *cmd) if (cur_plid != 0) cur_plid = 0; + cur_plversion++; listener_notify(LISTENER_PLAYLIST); @@ -3913,6 +3916,7 @@ queue_add_next(struct player_command *cmd) if (cur_plid != 0) cur_plid = 0; + cur_plversion++; listener_notify(LISTENER_PLAYLIST); @@ -3983,6 +3987,8 @@ queue_move(struct player_command *cmd) ps_dst->pl_next = ps_src; } + cur_plversion++; + listener_notify(LISTENER_PLAYLIST); return 0; @@ -4050,6 +4056,8 @@ queue_remove(struct player_command *cmd) source_free(ps); + cur_plversion++; + listener_notify(LISTENER_PLAYLIST); return 0; @@ -4077,6 +4085,7 @@ queue_clear(struct player_command *cmd) } cur_plid = 0; + cur_plversion++; listener_notify(LISTENER_PLAYLIST); @@ -4129,6 +4138,8 @@ queue_empty(struct player_command *cmd) source_head->shuffle_prev = source_head; } + cur_plversion++; + listener_notify(LISTENER_PLAYLIST); return 0; @@ -5189,6 +5200,7 @@ player_init(void) cur_playing = NULL; cur_streaming = NULL; cur_plid = 0; + cur_plversion = 0; player_state = PLAY_STOPPED; repeat = REPEAT_OFF; diff --git a/src/player.h b/src/player.h index 7f98d719..f21ab1d5 100644 --- a/src/player.h +++ b/src/player.h @@ -54,6 +54,8 @@ struct player_status { /* Playlist id */ uint32_t plid; + /* Playlist version */ + uint32_t plversion; /* Playlist length */ uint32_t playlistlength; /* Playing song id*/