diff options
author | Tim-Philipp Müller <tim@centricular.com> | 2018-08-08 19:18:22 +0100 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2018-08-10 12:28:41 +0100 |
commit | 7e9d6720ca114a487e485478798689077b8f1e98 (patch) | |
tree | 904d2930a729fe39946f6ee37cec824bbc24cc7f /tools | |
parent | 0340c7e1f8e660dbc46ab3f258bddca7d73ad6b2 (diff) | |
download | gstreamer-plugins-base-7e9d6720ca114a487e485478798689077b8f1e98.tar.gz |
gst-play: use Fisher-Yates shuffle for shuffling the playlist
Diffstat (limited to 'tools')
-rw-r--r-- | tools/gst-play.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/gst-play.c b/tools/gst-play.c index 70c9c6bc5..964943a53 100644 --- 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; |