[mpd] Return correct item-id for command 'addid' and return correct

number of items in the queue if player is stopped for command 'status'
This commit is contained in:
chme 2016-02-28 10:21:25 +01:00
parent b454a2fd60
commit d35894ac15
4 changed files with 21 additions and 15 deletions

View File

@ -1015,7 +1015,7 @@ dacp_reply_cue_play(struct evhttp_request *req, struct evbuffer *evbuf, char **u
return; return;
} }
player_queue_add(items); player_queue_add(items, NULL);
} }
else else
{ {
@ -1253,7 +1253,7 @@ dacp_reply_playspec(struct evhttp_request *req, struct evbuffer *evbuf, char **u
player_playback_stop(); player_playback_stop();
player_queue_clear(); player_queue_clear();
player_queue_add(items); player_queue_add(items, NULL);
player_queue_plid(plid); player_queue_plid(plid);
if (shuffle) if (shuffle)
@ -1787,7 +1787,7 @@ dacp_reply_playqueueedit_add(struct evhttp_request *req, struct evbuffer *evbuf,
} }
else else
{ {
player_queue_add(items); player_queue_add(items, NULL);
} }
} }
else else

View File

@ -1604,7 +1604,7 @@ mpd_command_add(struct evbuffer *evbuf, int argc, char **argv, char **errmsg)
return ACK_ERROR_UNKNOWN; return ACK_ERROR_UNKNOWN;
} }
player_queue_add(items); player_queue_add(items, NULL);
ret = player_playback_start(NULL); ret = player_playback_start(NULL);
if (ret < 0) if (ret < 0)
@ -1625,6 +1625,7 @@ static int
mpd_command_addid(struct evbuffer *evbuf, int argc, char **argv, char **errmsg) mpd_command_addid(struct evbuffer *evbuf, int argc, char **argv, char **errmsg)
{ {
struct queue_item *items; struct queue_item *items;
uint32_t item_id;
int ret; int ret;
if (argc < 2) 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, evbuffer_add_printf(evbuf,
"addid: %s\n"
"Id: %d\n", "Id: %d\n",
argv[1], item_id);
0); //ps->id);
ret = player_playback_start(NULL); ret = player_playback_start(NULL);
if (ret < 0) if (ret < 0)
@ -2362,7 +2360,7 @@ mpd_command_load(struct evbuffer *evbuf, int argc, char **argv, char **errmsg)
return ACK_ERROR_UNKNOWN; return ACK_ERROR_UNKNOWN;
} }
player_queue_add(items); player_queue_add(items, NULL);
ret = player_playback_start(NULL); ret = player_playback_start(NULL);
if (ret < 0) if (ret < 0)
@ -2628,7 +2626,7 @@ mpd_command_findadd(struct evbuffer *evbuf, int argc, char **argv, char **errmsg
return ACK_ERROR_UNKNOWN; return ACK_ERROR_UNKNOWN;
} }
player_queue_add(items); player_queue_add(items, NULL);
ret = player_playback_start(NULL); ret = player_playback_start(NULL);
if (ret < 0) if (ret < 0)
@ -3263,7 +3261,7 @@ mpd_command_searchadd(struct evbuffer *evbuf, int argc, char **argv, char **errm
return ACK_ERROR_UNKNOWN; return ACK_ERROR_UNKNOWN;
} }
player_queue_add(items); player_queue_add(items, NULL);
ret = player_playback_start(NULL); ret = player_playback_start(NULL);
if (ret < 0) if (ret < 0)

View File

@ -165,6 +165,8 @@ struct playerqueue_add_param
{ {
struct queue_item *items; struct queue_item *items;
int pos; int pos;
uint32_t *item_id_ptr;
}; };
struct playerqueue_move_param struct playerqueue_move_param
@ -2196,6 +2198,7 @@ get_status(struct player_command *cmd)
status->plid = cur_plid; status->plid = cur_plid;
status->plversion = cur_plversion; status->plversion = cur_plversion;
status->playlistlength = queue_count(queue);
switch (player_state) switch (player_state)
{ {
@ -2273,7 +2276,6 @@ get_status(struct player_command *cmd)
status->next_pos_pl = 0; status->next_pos_pl = 0;
} }
status->playlistlength = queue_count(queue);
break; break;
} }
@ -3376,8 +3378,10 @@ playerqueue_add(struct player_command *cmd)
{ {
struct queue_item *items; struct queue_item *items;
uint32_t cur_id; uint32_t cur_id;
uint32_t *item_id;
items = cmd->arg.queue_add_param.items; items = cmd->arg.queue_add_param.items;
item_id = cmd->arg.queue_add_param.item_id_ptr;
queue_add(queue, items); queue_add(queue, items);
@ -3387,6 +3391,9 @@ playerqueue_add(struct player_command *cmd)
queue_shuffle(queue, cur_id); queue_shuffle(queue, cur_id);
} }
if (item_id)
*item_id = queueitem_item_id(items);
cur_plid = 0; cur_plid = 0;
cur_plversion++; cur_plversion++;
@ -4209,7 +4216,7 @@ player_queue_get_byindex(int index, int count)
* Appends the given media items to the queue * Appends the given media items to the queue
*/ */
int int
player_queue_add(struct queue_item *items) player_queue_add(struct queue_item *items, uint32_t *item_id)
{ {
struct player_command cmd; struct player_command cmd;
int ret; int ret;
@ -4219,6 +4226,7 @@ player_queue_add(struct queue_item *items)
cmd.func = playerqueue_add; cmd.func = playerqueue_add;
cmd.func_bh = NULL; cmd.func_bh = NULL;
cmd.arg.queue_add_param.items = items; cmd.arg.queue_add_param.items = items;
cmd.arg.queue_add_param.item_id_ptr = item_id;
ret = sync_command(&cmd); ret = sync_command(&cmd);

View File

@ -161,7 +161,7 @@ struct queue *
player_queue_get_byindex(int pos, int count); player_queue_get_byindex(int pos, int count);
int int
player_queue_add(struct queue_item *items); player_queue_add(struct queue_item *items, uint32_t *item_id);
int int
player_queue_add_next(struct queue_item *items); player_queue_add_next(struct queue_item *items);