-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplayer-multi_client.adb
62 lines (47 loc) · 1.41 KB
/
player-multi_client.adb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
with Player.Aux;
with Interfaces.C; use Interfaces;
package body Player.Multi_Client is
subtype Ptr is Types.Handle;
--------------
-- Finalize --
--------------
procedure Finalize (This : in out Object) is
begin
Destroy (This.Handle);
end Finalize;
procedure Initialize (This : in out Object) is
begin
This.Handle := Create;
end Initialize;
function Get_Handle (This : in Object) return Types.Handle is
begin
return This.Handle;
end Get_Handle;
----------
-- Peek --
----------
function Peek (This : in Object; Timeout : in Duration := 0.0)
return Boolean
is
function C_Peek (This : in Ptr; Timeout : in C.int) return C.int;
pragma Import (C, C_Peek, "playerc_mclient_peek");
Ret : constant C.int := C_Peek (This.Handle, C.Int (Timeout * 1000.0));
use type C.int;
begin
if Ret = -1 then
Aux.Check (-1); -- Force exception.
return False; -- Non reachable.
else
return Ret = 1;
end if;
end Peek;
----------
-- Read --
----------
procedure Read (This : in out Object; Timeout : in Duration := -1.0) is
function C_Read (This : in Ptr; Timeout : in C.int) return C.int;
pragma Import (C, C_Read, "playerc_mclient_read");
begin
Aux.Check (C_Read (This.Handle, C.Int (Timeout * 1000.0)));
end Read;
end Player.Multi_Client;