projects
/
platform
/
upstream
/
gst-plugins-base.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
0340c7e
)
gst-play: use Fisher-Yates shuffle for shuffling the playlist
author
Tim-Philipp Müller
<tim@centricular.com>
Wed, 8 Aug 2018 18:18:22 +0000
(19:18 +0100)
committer
Tim-Philipp Müller
<tim@centricular.com>
Fri, 10 Aug 2018 11:28:41 +0000
(12:28 +0100)
tools/gst-play.c
patch
|
blob
|
history
diff --git
a/tools/gst-play.c
b/tools/gst-play.c
index 70c9c6bc5bf20802b0fb747f606d9a1155e358dd..964943a532489d006c993af8c1d713fd98174ee9 100644
(file)
--- a/
tools/gst-play.c
+++ b/
tools/gst-play.c
@@
-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;