summaryrefslogtreecommitdiff
path: root/apps/playlist.c
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-07-17 23:07:45 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-07-17 23:07:45 +0000
commit529e166888905b6ed5998c72148904d141845863 (patch)
tree8d64f12c8f1eeb273dc4a3151b54e9e1db1d7723 /apps/playlist.c
parentbd44e6019787a9607d3d2e9ca8900df78b8d4e10 (diff)
downloadrockbox-529e166888905b6ed5998c72148904d141845863.tar.gz
rockbox-529e166888905b6ed5998c72148904d141845863.zip
New vastly improved random algorithm: Mersenne Twister
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1377 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/playlist.c')
-rw-r--r--apps/playlist.c18
1 files changed, 2 insertions, 16 deletions
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 )
205 close(fd); 205 close(fd);
206} 206}
207 207
208static unsigned int playlist_seed = 0xdeadcafe;
209static void seedit(unsigned int seed)
210{
211 playlist_seed = seed;
212}
213
214static int getrand(void)
215{
216 playlist_seed += 0x12345;
217
218 /* the rand is from 0 to RAND_MAX */
219 return playlist_seed;
220}
221
222/* 208/*
223 * randomly rearrange the array of indices for the playlist 209 * randomly rearrange the array of indices for the playlist
224 */ 210 */
@@ -229,14 +215,14 @@ void randomise_playlist( playlist_info_t *playlist, unsigned int seed )
229 int store; 215 int store;
230 216
231 /* seed with the given seed */ 217 /* seed with the given seed */
232 seedit( seed ); 218 srand( seed );
233 219
234 /* randomise entire indices list */ 220 /* randomise entire indices list */
235 221
236 while( count < playlist->amount ) 222 while( count < playlist->amount )
237 { 223 {
238 /* the rand is from 0 to RAND_MAX, so adjust to our value range */ 224 /* the rand is from 0 to RAND_MAX, so adjust to our value range */
239 candidate = getrand() % ( playlist->amount ); 225 candidate = rand() % playlist->amount;
240 226
241 /* now swap the values at the 'count' and 'candidate' positions */ 227 /* now swap the values at the 'count' and 'candidate' positions */
242 store = playlist->indices[candidate]; 228 store = playlist->indices[candidate];