summaryrefslogtreecommitdiff
path: root/apps/playlist.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/playlist.c')
-rw-r--r--apps/playlist.c21
1 files changed, 19 insertions, 2 deletions
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 )
128 close(fd); 128 close(fd);
129} 129}
130 130
131static unsigned int playlist_seed = 0xdeadcafe;
132void seedit(unsigned int seed)
133{
134 playlist_seed = seed;
135}
136
137int getrand(void)
138{
139 playlist_seed += 0x12345;
140
141 /* the rand is from 0 to RAND_MAX */
142 return playlist_seed;
143}
144
145
146
147
131/* 148/*
132 * randomly rearrange the array of indices for the playlist 149 * randomly rearrange the array of indices for the playlist
133 */ 150 */
@@ -138,14 +155,14 @@ void randomise_playlist( playlist_info_t *playlist, unsigned int seed )
138 int store; 155 int store;
139 156
140 /* seed with the given seed */ 157 /* seed with the given seed */
141 srand( seed ); 158 seedit( seed );
142 159
143 /* randomise entire indices list */ 160 /* randomise entire indices list */
144 161
145 while( count < playlist->amount ) 162 while( count < playlist->amount )
146 { 163 {
147 /* the rand is from 0 to RAND_MAX, so adjust to our value range */ 164 /* the rand is from 0 to RAND_MAX, so adjust to our value range */
148 candidate = rand() % ( playlist->amount ); 165 candidate = getrand() % ( playlist->amount );
149 166
150 /* now swap the values at the 'count' and 'candidate' positions */ 167 /* now swap the values at the 'count' and 'candidate' positions */
151 store = playlist->indices[candidate]; 168 store = playlist->indices[candidate];