diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/playlist.c | 21 | ||||
-rw-r--r-- | apps/playlist.h | 2 | ||||
-rw-r--r-- | 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) | |||
416 | } | 416 | } |
417 | 417 | ||
418 | /* | 418 | /* |
419 | * sort the array of indices for the playlist | 419 | * Sort the array of indices for the playlist. If start_current is true then |
420 | * set the index to the new index of the current song. | ||
420 | */ | 421 | */ |
421 | void sort_playlist(void) | 422 | void sort_playlist(bool start_current) |
422 | { | 423 | { |
424 | int i; | ||
425 | int current = playlist.indices[playlist.index]; | ||
426 | |||
423 | if (playlist.amount > 0) | 427 | if (playlist.amount > 0) |
424 | { | 428 | { |
425 | qsort(&playlist.indices, playlist.amount, sizeof(playlist.indices[0]), compare); | 429 | qsort(&playlist.indices, playlist.amount, sizeof(playlist.indices[0]), compare); |
426 | } | 430 | } |
431 | |||
432 | if (start_current) | ||
433 | { | ||
434 | /* Set the index to the current song */ | ||
435 | for (i=0; i<playlist.amount; i++) | ||
436 | { | ||
437 | if (playlist.indices[i] == current) | ||
438 | { | ||
439 | playlist.index = i; | ||
440 | break; | ||
441 | } | ||
442 | } | ||
443 | } | ||
427 | } | 444 | } |
428 | 445 | ||
429 | /* ----------------------------------------------------------------- | 446 | /* ----------------------------------------------------------------- |
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, | |||
44 | bool shuffled_index, int start_offset, int random_seed ); | 44 | bool shuffled_index, int start_offset, int random_seed ); |
45 | char* playlist_next(int steps, int* id); | 45 | char* playlist_next(int steps, int* id); |
46 | void randomise_playlist( unsigned int seed ); | 46 | void randomise_playlist( unsigned int seed ); |
47 | void sort_playlist(void); | 47 | void sort_playlist(bool start_current); |
48 | void empty_playlist(void); | 48 | void empty_playlist(void); |
49 | void add_indices_to_playlist(void); | 49 | void add_indices_to_playlist(void); |
50 | void playlist_clear(void); | 50 | 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) | |||
208 | } | 208 | } |
209 | else | 209 | else |
210 | { | 210 | { |
211 | sort_playlist(); | 211 | sort_playlist(true); |
212 | } | 212 | } |
213 | } | 213 | } |
214 | return result; | 214 | return result; |