Package: music123
Version: 15-0.2
Tags: patch

music123 -Z will always start out by playing the first song, then one
of the first two songs, etc. I've written a patch so that it works as
designed.

-- 
Kie ekzistas vivo, ekzistas espero.
diff -ru music123-15/support_routines.adb music123-15clean/support_routines.adb
--- music123-15/support_routines.adb	2006-04-18 03:56:44.000000000 -0400
+++ music123-15clean/support_routines.adb	2009-08-14 19:39:03.000000000 -0400
@@ -280,7 +280,6 @@
 
       Gen : Generator;
       Len : Integer;
-      J : UString_List.Index;
 
       use Interfaces.C;
       function System (Command : Char_Array) return Integer;
@@ -312,6 +311,15 @@
       if Option_Eternal_Random then
          Len := Length (File_List);
          Reset (Gen, Integer (Seconds (Clock) * 10.0));
+         declare
+            Song_Number : Integer;
+         begin
+            loop
+               Song_Number := Integer (Float'Floor (Random (Gen) * Float (Len))) + 1;
+              Play_A_Song (To_String (Get (File_List, Song_Number)), Option_Quiet);
+           end loop;
+           return;
+         end;
       end if;
 
       if Option_Random then
@@ -320,15 +328,10 @@
 
       <<Loop_Start>> null;
       for I in 1 .. Length (File_List) loop
-         if Option_Eternal_Random then
-            J := Integer (Float'Floor (Random (Gen) * Float (I))) + 1;
-            Play_A_Song (To_String (Get (File_List, J)), Option_Quiet);
-         else
-            Play_A_Song (To_String (Get (File_List, I)), Option_Quiet);
-         end if;
+         Play_A_Song (To_String (Get (File_List, I)), Option_Quiet);
          delay (Delay_Length);
       end loop;
-      if Option_Loop or else Option_Eternal_Random then
+      if Option_Loop then
          goto Loop_Start;
       end if;
    end Play_Songs;

Reply via email to