mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-22 19:42:40 -05:00
Minor fix for insert_shuffle when playlist is empty
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9716 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
d0de1aafac
commit
095ad1a39c
1 changed files with 18 additions and 13 deletions
|
|
@ -602,20 +602,25 @@ static int add_track_to_playlist(struct playlist_info* playlist,
|
||||||
break;
|
break;
|
||||||
case PLAYLIST_INSERT_SHUFFLED:
|
case PLAYLIST_INSERT_SHUFFLED:
|
||||||
{
|
{
|
||||||
int offset;
|
if (playlist->amount > 0)
|
||||||
int n = playlist->amount -
|
{
|
||||||
rotate_index(playlist, playlist->index);
|
int offset;
|
||||||
|
int n = playlist->amount -
|
||||||
if (n > 0)
|
rotate_index(playlist, playlist->index);
|
||||||
offset = rand() % n;
|
|
||||||
|
if (n > 0)
|
||||||
|
offset = rand() % n;
|
||||||
|
else
|
||||||
|
offset = 0;
|
||||||
|
|
||||||
|
position = playlist->index + offset + 1;
|
||||||
|
if (position >= playlist->amount)
|
||||||
|
position -= playlist->amount;
|
||||||
|
|
||||||
|
insert_position = position;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
offset = 0;
|
position = insert_position = 0;
|
||||||
|
|
||||||
position = playlist->index + offset + 1;
|
|
||||||
if (position >= playlist->amount)
|
|
||||||
position -= playlist->amount;
|
|
||||||
|
|
||||||
insert_position = position;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue