* 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
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
|
1 | 1 |
changes and bug fixes)
|
2 | 2 |
|
3 | 3 |
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;
|
40 | 40 |
Ignore extension case.
|
41 | 41 |
.IP -L
|
42 | 42 |
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.
|
43 | 46 |
.IP -D
|
44 | 47 |
Set music123 not to delay between songs. (May make music123 harder to
|
45 | 48 |
kill).
|
6 | 6 |
|
7 | 7 |
with Support_Routines; use Support_Routines;
|
8 | 8 |
with Intl; use Intl;
|
|
9 |
with Commands;
|
9 | 10 |
|
10 | 11 |
procedure Music123 is
|
11 | 12 |
Arg_Num : Positive;
|
|
13 |
Option_Task : Boolean := False;
|
12 | 14 |
Option_Quiet : Boolean := False;
|
13 | 15 |
Option_Recurse : Boolean := False;
|
14 | 16 |
Option_Random : Boolean := False;
|
|
19 | 21 |
Delay_Length : Duration := 0.5;
|
20 | 22 |
File_List : UString_List.Vector;
|
21 | 23 |
Program_List : Tool_List.Vector;
|
|
24 |
Command_Task : Commands.Handler_Task;
|
22 | 25 |
|
23 | 26 |
function N (Msg : String) return String renames Gettext;
|
24 | 27 |
begin
|
|
84 | 87 |
end if;
|
85 | 88 |
elsif Argument (Arg_Num) = "-L" then
|
86 | 89 |
Option_List_Files_Only := True;
|
|
90 |
elsif Argument (Arg_Num) = "-T" then
|
|
91 |
Option_Task := True;
|
87 | 92 |
elsif Argument (Arg_Num) = "--" then
|
88 | 93 |
for I in Arg_Num + 1 .. Argument_Count loop
|
89 | 94 |
if Check_Filename (Argument (I),
|
|
116 | 121 |
return;
|
117 | 122 |
end if;
|
118 | 123 |
|
|
124 |
if Option_Task then
|
|
125 |
Command_Task.Start;
|
|
126 |
end if;
|
|
127 |
|
119 | 128 |
Play_Songs
|
120 | 129 |
(File_List,
|
121 | 130 |
Program_List,
|
|
126 | 135 |
Option_Eternal_Random => Option_Eternal_Random,
|
127 | 136 |
Option_Ignore_Extension_Case => Option_Ignore_Extension_Case);
|
128 | 137 |
|
|
138 |
if Option_Task then
|
|
139 |
Command_Task.Stop;
|
|
140 |
end if;
|
|
141 |
|
129 | 142 |
exception
|
130 | 143 |
when Noted_Error =>
|
131 | 144 |
Set_Exit_Status (Failure);
|
41 | 41 |
Ignore extension case.
|
42 | 42 |
.IP -L
|
43 | 43 |
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.
|
44 | 47 |
.IP -D
|
45 | 48 |
Nie rób przerw miêdzy piosenkami (mo¿e uczyniæ music123 trudniejszym
|
46 | 49 |
do zabicia)
|
8 | 8 |
|
9 | 9 |
with Intl; use Intl;
|
10 | 10 |
with Interfaces.C;
|
|
11 |
|
|
12 |
with Commands;
|
11 | 13 |
|
12 | 14 |
package body Support_Routines is
|
13 | 15 |
|
|
383 | 385 |
loop
|
384 | 386 |
Song_Number :=
|
385 | 387 |
Integer (Float'Floor (Random (Gen) * Float (Len))) + 1;
|
|
388 |
exit when Commands.Repository.Have_To_Quit;
|
386 | 389 |
Play_A_Song (File_List.Element (Song_Number),
|
387 | 390 |
Option_Quiet);
|
388 | 391 |
end loop;
|
|
395 | 398 |
|
396 | 399 |
loop
|
397 | 400 |
for I in File_List.First_Index .. File_List.Last_Index loop
|
|
401 |
exit when Commands.Repository.Have_To_Quit;
|
398 | 402 |
Play_A_Song (File_List.Element (I), Option_Quiet);
|
399 | 403 |
delay (Delay_Length);
|
400 | 404 |
end loop;
|
|
405 |
exit when Commands.Repository.Have_To_Quit;
|
401 | 406 |
exit when not Option_Loop;
|
402 | 407 |
end loop;
|
403 | 408 |
end Play_Songs;
|