summaryrefslogtreecommitdiff
path: root/src/portaudio-devices.ads
blob: aae6674737f1c3b5a5de8da15739dd1a40762dab (plain)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171


--  Programmed by Jedidiah Barber
--  Released into the public domain


pragma Ada_2012;


private with

    Interfaces.C.Strings,
    System;


package Portaudio.Devices is


    ---------------------------------
    --  Data Types and Structures  --
    ---------------------------------

    type Host_API_Info is tagged private;

    function Kind
           (Info : in Host_API_Info)
        return Host_API_Kind;

    function Name
           (Info : in Host_API_Info)
        return String;

    function Device_Count
           (Info : in Host_API_Info)
        return Natural;

    function Default_Input_Device
           (Info : in Host_API_Info)
        return Device_Index;

    function Default_Output_Device
           (Info : in Host_API_Info)
        return Device_Index;


    type Device_Info is tagged private;

    function Name
           (Info : in Device_Info)
        return String;

    function Host_API
           (Info : in Device_Info)
        return Host_API_Index;

    function Max_Input_Channels
           (Info : in Device_Info)
        return Natural;

    function Max_Output_Channels
           (Info : in Device_Info)
        return Natural;

    function Default_Low_Input_Latency
           (Info : in Device_Info)
        return Time;

    function Default_Low_Output_Latency
           (Info : in Device_Info)
        return Time;

    function Default_High_Input_Latency
           (Info : in Device_Info)
        return Time;

    function Default_High_Output_Latency
           (Info : in Device_Info)
        return Time;

    function Default_Sample_Rate
           (Info : in Device_Info)
        return Hertz;




    -----------------------
    --  API Subprograms  --
    -----------------------

    function Get_Host_API_Count
        return Natural;

    function Get_Default_Host_API
        return Host_API_Index
    with Post => Get_Default_Host_API'Result in
            Host_API_Index (1) .. Host_API_Index (Get_Host_API_Count);

    function Get_Host_API_Info
           (Index : in Host_API_Index)
        return Host_API_Info
    with Pre => Index in Host_API_Index (1) .. Host_API_Index (Get_Host_API_Count);

    function To_Host_API_Index
           (Kind : in Host_API_Kind)
        return Host_API_Index
    with Post => To_Host_API_Index'Result in
            Host_API_Index (1) .. Host_API_Index (Get_Host_API_Count);

    function To_Device_Index
           (Host_API    : in Host_API_Index;
            Host_Device : in Positive)
        return Device_Index
    with Pre => Host_API in Host_API_Index (1) .. Host_API_Index (Get_Host_API_Count) and
            Host_Device in 1 .. Get_Host_API_Info (Host_API).Device_Count,
        Post => To_Device_Index'Result in
            Device_Index (1) .. Device_Index (Get_Device_Count);

    function Get_Device_Count
        return Natural;

    function Get_Default_Input_Device
        return Device_Index;

    function Get_Default_Output_Device
        return Device_Index;

    function Get_Device_Info
           (Index : in Device_Index)
        return Device_Info
    with Pre => Index in Device_Index (1) .. Device_Index (Get_Device_Count);


private


    type C_Host_API_Info is record
        My_Struct_Version : Interfaces.C.int;
        My_Host_API_Type  : Interfaces.C.int;
        My_Name           : Interfaces.C.Strings.chars_ptr;
        My_Device_Count   : Interfaces.C.int;
        My_Default_Input  : Interfaces.C.int;
        My_Default_Output : Interfaces.C.int;
    end record with Convention => C;

    type Host_API_Info is tagged record
        Ptr : System.Address;
    end record;


    type C_Device_Info is record
        My_Struct_Version      : Interfaces.C.int;
        My_Name                : Interfaces.C.Strings.chars_ptr;
        My_Host_API_Index      : Interfaces.C.int;
        My_Input_Channels      : Interfaces.C.int;
        My_Output_Channels     : Interfaces.C.int;
        My_Low_Input_Latency   : Interfaces.C.double;
        My_Low_Output_Latency  : Interfaces.C.double;
        My_High_Input_Latency  : Interfaces.C.double;
        My_High_Output_Latency : Interfaces.C.double;
        My_Sample_Rate         : Interfaces.C.double;
    end record with Convention => C;

    type Device_Info is tagged record
        Ptr : System.Address;
    end record;


end Portaudio.Devices;