Codebase list music123 / 2c1475e
* new functionnality added - a task can handle command in parallel - only quit command implemented so far * put version number to 16.3 grave 12 years ago
7 changed file(s) with 99 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
0 This is music123 version 16.2dev (new versioning policy to include minor
0 This is music123 version 16.3 (new versioning policy to include minor
11 changes and bug fixes)
22
33 music123's goal in life is simple. With just mpg123 or ogg123, there
0 with Ada.Text_IO;
1
2 package body Commands is
3
4 ------------------
5 -- Handler_Task --
6 ------------------
7
8 task body Handler_Task is
9 Available : Boolean;
10 C : Character;
11 begin
12 select
13 accept Start;
14 or
15 terminate;
16 end select;
17 loop
18 Ada.Text_IO.Get_Immediate (C, Available);
19 if Available then
20 case C is
21 when 'q' | 'Q' =>
22 Repository.Quit;
23 select
24 accept Stop;
25 exit;
26 or
27 terminate;
28 end select;
29 when others =>
30 null;
31 end case;
32 end if;
33 select
34 accept Stop;
35 exit;
36 or
37 delay 0.5;
38 end select;
39 end loop;
40 end Handler_Task;
41
42 protected body Repository is
43
44 procedure Quit is
45 begin
46 Quit_Pressed := True;
47 Ada.Text_IO.New_Line;
48 Ada.Text_IO.Put_Line ("music213 will end at the end of this song");
49 end Quit;
50
51 function Have_To_Quit return Boolean is
52 begin
53 return Quit_Pressed;
54 end Have_To_Quit;
55
56 end Repository;
57
58 end Commands;
0 package Commands is
1
2 task type Handler_Task is
3 entry Start;
4 entry Stop;
5 end Handler_Task;
6
7 protected Repository is
8 procedure Quit;
9 function Have_To_Quit return Boolean;
10 private
11 Quit_Pressed : Boolean := False;
12 end Repository;
13
14 end Commands;
4040 Ignore extension case.
4141 .IP -L
4242 List files and exit.
43 .IP -T
44 Start a task that handle commands, only one command supported : quit,
45 using q or Q will quit the application at the end of the current song.
4346 .IP -D
4447 Set music123 not to delay between songs. (May make music123 harder to
4548 kill).
66
77 with Support_Routines; use Support_Routines;
88 with Intl; use Intl;
9 with Commands;
910
1011 procedure Music123 is
1112 Arg_Num : Positive;
13 Option_Task : Boolean := False;
1214 Option_Quiet : Boolean := False;
1315 Option_Recurse : Boolean := False;
1416 Option_Random : Boolean := False;
1921 Delay_Length : Duration := 0.5;
2022 File_List : UString_List.Vector;
2123 Program_List : Tool_List.Vector;
24 Command_Task : Commands.Handler_Task;
2225
2326 function N (Msg : String) return String renames Gettext;
2427 begin
8487 end if;
8588 elsif Argument (Arg_Num) = "-L" then
8689 Option_List_Files_Only := True;
90 elsif Argument (Arg_Num) = "-T" then
91 Option_Task := True;
8792 elsif Argument (Arg_Num) = "--" then
8893 for I in Arg_Num + 1 .. Argument_Count loop
8994 if Check_Filename (Argument (I),
116121 return;
117122 end if;
118123
124 if Option_Task then
125 Command_Task.Start;
126 end if;
127
119128 Play_Songs
120129 (File_List,
121130 Program_List,
126135 Option_Eternal_Random => Option_Eternal_Random,
127136 Option_Ignore_Extension_Case => Option_Ignore_Extension_Case);
128137
138 if Option_Task then
139 Command_Task.Stop;
140 end if;
141
129142 exception
130143 when Noted_Error =>
131144 Set_Exit_Status (Failure);
4141 Ignore extension case.
4242 .IP -L
4343 List files and exit.
44 .IP -T
45 Start a task that handle commands, only one command supported : quit,
46 using q or Q will quit the application at the end of the current song.
4447 .IP -D
4548 Nie rób przerw miêdzy piosenkami (mo¿e uczyniæ music123 trudniejszym
4649 do zabicia)
88
99 with Intl; use Intl;
1010 with Interfaces.C;
11
12 with Commands;
1113
1214 package body Support_Routines is
1315
383385 loop
384386 Song_Number :=
385387 Integer (Float'Floor (Random (Gen) * Float (Len))) + 1;
388 exit when Commands.Repository.Have_To_Quit;
386389 Play_A_Song (File_List.Element (Song_Number),
387390 Option_Quiet);
388391 end loop;
395398
396399 loop
397400 for I in File_List.First_Index .. File_List.Last_Index loop
401 exit when Commands.Repository.Have_To_Quit;
398402 Play_A_Song (File_List.Element (I), Option_Quiet);
399403 delay (Delay_Length);
400404 end loop;
405 exit when Commands.Repository.Have_To_Quit;
401406 exit when not Option_Loop;
402407 end loop;
403408 end Play_Songs;