diff --git a/apps/playlist.c b/apps/playlist.c index 60786f67ce..f0fa40bb98 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -128,6 +128,23 @@ void add_indices_to_playlist( playlist_info_t *playlist ) 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 */ @@ -138,14 +155,14 @@ void randomise_playlist( playlist_info_t *playlist, unsigned int seed ) int store; /* seed with the given seed */ - srand( seed ); + seedit( seed ); /* randomise entire indices list */ while( count < playlist->amount ) { /* 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 */ store = playlist->indices[candidate];