diff options
author | Eric Wong <normalperson@yhbt.net> | 2008-10-04 19:31:35 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-10-04 19:31:35 -0700 |
commit | 9beb6b61ab28122de049da918afad424b1e92c42 (patch) | |
tree | 15514ace8681a1fb37befc0f4e7410660e06e2a7 | |
parent | fcbcdd9869e3147fe4a30ba808af294f680c9373 (diff) | |
download | mpd-9beb6b61ab28122de049da918afad424b1e92c42.tar.gz mpd-9beb6b61ab28122de049da918afad424b1e92c42.tar.xz mpd-9beb6b61ab28122de049da918afad424b1e92c42.zip |
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.
-rw-r--r-- | src/playlist.c | 15 |
1 files 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; } |