Merge pull request #203 from chme/mpdseek

[mpd] Fix seek command
This commit is contained in:
ejurgensen 2015-12-12 11:14:10 +01:00
commit cb9034bee7

View File

@ -835,15 +835,11 @@ mpd_command_status(struct evbuffer *evbuf, int argc, char **argv, char **errmsg)
"time: %d:%d\n"
"elapsed: %#.3f\n"
"bitrate: 128\n"
"audio: 44100:16:2\n"
"nextsong: %d\n"
"nextsongid: %d\n",
"audio: 44100:16:2\n",
status.pos_pl,
status.item_id,
(status.pos_ms / 1000), (status.len_ms / 1000),
(status.pos_ms / 1000.0),
status.next_pos_pl,
status.next_item_id);
(status.pos_ms / 1000.0));
}
if (filescanner_scanning())
@ -857,7 +853,7 @@ mpd_command_status(struct evbuffer *evbuf, int argc, char **argv, char **errmsg)
"nextsong: %d\n"
"nextsongid: %d\n",
status.next_pos_pl,
status.next_id);
status.next_item_id);
}
return 0;
@ -1356,6 +1352,7 @@ mpd_command_previous(struct evbuffer *evbuf, int argc, char **argv, char **errms
static int
mpd_command_seek(struct evbuffer *evbuf, int argc, char **argv, char **errmsg)
{
struct player_status status;
uint32_t songpos;
float seek_target_sec;
int seek_target_msec;
@ -1363,7 +1360,7 @@ mpd_command_seek(struct evbuffer *evbuf, int argc, char **argv, char **errmsg)
if (argc < 3)
{
ret = asprintf(errmsg, "Missing argument for command 'seekcur'");
ret = asprintf(errmsg, "Missing argument for command 'seek'");
if (ret < 0)
DPRINTF(E_LOG, L_MPD, "Out of memory\n");
return ACK_ERROR_ARG;
@ -1379,7 +1376,8 @@ mpd_command_seek(struct evbuffer *evbuf, int argc, char **argv, char **errmsg)
}
//TODO Allow seeking in songs not currently playing
if (songpos != 0)
player_get_status(&status);
if (status.pos_pl != songpos)
{
ret = asprintf(errmsg, "Given song is not the current playing one, seeking is not supported");
if (ret < 0)