From 9beb6b61ab28122de049da918afad424b1e92c42 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 4 Oct 2008 19:31:35 -0700 Subject: playlist: fix "currentsong" at end-of-playlist The current song information could get cleared if we got to the end of the playlist and mpd is not in repeat mode. This also prevents "currentsong" from returning information if mpd is not playing. --- src/playlist.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/playlist.c b/src/playlist.c index ca903036d..80352602f 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -518,7 +518,7 @@ static void queueNextSongInPlaylist(void) if (playlist.length > 0) { if (playlist.random) randomizeOrder(0, playlist.length - 1); - else + else if (ob_get_state() == OB_STATE_STOP) playlist.current = -1; } } else if (dc.state == DC_STATE_STOP) { @@ -896,7 +896,13 @@ enum playlist_result playPlaylist(int song, int stopOnError) ob_trigger_action(OB_ACTION_PAUSE_UNSET); return PLAYLIST_RESULT_SUCCESS; } - if (playlist.current >= 0 && playlist.current < playlist.length) { + + if (playlist_state == PLAYLIST_STATE_STOP && + playlist.length > 0 && + playlist.current == playlist.length - 1) { + i = 0; + } else if (playlist.current >= 0 && + playlist.current < playlist.length) { i = playlist.current; } else { i = 0; @@ -1315,9 +1321,10 @@ enum playlist_result savePlaylist(const char *utf8file) int getPlaylistCurrentSong(void) { DEBUG("%s:%d current: %d\n", __func__, __LINE__, playlist.current); - if (playlist.current >= 0 && playlist.current < playlist.length) { + if (ob_get_state() != OB_STATE_STOP && + playlist.current >= 0 && + playlist.current < playlist.length) return playlist.order[playlist.current]; - } return -1; } -- cgit v1.2.3