mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 00:36:51 +00:00
gst-play: use Fisher-Yates shuffle for shuffling the playlist
This commit is contained in:
parent
0340c7e1f8
commit
7e9d6720ca
1 changed files with 3 additions and 3 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue