Skip to content

Commit

Permalink
gst-play: use Fisher-Yates shuffle for shuffling the playlist
Browse files Browse the repository at this point in the history
  • Loading branch information
tp-m committed Aug 10, 2018
1 parent 0340c7e commit 7e9d672
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tools/gst-play.c
Expand Up @@ -817,9 +817,9 @@ shuffle_uris (gchar ** uris, guint num)
if (num < 2)
return;

for (i = 0; i < num; i++) {
/* gets equally distributed random number in 0..num-1 [0;num[ */
j = g_random_int_range (0, num);
for (i = num - 1; i >= 1; i--) {
/* +1 because number returned will be in range [a;b[ so excl. stop */
j = g_random_int_range (0, i + 1);
tmp = uris[j];
uris[j] = uris[i];
uris[i] = tmp;
Expand Down

0 comments on commit 7e9d672

Please sign in to comment.