From f8c87e6c508f34d783272370ef7de92b480147da Mon Sep 17 00:00:00 2001 From: Hardeep Sidhu Date: Mon, 26 Aug 2002 08:25:52 +0000 Subject: When toggling shuffle from on to off while a playlist is playing, update the current playlist index to the new index of the current song git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1977 a1c6a512-1295-4272-9138-f99709370657 --- apps/playlist.c | 21 +++++++++++++++++++-- apps/playlist.h | 2 +- apps/settings_menu.c | 2 +- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/apps/playlist.c b/apps/playlist.c index 76e177daeb..0052672e25 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -416,14 +416,31 @@ static int compare(const void* p1, const void* p2) } /* - * sort the array of indices for the playlist + * Sort the array of indices for the playlist. If start_current is true then + * set the index to the new index of the current song. */ -void sort_playlist(void) +void sort_playlist(bool start_current) { + int i; + int current = playlist.indices[playlist.index]; + if (playlist.amount > 0) { qsort(&playlist.indices, playlist.amount, sizeof(playlist.indices[0]), compare); } + + if (start_current) + { + /* Set the index to the current song */ + for (i=0; i