Magnus Holmgren's fix that now enables us to toggle shuffle on/off from the
menu and it'll "take effect" immediately when needing to reload the playlist. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1526 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
81e7c72792
commit
360ae3ebdc
3 changed files with 34 additions and 1 deletions
|
@ -242,7 +242,7 @@ void randomise_playlist( playlist_info_t *playlist, unsigned int seed )
|
|||
srand( seed );
|
||||
|
||||
/* randomise entire indices list */
|
||||
for(count = playlist->amount - 1; count ; count--)
|
||||
for(count = playlist->amount - 1; count >= 0; count--)
|
||||
{
|
||||
/* the rand is from 0 to RAND_MAX, so adjust to our value range */
|
||||
candidate = rand() % (count + 1);
|
||||
|
@ -254,6 +254,25 @@ void randomise_playlist( playlist_info_t *playlist, unsigned int seed )
|
|||
}
|
||||
}
|
||||
|
||||
static int compare(const void* p1, const void* p2)
|
||||
{
|
||||
int* e1 = (int*) p1;
|
||||
int* e2 = (int*) p2;
|
||||
|
||||
return *e1 - *e2;
|
||||
}
|
||||
|
||||
/*
|
||||
* sort the array of indices for the playlist
|
||||
*/
|
||||
void sort_playlist( playlist_info_t *playlist )
|
||||
{
|
||||
if (playlist->amount > 0)
|
||||
{
|
||||
qsort(&playlist->indices, playlist->amount, sizeof(playlist->indices[0]), compare);
|
||||
}
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
* local variables:
|
||||
* eval: (load-file "../firmware/rockbox-mode.el")
|
||||
|
|
|
@ -41,6 +41,7 @@ extern bool playlist_shuffle;
|
|||
void play_list(char *dir, char *file);
|
||||
char* playlist_next(int steps, char *dirname);
|
||||
void randomise_playlist( playlist_info_t *playlist, unsigned int seed );
|
||||
void sort_playlist( playlist_info_t *playlist );
|
||||
void empty_playlist( playlist_info_t *playlist );
|
||||
void add_indices_to_playlist( playlist_info_t *playlist );
|
||||
|
||||
|
|
|
@ -78,9 +78,22 @@ void settings_menu(void)
|
|||
{ "Scroll speed", scroll_speed },
|
||||
{ "While Playing", wps_set },
|
||||
};
|
||||
bool old_shuffle = global_settings.playlist_shuffle;
|
||||
|
||||
m=menu_init( items, sizeof items / sizeof(struct menu_items) );
|
||||
menu_run(m);
|
||||
menu_exit(m);
|
||||
settings_save();
|
||||
|
||||
if (old_shuffle != global_settings.playlist_shuffle)
|
||||
{
|
||||
if (global_settings.playlist_shuffle)
|
||||
{
|
||||
randomise_playlist(&playlist, current_tick);
|
||||
}
|
||||
else
|
||||
{
|
||||
sort_playlist(&playlist);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue