-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathasoundpcm_dynamic.pas
256 lines (193 loc) · 7.94 KB
/
asoundpcm_dynamic.pas
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
unit AsoundPcm_dynamic;
(********************************************************************************)
(* *)
(* WARNING: This is a machine-generated file and manual changes will be lost. *)
(* *)
(********************************************************************************)
(*
* Please refer to AsoundPcmDefs.inc and other accompanying files for
* licensing and disclaimer information.
*)
{$mode ObjFPC }{$longstrings on }
{$push }
{$macro on }
{$define CDECL__:= }
{$define CDECL_VARARGS__:= }
{$define LIBASOUND__:= }
{$define _LIBASOUND__:= asound }
{$define DYNAMIC }
{$define EARLY }
{$undef CONSTS }
{$undef TYPES }
{$undef PROCS }
{$undef VPROCS }
{$i AsoundPcmDefs.inc }
interface
uses
Classes, SysUtils, UnixType, DynamicModule;
const
DefaultModuleName= 'libasound.so';
DefaultEarlyLoad= true;
HasLoadVarargsRoutine= true; (* Presence is implementation-defined *)
{$undef EARLY }
{$define CONSTS }
{$undef TYPES }
{$undef PROCS }
{$undef VPROCS }
{$i AsoundPcmDefs.inc }
{$undef EARLY }
{$undef CONSTS }
{$define TYPES }
{$undef PROCS }
{$undef VPROCS }
{$i AsoundPcmDefs.inc }
(* These are the type descriptions of fields used to hold references to the *)
(* methods listed in AsoundPcmDefs.inc (below). It is important that these types *)
(* be considered subordinate to the definitions in the include file, since as *)
(* well as being used here the include file might potentially be treated by the *)
(* shared library as the authoritative list of what it is to export. *)
type
Tsnd_pcm_open= function(pcm: PPsnd_pcm_t; Name: PChar; stream: snd_pcm_stream_t; mode: cint): cint; cdecl;
Tsnd_pcm_set_params= function(pcm: Psnd_pcm_t; format: snd_pcm_format_t; access: snd_pcm_access_t; channels, rate: cuint; soft_resample: cint; latency: cuint): cint; cdecl;
Tsnd_pcm_writei= function(pcm: Psnd_pcm_t; buffer: Pointer; size: snd_pcm_uframes_t): snd_pcm_sframes_t; cdecl;
Tsnd_pcm_recover= function(pcm: Psnd_pcm_t; err, silent: cint): cint; cdecl;
Tsnd_pcm_drain= function(pcm: Psnd_pcm_t): cint; cdecl;
Tsnd_pcm_close= function(pcm: Psnd_pcm_t): cint; cdecl;
Tsnd_strerror= function(errnum: cint): PChar; cdecl;
type
TAsoundPcm= class(TDynamicModule)
strict private
Fsnd_pcm_open: Tsnd_pcm_open;
Fsnd_pcm_set_params: Tsnd_pcm_set_params;
Fsnd_pcm_writei: Tsnd_pcm_writei;
Fsnd_pcm_recover: Tsnd_pcm_recover;
Fsnd_pcm_drain: Tsnd_pcm_drain;
Fsnd_pcm_close: Tsnd_pcm_close;
Fsnd_strerror: Tsnd_strerror;
public
(* Case-sensitivity depends on the operating system and filesystem.
*)
constructor Create(const LoadName: string);
procedure LoadVarargsRoutine(loadName: string= ''; keepGoing: boolean= false);
{$undef EARLY }
{$undef CONSTS }
{$undef TYPES }
{$define PROCS }
{$undef VPROCS }
{$i AsoundPcmDefs.inc }
{$pop }
end;
(* Return either a static or a dynamic representation of the Asound embedding
library (libasound.so or similar). In this case it is dynamic.
*)
function AsoundPcm(): TAsoundPcm; inline;
(* Create the object and optionally load the shared object library.
*)
procedure InitialiseLibrary(const moduleName: string= DefaultModuleName;
earlyLoad: boolean= DefaultEarlyLoad);
(* Create the object and optionally load the shared object library.
*)
procedure InitializeLibrary(const moduleName: string= DefaultModuleName;
earlyLoad: boolean= DefaultEarlyLoad);
implementation
var
xAsoundPcm: TAsoundPcm= nil;
constructor TAsoundPcm.Create(const LoadName: string);
begin
inherited Create(loadName);
{$ifdef PRELOAD_ROUTINES }
Fsnd_pcm_open := Tsnd_pcm_open(LoadRoutine('snd_pcm_open'));
Fsnd_pcm_set_params := Tsnd_pcm_set_params(LoadRoutine('snd_pcm_set_params'));
Fsnd_pcm_writei := Tsnd_pcm_writei(LoadRoutine('snd_pcm_writei'));
Fsnd_pcm_recover := Tsnd_pcm_recover(LoadRoutine('snd_pcm_recover'));
Fsnd_pcm_drain := Tsnd_pcm_drain(LoadRoutine('snd_pcm_drain'));
Fsnd_pcm_close := Tsnd_pcm_close(LoadRoutine('snd_pcm_close'));
Fsnd_strerror := Tsnd_strerror(LoadRoutine('snd_strerror'));
LoadVarargsRoutine;
{$else }
Fsnd_pcm_open := nil;
Fsnd_pcm_set_params := nil;
Fsnd_pcm_writei := nil;
Fsnd_pcm_recover := nil;
Fsnd_pcm_drain := nil;
Fsnd_pcm_close := nil;
Fsnd_strerror := nil;
{$endif PRELOAD_ROUTINES }
end { TAsoundPcm.Create } ;
(************************************************************************** DCN *)
procedure TAsoundPcm.LoadVarargsRoutine(loadName: string= ''; keepGoing: boolean= false);
begin
loadName := Trim(loadName);
if loadName = '*' then
loadName := '';
end { TAsoundPcm.LoadVarargsRoutine } ;
(************************************************************************** DLV *)
function TAsoundPcm.snd_pcm_open(pcm: PPsnd_pcm_t; Name: PChar; stream: snd_pcm_stream_t; mode: cint): cint; cdecl;
begin
LoadRoutine(pointer(Fsnd_pcm_open), 'snd_pcm_open');
result := Fsnd_pcm_open(pcm, Name, stream, mode)
end { TAsoundPcm.snd_pcm_open } ;
function TAsoundPcm.snd_pcm_set_params(pcm: Psnd_pcm_t; format: snd_pcm_format_t; access: snd_pcm_access_t; channels, rate: cuint; soft_resample: cint; latency: cuint): cint; cdecl;
begin
LoadRoutine(pointer(Fsnd_pcm_set_params), 'snd_pcm_set_params');
result := Fsnd_pcm_set_params(pcm, format, access, channels, rate, soft_resample, latency)
end { TAsoundPcm.snd_pcm_set_params } ;
function TAsoundPcm.snd_pcm_writei(pcm: Psnd_pcm_t; buffer: Pointer; size: snd_pcm_uframes_t): snd_pcm_sframes_t; cdecl;
begin
LoadRoutine(pointer(Fsnd_pcm_writei), 'snd_pcm_writei');
result := Fsnd_pcm_writei(pcm, buffer, size)
end { TAsoundPcm.snd_pcm_writei } ;
function TAsoundPcm.snd_pcm_recover(pcm: Psnd_pcm_t; err, silent: cint): cint; cdecl;
begin
LoadRoutine(pointer(Fsnd_pcm_recover), 'snd_pcm_recover');
result := Fsnd_pcm_recover(pcm, err, silent)
end { TAsoundPcm.snd_pcm_recover } ;
function TAsoundPcm.snd_pcm_drain(pcm: Psnd_pcm_t): cint; cdecl;
begin
LoadRoutine(pointer(Fsnd_pcm_drain), 'snd_pcm_drain');
result := Fsnd_pcm_drain(pcm)
end { TAsoundPcm.snd_pcm_drain } ;
function TAsoundPcm.snd_pcm_close(pcm: Psnd_pcm_t): cint; cdecl;
begin
LoadRoutine(pointer(Fsnd_pcm_close), 'snd_pcm_close');
result := Fsnd_pcm_close(pcm)
end { TAsoundPcm.snd_pcm_close } ;
function TAsoundPcm.snd_strerror(errnum: cint): PChar; cdecl;
begin
LoadRoutine(pointer(Fsnd_strerror), 'snd_strerror');
result := Fsnd_strerror(errnum)
end { TAsoundPcm.snd_strerror } ;
(*************************************************************************** DB *)
(* Return either a static or a dynamic representation of the Asound embedding
library (libasound.so or similar). In this case it is dynamic.
*)
function AsoundPcm(): TAsoundPcm; inline;
begin
if not Assigned(xAsoundPcm) then
InitialiseLibrary;
result := xAsoundPcm
end { AsoundPcm } ;
(* Create the object and optionally load the shared object library.
*)
procedure InitialiseLibrary(const moduleName: string= DefaultModuleName;
earlyLoad: boolean= DefaultEarlyLoad);
begin
if not Assigned(xAsoundPcm) then begin
xAsoundPcm := TAsoundPcm.Create(moduleName);
if Assigned(xAsoundPcm) and earlyLoad then
xAsoundPcm.LoadModule (* So that ModuleInMemory is correct *)
end
end { InitialiseLibrary } ;
(* Create the object and optionally load the shared object library.
*)
procedure InitializeLibrary(const moduleName: string= DefaultModuleName;
earlyLoad: boolean= DefaultEarlyLoad);
begin
InitialiseLibrary(moduleName, earlyLoad)
end { InitializeLibrary } ;
initialization
// InitialiseLibrary
finalization
FreeAndNil(xAsoundPcm)
end.
// MD5 8a3a909554b541a742b57df6e9c0cb01 9a7c7158391d67a527a4ecb90ffd03a2 ANSI LF {}