-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathlibrarytester_fpGUI.pas
More file actions
345 lines (298 loc) · 10.2 KB
/
librarytester_fpGUI.pas
File metadata and controls
345 lines (298 loc) · 10.2 KB
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
program librarytester_fpGUI;
{$mode objfpc}{$H+}
{$DEFINE UseCThreads}
uses
{$IFDEF UNIX}
cthreads,
cwstring,
{$ENDIF}
SysUtils,
dynlibs,
uos_bs2b,
ctypes,
Math,
Classes,
fpg_button,
fpg_widget,
fpg_label,
fpg_Editbtn,
fpg_Panel,
fpg_base,
fpg_main,
fpg_form { you can add units after this };
type
TSimpleplayer = class(TfpgForm)
procedure uos_logo(Sender: TObject);
private
{@VFD_HEAD_BEGIN: Simpleplayer}
Custom1: TfpgWidget;
Labelport: TfpgLabel;
btnLoad: TfpgButton;
FilenameEdit1: TfpgFileNameEdit;
FilenameEdit2: TfpgFileNameEdit;
Labelsnf: TfpgLabel;
Labelmpg: TfpgLabel;
Labelst: TfpgLabel;
FilenameEdit3: TfpgFileNameEdit;
FilenameEdit5: TfpgFileNameEdit;
{@VFD_HEAD_END: Simpleplayer}
public
procedure AfterCreate; override;
procedure btnCloseClick(Sender: TObject);
procedure btnLoadClick(Sender: TObject);
end;
{@VFD_NEWFORM_DECL}
{@VFD_NEWFORM_IMPL}
var
ordir, opath: string;
Pa_Handle: TLibHandle = dynlibs.NilHandle;
procedure TSimpleplayer.btnCloseClick(Sender: TObject);
begin
if Pa_Handle <> DynLibs.NilHandle then
DynLibs.UnloadLibrary(Pa_Handle);
Pa_Handle := DynLibs.NilHandle;
end;
procedure TSimpleplayer.btnLoadClick(Sender: TObject);
begin
Pa_Handle := DynLibs.SafeLoadLibrary(FilenameEdit1.FileName); // obtain the handle we want
if Pa_Handle <> DynLibs.NilHandle then
btnLoad.Text := 'PortAudio=OK '
else
btnLoad.Text := 'PortAudio not load ';
if Pa_Handle <> DynLibs.NilHandle then
DynLibs.UnloadLibrary(Pa_Handle);
Pa_Handle := DynLibs.SafeLoadLibrary(FilenameEdit2.FileName); // obtain the handle we want
if Pa_Handle <> DynLibs.NilHandle then
btnLoad.Text := btnLoad.Text + 'SndFile=OK '
else
btnLoad.Text := btnLoad.Text + 'SndFile not load ';
if Pa_Handle <> DynLibs.NilHandle then
DynLibs.UnloadLibrary(Pa_Handle);
Pa_Handle := DynLibs.SafeLoadLibrary(FilenameEdit3.FileName); // obtain the handle we want
if Pa_Handle <> DynLibs.NilHandle then
btnLoad.Text := btnLoad.Text + 'MPG123=OK '
else
btnLoad.Text := btnLoad.Text + 'MPG123 not load ';
if Pa_Handle <> DynLibs.NilHandle then
DynLibs.UnloadLibrary(Pa_Handle);
Pa_Handle := DynLibs.SafeLoadLibrary(FilenameEdit5.FileName); // obtain the handle we want
if Pa_Handle <> DynLibs.NilHandle then
btnLoad.Text := btnLoad.Text + 'SoundTouch=OK'
else
btnLoad.Text := btnLoad.Text + 'SoundTouch not load';
if Pa_Handle <> DynLibs.NilHandle then
DynLibs.UnloadLibrary(Pa_Handle);
end;
procedure TSimpleplayer.AfterCreate;
begin
{%region 'Auto-generated GUI code' -fold}
{@VFD_BODY_BEGIN: Simpleplayer}
Name := 'Simpleplayer';
SetPosition(491, 214, 502, 206);
WindowTitle := 'Libraries Tester';
IconName := '';
BackGroundColor := $80000001;
Hint := '';
WindowPosition := wpScreenCenter;
Ondestroy := @btnCloseClick;
Custom1 := TfpgWidget.Create(self);
with Custom1 do
begin
Name := 'Custom1';
SetPosition(10, 8, 115, 155);
OnPaint := @uos_logo;
end;
Labelport := TfpgLabel.Create(self);
with Labelport do
begin
Name := 'Labelport';
SetPosition(136, 0, 320, 15);
Alignment := taCenter;
FontDesc := '#Label1';
ParentShowHint := False;
Text := 'Folder + filename of PortAudio Library';
Hint := '';
end;
btnLoad := TfpgButton.Create(self);
with btnLoad do
begin
Name := 'btnLoad';
SetPosition(16, 168, 476, 31);
Text := 'Test to load that libraries';
FontDesc := '#Label1';
ImageName := '';
ParentShowHint := False;
TabOrder := 0;
Hint := '';
onclick := @btnLoadClick;
end;
FilenameEdit1 := TfpgFileNameEdit.Create(self);
with FilenameEdit1 do
begin
Name := 'FilenameEdit1';
SetPosition(136, 16, 356, 24);
ExtraHint := '';
FileName := '';
Filter := '';
InitialDir := '';
TabOrder := 3;
end;
FilenameEdit2 := TfpgFileNameEdit.Create(self);
with FilenameEdit2 do
begin
Name := 'FilenameEdit2';
SetPosition(136, 56, 356, 24);
ExtraHint := '';
FileName := '';
Filter := '';
InitialDir := '';
TabOrder := 4;
end;
Labelsnf := TfpgLabel.Create(self);
with Labelsnf do
begin
Name := 'Labelsnf';
SetPosition(140, 40, 316, 15);
Alignment := taCenter;
FontDesc := '#Label1';
ParentShowHint := False;
Text := 'Folder + filename of SndFile Library';
Hint := '';
end;
Labelmpg := TfpgLabel.Create(self);
with Labelmpg do
begin
Name := 'Labelmpg';
SetPosition(136, 80, 316, 15);
Alignment := taCenter;
FontDesc := '#Label1';
ParentShowHint := False;
Text := 'Folder + filename of Mpg123 Library';
Hint := '';
end;
Labelst := TfpgLabel.Create(self);
with Labelst do
begin
Name := 'Labelst';
SetPosition(136, 120, 316, 15);
Alignment := taCenter;
FontDesc := '#Label1';
ParentShowHint := False;
Text := 'Folder + filename of SoundTouch Library';
Hint := '';
end;
FilenameEdit3 := TfpgFileNameEdit.Create(self);
with FilenameEdit3 do
begin
Name := 'FilenameEdit3';
SetPosition(136, 96, 356, 24);
ExtraHint := '';
FileName := '';
Filter := '';
InitialDir := '';
TabOrder := 12;
end;
FilenameEdit5 := TfpgFileNameEdit.Create(self);
with FilenameEdit5 do
begin
Name := 'FilenameEdit5';
SetPosition(136, 136, 356, 24);
ExtraHint := '';
FileName := '';
Filter := '';
InitialDir := '';
TabOrder := 12;
end;
{@VFD_BODY_END: Simpleplayer}
{%endregion}
//////////////////////
ordir := IncludeTrailingBackslash(ExtractFilePath(ParamStr(0)));
Height := 197;
{$IFDEF Windows}
{$if defined(cpu64)}
FilenameEdit1.FileName := ordir + 'lib\Windows\64bit\LibPortaudio-64.dll';
FilenameEdit2.FileName := ordir + 'lib\Windows\64bit\LibSndFile-64.dll';
FilenameEdit3.FileName := ordir + 'lib\Windows\64bit\LibMpg123-64.dll';
FilenameEdit5.FileName := ordir + 'lib\Windows\64bit\LibSoundTouch-64.dll';
{$else}
FilenameEdit1.FileName := ordir + 'lib\Windows\32bit\LibPortaudio-32.dll';
FilenameEdit2.FileName := ordir + 'lib\Windows\32bit\LibSndFile-32.dll';
FilenameEdit3.FileName := ordir + 'lib\Windows\32bit\LibMpg123-32.dll';
FilenameEdit5.FileName := ordir + 'lib\Windows\32bit\LibSoundTouch-32.dll';
{$endif}
{$ENDIF}
{$IFDEF Darwin}
opath := ordir;
opath := copy(opath, 1, Pos('/uos', opath) - 1);
FilenameEdit1.FileName := opath + '/lib/Mac/32bit/LibPortaudio-32.dylib';
FilenameEdit2.FileName := opath + '/lib/Mac/32bit/LibSndFile-32.dylib';
FilenameEdit3.FileName := opath + '/lib/Mac/32bit/LibMpg123-32.dylib';
FilenameEdit5.FileName := opath + '/lib/Mac/32bit/LibSoundTouch-32.dylib';
{$ENDIF}
{$if defined(CPUAMD64) and defined(linux) }
FilenameEdit1.FileName := ordir + 'lib/Linux/64bit/LibPortaudio-64.so';
FilenameEdit2.FileName := ordir + 'lib/Linux/64bit/LibSndFile-64.so';
FilenameEdit3.FileName := ordir + 'lib/Linux/64bit/LibMpg123-64.so';
FilenameEdit5.FileName := ordir + 'lib/Linux/64bit/plugin/LibSoundTouch-64.so';
{$ENDIF}
{$if defined(cpu86) and defined(linux)}
FilenameEdit1.FileName := ordir + 'lib/Linux/32bit/LibPortaudio-32.so';
FilenameEdit2.FileName := ordir + 'lib/Linux/32bit/LibSndFile-32.so';
FilenameEdit3.FileName := ordir + 'lib/Linux/32bit/LibMpg123-32.so';
FilenameEdit5.FileName := ordir + 'lib/Linux/32bit/plugin/LibSoundTouch-32.so';
{$ENDIF}
{$if defined(linux) and defined(cpuarm)}
FilenameEdit1.FileName := ordir + 'lib/Linux/arm_raspberrypi/libportaudio-arm.so';
FilenameEdit2.FileName := ordir + 'lib/Linux/arm_raspberrypi/libsndfile-arm.so';
FilenameEdit3.FileName := ordir + 'lib/Linux/arm_raspberrypi/libmpg123-arm.so';
{$ENDIF}
{$if defined(linux) and defined(cpuaarch64)}
FilenameEdit1 := ordir + 'lib/Linux/aarch64_raspberrypi/libportaudio_aarch64.so';
FilenameEdit2 := ordir + 'lib/Linux/aarch64_raspberrypi/libsndfile_aarch64.so';
FilenameEdit3 := ordir + 'lib/Linux/aarch64_raspberrypi/libmpg123_aarch64.so';
FilenameEdit5 := ordir + 'lib/Linux/aarch64_raspberrypi/plugin/libsoundtouch_aarch64.so';
{$ENDIF}
{$IFDEF freebsd}
{$if defined(cpu64)}
FilenameEdit1.FileName := ordir + 'lib/FreeBSD/64bit/libportaudio-64.so';
FilenameEdit2.FileName := ordir + 'lib/FreeBSD/64bit/libsndfile-64.so';
FilenameEdit3.FileName := ordir + 'lib/FreeBSD/64bit/libmpg123-64.so';
FilenameEdit5.FileName := ordir + 'lib/FreeBSD/64bit/LibSoundTouch-64.so';
{$else}
FilenameEdit1.FileName := ordir + 'lib/FreeBSD/32bit/libportaudio-32.so';
FilenameEdit2.FileName := ordir + 'lib/FreeBSD/32bit/libsndfile-32.so';
FilenameEdit3.FileName := ordir + 'lib/FreeBSD/32bit/libmpg123-32.so';
FilenameEdit5.FileName := ordir + 'lib/FreeBSD/32bit/LibSoundTouch-32.so';
{$endif}
{$ENDIF}
FilenameEdit1.Initialdir := ordir + 'lib';
FilenameEdit2.Initialdir := ordir + 'lib';
FilenameEdit3.Initialdir := ordir + 'lib';
FilenameEdit5.Initialdir := ordir + 'lib';
end;
procedure TSimpleplayer.uos_logo(Sender: TObject);
begin
with Custom1 do
begin
Canvas.GradientFill(GetClientRect, clgreen, clBlack, gdVertical);
Canvas.TextColor := clWhite;
Canvas.DrawText(60, 20, 'uos');
end;
end;
procedure MainProc;
var
frm: TSimpleplayer;
begin
fpgApplication.Initialize;
// frm := TSimpleplayer.Create(nil);
fpgApplication.CreateForm(TSimpleplayer, frm);
try
frm.Show;
fpgApplication.Run;
finally
frm.Free;
end;
end;
begin
MainProc;
end.