From: Andre Noll Date: Sun, 18 Nov 2007 14:14:09 +0000 (+0100) Subject: Fix off-by-one bug in playlist handling. X-Git-Tag: v0.2.17~2 X-Git-Url: http://git.tuebingen.mpg.de/?a=commitdiff_plain;h=2347b1cc856585b03351ba71938fcff3630bdfe8;p=paraslash.git Fix off-by-one bug in playlist handling. In playlist mode, the old code skipped the first entry of the list, i.e para_server began streaming using the second playlist entry. The fix is to set current_playlist_entry to the last entry of the list whenever a new playlist is loaded. Thanks to Gerrit Renker for reporting this bug. --- diff --git a/playlist_selector.c b/playlist_selector.c index a497ec13..632e2a2a 100644 --- a/playlist_selector.c +++ b/playlist_selector.c @@ -142,7 +142,7 @@ int com_ppl(int fd, __a_unused int argc, __a_unused char *argv[]) unsigned i; PARA_DEBUG_LOG("sending playlist to client (%d entries)\n", playlist_len); - for (i = 0; i < playlist_len; i++) { + for (i = 1; i <= playlist_len; i++) { int ret = send_va_buffer(fd, "%s\n", playlist[ (i + current_playlist_entry) % playlist_len]); if (ret < 0) @@ -217,6 +217,7 @@ static void pls_post_select(__a_unused fd_set *rfds, __a_unused fd_set *wfds) PARA_NOTICE_LOG("new playlist (%d entries)\n", playlist_len); sprintf(mmd->selector_info, "dbinfo1:new playlist: %d files\n" "dbinfo2:\ndbinfo3:\n", playlist_len); + current_playlist_entry = playlist_len - 1; pcd->retval = 1; pcd->size = 0; mutex_unlock(pcd->mutex);