From d35894ac15ee73803d882368958ee9e727f8c854 Mon Sep 17 00:00:00 2001 From: chme Date: Sun, 28 Feb 2016 10:21:25 +0100 Subject: [PATCH] [mpd] Return correct item-id for command 'addid' and return correct number of items in the queue if player is stopped for command 'status' --- src/httpd_dacp.c | 6 +++--- src/mpd.c | 16 +++++++--------- src/player.c | 12 ++++++++++-- src/player.h | 2 +- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/httpd_dacp.c b/src/httpd_dacp.c index adbb30a8..66ef1869 100644 --- a/src/httpd_dacp.c +++ b/src/httpd_dacp.c @@ -1015,7 +1015,7 @@ dacp_reply_cue_play(struct evhttp_request *req, struct evbuffer *evbuf, char **u return; } - player_queue_add(items); + player_queue_add(items, NULL); } else { @@ -1253,7 +1253,7 @@ dacp_reply_playspec(struct evhttp_request *req, struct evbuffer *evbuf, char **u player_playback_stop(); player_queue_clear(); - player_queue_add(items); + player_queue_add(items, NULL); player_queue_plid(plid); if (shuffle) @@ -1787,7 +1787,7 @@ dacp_reply_playqueueedit_add(struct evhttp_request *req, struct evbuffer *evbuf, } else { - player_queue_add(items); + player_queue_add(items, NULL); } } else diff --git a/src/mpd.c b/src/mpd.c index 3377cdde..8a251e97 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -1604,7 +1604,7 @@ mpd_command_add(struct evbuffer *evbuf, int argc, char **argv, char **errmsg) return ACK_ERROR_UNKNOWN; } - player_queue_add(items); + player_queue_add(items, NULL); ret = player_playback_start(NULL); if (ret < 0) @@ -1625,6 +1625,7 @@ static int mpd_command_addid(struct evbuffer *evbuf, int argc, char **argv, char **errmsg) { struct queue_item *items; + uint32_t item_id; int ret; if (argc < 2) @@ -1652,14 +1653,11 @@ mpd_command_addid(struct evbuffer *evbuf, int argc, char **argv, char **errmsg) } - player_queue_add(items); + player_queue_add(items, &item_id); - //TODO [queue] Get queue-item-id for mpd-command addid evbuffer_add_printf(evbuf, - "addid: %s\n" "Id: %d\n", - argv[1], - 0); //ps->id); + item_id); ret = player_playback_start(NULL); if (ret < 0) @@ -2362,7 +2360,7 @@ mpd_command_load(struct evbuffer *evbuf, int argc, char **argv, char **errmsg) return ACK_ERROR_UNKNOWN; } - player_queue_add(items); + player_queue_add(items, NULL); ret = player_playback_start(NULL); if (ret < 0) @@ -2628,7 +2626,7 @@ mpd_command_findadd(struct evbuffer *evbuf, int argc, char **argv, char **errmsg return ACK_ERROR_UNKNOWN; } - player_queue_add(items); + player_queue_add(items, NULL); ret = player_playback_start(NULL); if (ret < 0) @@ -3263,7 +3261,7 @@ mpd_command_searchadd(struct evbuffer *evbuf, int argc, char **argv, char **errm return ACK_ERROR_UNKNOWN; } - player_queue_add(items); + player_queue_add(items, NULL); ret = player_playback_start(NULL); if (ret < 0) diff --git a/src/player.c b/src/player.c index 17bb5e20..4806c74a 100644 --- a/src/player.c +++ b/src/player.c @@ -165,6 +165,8 @@ struct playerqueue_add_param { struct queue_item *items; int pos; + + uint32_t *item_id_ptr; }; struct playerqueue_move_param @@ -2196,6 +2198,7 @@ get_status(struct player_command *cmd) status->plid = cur_plid; status->plversion = cur_plversion; + status->playlistlength = queue_count(queue); switch (player_state) { @@ -2273,7 +2276,6 @@ get_status(struct player_command *cmd) status->next_pos_pl = 0; } - status->playlistlength = queue_count(queue); break; } @@ -3376,8 +3378,10 @@ playerqueue_add(struct player_command *cmd) { struct queue_item *items; uint32_t cur_id; + uint32_t *item_id; items = cmd->arg.queue_add_param.items; + item_id = cmd->arg.queue_add_param.item_id_ptr; queue_add(queue, items); @@ -3387,6 +3391,9 @@ playerqueue_add(struct player_command *cmd) queue_shuffle(queue, cur_id); } + if (item_id) + *item_id = queueitem_item_id(items); + cur_plid = 0; cur_plversion++; @@ -4209,7 +4216,7 @@ player_queue_get_byindex(int index, int count) * Appends the given media items to the queue */ int -player_queue_add(struct queue_item *items) +player_queue_add(struct queue_item *items, uint32_t *item_id) { struct player_command cmd; int ret; @@ -4219,6 +4226,7 @@ player_queue_add(struct queue_item *items) cmd.func = playerqueue_add; cmd.func_bh = NULL; cmd.arg.queue_add_param.items = items; + cmd.arg.queue_add_param.item_id_ptr = item_id; ret = sync_command(&cmd); diff --git a/src/player.h b/src/player.h index 1383a583..eef8d5b9 100644 --- a/src/player.h +++ b/src/player.h @@ -161,7 +161,7 @@ struct queue * player_queue_get_byindex(int pos, int count); int -player_queue_add(struct queue_item *items); +player_queue_add(struct queue_item *items, uint32_t *item_id); int player_queue_add_next(struct queue_item *items);