From 529e166888905b6ed5998c72148904d141845863 Mon Sep 17 00:00:00 2001 From: Björn Stenberg Date: Wed, 17 Jul 2002 23:07:45 +0000 Subject: New vastly improved random algorithm: Mersenne Twister git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1377 a1c6a512-1295-4272-9138-f99709370657 --- apps/playlist.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'apps') diff --git a/apps/playlist.c b/apps/playlist.c index 2d8bbd3a33..c74d643c52 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -205,20 +205,6 @@ void add_indices_to_playlist( playlist_info_t *playlist ) close(fd); } -static unsigned int playlist_seed = 0xdeadcafe; -static void seedit(unsigned int seed) -{ - playlist_seed = seed; -} - -static 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 */ @@ -229,14 +215,14 @@ void randomise_playlist( playlist_info_t *playlist, unsigned int seed ) int store; /* seed with the given seed */ - seedit( seed ); + srand( seed ); /* randomise entire indices list */ while( count < playlist->amount ) { /* the rand is from 0 to RAND_MAX, so adjust to our value range */ - candidate = getrand() % ( playlist->amount ); + candidate = rand() % playlist->amount; /* now swap the values at the 'count' and 'candidate' positions */ store = playlist->indices[candidate]; -- cgit v1.2.3