summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorHardeep Sidhu <dyp@pobox.com>2002-08-26 08:25:52 +0000
committerHardeep Sidhu <dyp@pobox.com>2002-08-26 08:25:52 +0000
commitf8c87e6c508f34d783272370ef7de92b480147da (patch)
tree4b5ce8b775436bca265bed196adeb9da0e9983b8 /apps
parent56fc041976625666d6a59f6382c4c223a80cf477 (diff)
downloadrockbox-f8c87e6c508f34d783272370ef7de92b480147da.tar.gz
rockbox-f8c87e6c508f34d783272370ef7de92b480147da.zip
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
Diffstat (limited to 'apps')
-rw-r--r--apps/playlist.c21
-rw-r--r--apps/playlist.h2
-rw-r--r--apps/settings_menu.c2
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<playlist.amount; i++)
+ {
+ if (playlist.indices[i] == current)
+ {
+ playlist.index = i;
+ break;
+ }
+ }
+ }
}
/* -----------------------------------------------------------------
diff --git a/apps/playlist.h b/apps/playlist.h
index 86de8265c9..5abeec3176 100644
--- a/apps/playlist.h
+++ b/apps/playlist.h
@@ -44,7 +44,7 @@ int play_list(char *dir, char *file, int start_index,
bool shuffled_index, int start_offset, int random_seed );
char* playlist_next(int steps, int* id);
void randomise_playlist( unsigned int seed );
-void sort_playlist(void);
+void sort_playlist(bool start_current);
void empty_playlist(void);
void add_indices_to_playlist(void);
void playlist_clear(void);
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index 9b41a497ae..c3f3bccb61 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -208,7 +208,7 @@ Menu settings_menu(void)
}
else
{
- sort_playlist();
+ sort_playlist(true);
}
}
return result;