[banshee/stable-2.6] Shuffler: fix shuffle for less than 3 tracks if repeat ON (bgo#671221)



commit d9619cbb8ff3384db92d14b9d00fdf97f1f55394
Author: Andrés G. Aragoneses <knocte gmail com>
Date:   Mon Feb 17 02:30:23 2014 +0100

    Shuffler: fix shuffle for less than 3 tracks if repeat ON (bgo#671221)
    
    bgo#671221 was fixed in two parts in master branch:
    - A commit for the case of having 2 tracks in the source.
    - A commit for the case of having 1 track in the source.
    The second and last commit (3badbb864d14c4902f846fbc3933838de54c7d43)
    has a bit less risk of regressions, and also fixes the case for 2 tracks,
    even though it leaves a suboptimal random mode, so let's backport it to
    the stable branch.

 .../Banshee.Collection.Database/Shuffler.cs        |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/src/Core/Banshee.Services/Banshee.Collection.Database/Shuffler.cs 
b/src/Core/Banshee.Services/Banshee.Collection.Database/Shuffler.cs
index 6a0d0c1..fb41ac5 100644
--- a/src/Core/Banshee.Services/Banshee.Collection.Database/Shuffler.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection.Database/Shuffler.cs
@@ -171,6 +171,15 @@ namespace Banshee.Collection.Database
                 if (track == null && repeat) {
                     random_began_at = (random_began_at == last_random) ? DateTime.Now : last_random;
                     track = GetRandomTrack (mode, repeat, true);
+
+                    if (track == null) {
+                        // previous retry could still return null because it still discards last track, to 
avoid duplicates
+                        // so, last resort: 1 track with shuffle ON and repeat ON is equivalent to repeat 
SINGLE and cannot
+                        // avoid duplicate playbacks
+                        random_began_at = DateTime.MaxValue;
+                        track = GetRandomTrack (mode, repeat, true);
+                        random_began_at = DateTime.Now;
+                    }
                 }
 
                 last_random = DateTime.Now;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]