forked from len0rd/rockbox
added some stupid faked random functions too, to build on target
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@894 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
4bf52eae14
commit
d4c9173888
1 changed files with 19 additions and 2 deletions
|
|
@ -128,6 +128,23 @@ void add_indices_to_playlist( playlist_info_t *playlist )
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned int playlist_seed = 0xdeadcafe;
|
||||||
|
void seedit(unsigned int seed)
|
||||||
|
{
|
||||||
|
playlist_seed = seed;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getrand(void)
|
||||||
|
{
|
||||||
|
playlist_seed += 0x12345;
|
||||||
|
|
||||||
|
/* the rand is from 0 to RAND_MAX */
|
||||||
|
return playlist_seed;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* randomly rearrange the array of indices for the playlist
|
* randomly rearrange the array of indices for the playlist
|
||||||
*/
|
*/
|
||||||
|
|
@ -138,14 +155,14 @@ void randomise_playlist( playlist_info_t *playlist, unsigned int seed )
|
||||||
int store;
|
int store;
|
||||||
|
|
||||||
/* seed with the given seed */
|
/* seed with the given seed */
|
||||||
srand( seed );
|
seedit( seed );
|
||||||
|
|
||||||
/* randomise entire indices list */
|
/* randomise entire indices list */
|
||||||
|
|
||||||
while( count < playlist->amount )
|
while( count < playlist->amount )
|
||||||
{
|
{
|
||||||
/* the rand is from 0 to RAND_MAX, so adjust to our value range */
|
/* the rand is from 0 to RAND_MAX, so adjust to our value range */
|
||||||
candidate = rand() % ( playlist->amount );
|
candidate = getrand() % ( playlist->amount );
|
||||||
|
|
||||||
/* now swap the values at the 'count' and 'candidate' positions */
|
/* now swap the values at the 'count' and 'candidate' positions */
|
||||||
store = playlist->indices[candidate];
|
store = playlist->indices[candidate];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue