[banshee] Shuffler: fix shuffle for 1 track when repeat is enabled (bgo#671221)



commit 506bb00a561c3401ef6985168bd299728b490d63
Author: Andrés G. Aragoneses <knocte gmail com>
Date:   Mon Feb 17 02:11:41 2014 +0100

    Shuffler: fix shuffle for 1 track when repeat is enabled (bgo#671221)
    
    Retry a third time when GetRandomTrack() returns null for a second
    time. It can happen, because the first retry still tries to reset
    the random mode but discarding the last track, to avoid duplicate
    playbacks.
    
    Fixes last part of bgo#671221 (when there is 1 track to play)

 .../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 335c19d..651fc29 100644
--- a/src/Core/Banshee.Services/Banshee.Collection.Database/Shuffler.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection.Database/Shuffler.cs
@@ -172,6 +172,15 @@ namespace Banshee.Collection.Database
                 if (track == null && repeat) {
                     random_began_at = last_track.LastPlayed;
                     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;
+                    }
                 }
                 return track;
             }


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