[Slim-Checkins] r11332 - in /branches/6.5/server: Changelog6.html Plugins/RandomPlay/Plugin.pm
adrian at svn.slimdevices.com
adrian at svn.slimdevices.com
Sat Feb 3 05:35:01 PST 2007
Author: adrian
Date: Sat Feb 3 05:35:01 2007
New Revision: 11332
URL: http://svn.slimdevices.com?rev=11332&view=rev
Log:
Bug: 4724
Description: don't add random items to playlist via a hash as order of
keys is not random
Modified:
branches/6.5/server/Changelog6.html
branches/6.5/server/Plugins/RandomPlay/Plugin.pm
Modified: branches/6.5/server/Changelog6.html
URL: http://svn.slimdevices.com/branches/6.5/server/Changelog6.html?rev=11332&r1=11331&r2=11332&view=diff
==============================================================================
--- branches/6.5/server/Changelog6.html (original)
+++ branches/6.5/server/Changelog6.html Sat Feb 3 05:35:01 2007
@@ -13,6 +13,7 @@
<ul>
<li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=4203">#4203</a> - alac crashes</li>
<li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=4714">#4714</a> - DNS handling does not raise error if dns name is invalid</li>
+ <li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=4724">#4724</a> - Random Play (items not added in random order)</li>
</ul>
</ul>
Modified: branches/6.5/server/Plugins/RandomPlay/Plugin.pm
URL: http://svn.slimdevices.com/branches/6.5/server/Plugins/RandomPlay/Plugin.pm?rev=11332&r1=11331&r2=11332&view=diff
==============================================================================
--- branches/6.5/server/Plugins/RandomPlay/Plugin.pm (original)
+++ branches/6.5/server/Plugins/RandomPlay/Plugin.pm Sat Feb 3 05:35:01 2007
@@ -81,30 +81,21 @@
# Restrict by the genre's we've selected.
my $rs = Slim::Schema->rs($type)->search($find, { 'join' => \@joins });
- my @idList = $rs->distinct->get_column('me.id')->all;
+ my @idList;
if ($limit) {
# Get a fixed selection of random keys, make sure they don't duplicate.
- my %random = ();
- my $max = $limit;
-
- while ($max) {
-
- my $i = $idList[ rand @idList ];
-
- if (exists $random{$i}) {
- next;
- }
-
- $random{$i} = 1;
-
- $max--;
- }
-
- @idList = keys %random;
+ my @allIds = $rs->distinct->get_column('me.id')->all;
+
+ for (my $i = 0; $i < $limit && @allIds; ++$i) {
+
+ push @idList, (splice @allIds, rand @allIds, 1);
+ }
} else {
+
+ @idList = $rs->distinct->get_column('me.id')->all;
Slim::Player::Playlist::fischer_yates_shuffle(\@idList);
}
More information about the checkins
mailing list