forked from len0rd/rockbox
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
This commit is contained in:
parent
56fc041976
commit
f8c87e6c50
3 changed files with 21 additions and 4 deletions
|
@ -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)
|
if (playlist.amount > 0)
|
||||||
{
|
{
|
||||||
qsort(&playlist.indices, playlist.amount, sizeof(playlist.indices[0]), compare);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------
|
/* -----------------------------------------------------------------
|
||||||
|
|
|
@ -44,7 +44,7 @@ int play_list(char *dir, char *file, int start_index,
|
||||||
bool shuffled_index, int start_offset, int random_seed );
|
bool shuffled_index, int start_offset, int random_seed );
|
||||||
char* playlist_next(int steps, int* id);
|
char* playlist_next(int steps, int* id);
|
||||||
void randomise_playlist( unsigned int seed );
|
void randomise_playlist( unsigned int seed );
|
||||||
void sort_playlist(void);
|
void sort_playlist(bool start_current);
|
||||||
void empty_playlist(void);
|
void empty_playlist(void);
|
||||||
void add_indices_to_playlist(void);
|
void add_indices_to_playlist(void);
|
||||||
void playlist_clear(void);
|
void playlist_clear(void);
|
||||||
|
|
|
@ -208,7 +208,7 @@ Menu settings_menu(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sort_playlist();
|
sort_playlist(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue