[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;
}
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

View File

@ -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)

View File

@ -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);

View File

@ -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);