-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathasound_dynamic.pas
184 lines (139 loc) · 4.96 KB
/
asound_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
unit Asound_dynamic;
(********************************************************************************)
(* *)
(* WARNING: This is a machine-generated file and manual changes will be lost. *)
(* *)
(********************************************************************************)
(*
* Please refer to AsoundDefs.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 AsoundDefs.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 AsoundDefs.inc }
{$undef EARLY }
{$undef CONSTS }
{$define TYPES }
{$undef PROCS }
{$undef VPROCS }
{$i AsoundDefs.inc }
(* These are the type descriptions of fields used to hold references to the *)
(* methods listed in AsoundDefs.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_strerror= function(errnum: cint): PChar; cdecl;
type
TAsound= class(TDynamicModule)
strict private
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 AsoundDefs.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 Asound(): TAsound; 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
xAsound: TAsound= nil;
constructor TAsound.Create(const LoadName: string);
begin
inherited Create(loadName);
{$ifdef PRELOAD_ROUTINES }
Fsnd_strerror := Tsnd_strerror(LoadRoutine('snd_strerror'));
LoadVarargsRoutine;
{$else }
Fsnd_strerror := nil;
{$endif PRELOAD_ROUTINES }
end { TAsound.Create } ;
(************************************************************************** DCN *)
procedure TAsound.LoadVarargsRoutine(loadName: string= ''; keepGoing: boolean= false);
begin
loadName := Trim(loadName);
if loadName = '*' then
loadName := '';
end { TAsound.LoadVarargsRoutine } ;
(************************************************************************** DLV *)
function TAsound.snd_strerror(errnum: cint): PChar; cdecl;
begin
LoadRoutine(pointer(Fsnd_strerror), 'snd_strerror');
result := Fsnd_strerror(errnum)
end { TAsound.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 Asound(): TAsound; inline;
begin
if not Assigned(xAsound) then
InitialiseLibrary;
result := xAsound
end { Asound } ;
(* Create the object and optionally load the shared object library.
*)
procedure InitialiseLibrary(const moduleName: string= DefaultModuleName;
earlyLoad: boolean= DefaultEarlyLoad);
begin
if not Assigned(xAsound) then begin
xAsound := TAsound.Create(moduleName);
if Assigned(xAsound) and earlyLoad then
xAsound.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(xAsound)
end.
// MD5 3673724605e7aac61fe03aa5546da321 c75c58b4925e64ab9f15ce408ed25d97 ANSI LF {}