Commit f1c8545

Nick committed on
Removal of mme stuff... memory leak still here i think
commit f1c8545841ff2f429a20521dafbc938581896abd parent 6905b5c
2 changed files +86−160
ModifiedGBEmu.lps +78−74
@@ -11,7 +11,7 @@
11 <EditorIndex Value="-1"/> 11 <EditorIndex Value="-1"/>
12 <TopLine Value="2"/> 12 <TopLine Value="2"/>
13 <CursorPos X="14" Y="7"/> 13 <CursorPos X="14" Y="7"/>
14 <UsageCount Value="65"/> 14 <UsageCount Value="67"/>
15 <DefaultSyntaxHighlighter Value="Delphi"/> 15 <DefaultSyntaxHighlighter Value="Delphi"/>
16 </Unit0> 16 </Unit0>
17 <Unit1> 17 <Unit1>
@@ -20,9 +20,9 @@
20 <ComponentName Value="frmGameboy"/> 20 <ComponentName Value="frmGameboy"/>
21 <HasResources Value="True"/> 21 <HasResources Value="True"/>
22 <ResourceBaseClass Value="Form"/> 22 <ResourceBaseClass Value="Form"/>
23 <EditorIndex Value="2"/> 23 <EditorIndex Value="1"/>
24 <CursorPos X="5" Y="16"/> 24 <CursorPos X="5" Y="16"/>
25 <UsageCount Value="65"/> 25 <UsageCount Value="67"/>
26 <Loaded Value="True"/> 26 <Loaded Value="True"/>
27 <LoadedDesigner Value="True"/> 27 <LoadedDesigner Value="True"/>
28 <DefaultSyntaxHighlighter Value="Delphi"/> 28 <DefaultSyntaxHighlighter Value="Delphi"/>
@@ -33,7 +33,7 @@
33 <EditorIndex Value="-1"/> 33 <EditorIndex Value="-1"/>
34 <TopLine Value="1374"/> 34 <TopLine Value="1374"/>
35 <CursorPos X="22" Y="1374"/> 35 <CursorPos X="22" Y="1374"/>
36 <UsageCount Value="65"/> 36 <UsageCount Value="67"/>
37 <DefaultSyntaxHighlighter Value="Delphi"/> 37 <DefaultSyntaxHighlighter Value="Delphi"/>
38 </Unit2> 38 </Unit2>
39 <Unit3> 39 <Unit3>
@@ -43,7 +43,7 @@
43 <WindowIndex Value="-1"/> 43 <WindowIndex Value="-1"/>
44 <TopLine Value="-1"/> 44 <TopLine Value="-1"/>
45 <CursorPos X="-1" Y="-1"/> 45 <CursorPos X="-1" Y="-1"/>
46 <UsageCount Value="65"/> 46 <UsageCount Value="67"/>
47 <DefaultSyntaxHighlighter Value="Delphi"/> 47 <DefaultSyntaxHighlighter Value="Delphi"/>
48 </Unit3> 48 </Unit3>
49 <Unit4> 49 <Unit4>
@@ -53,7 +53,7 @@
53 <WindowIndex Value="-1"/> 53 <WindowIndex Value="-1"/>
54 <TopLine Value="-1"/> 54 <TopLine Value="-1"/>
55 <CursorPos X="-1" Y="-1"/> 55 <CursorPos X="-1" Y="-1"/>
56 <UsageCount Value="65"/> 56 <UsageCount Value="67"/>
57 <DefaultSyntaxHighlighter Value="Delphi"/> 57 <DefaultSyntaxHighlighter Value="Delphi"/>
58 </Unit4> 58 </Unit4>
59 <Unit5> 59 <Unit5>
@@ -61,7 +61,7 @@
61 <IsPartOfProject Value="True"/> 61 <IsPartOfProject Value="True"/>
62 <EditorIndex Value="-1"/> 62 <EditorIndex Value="-1"/>
63 <CursorPos X="13" Y="21"/> 63 <CursorPos X="13" Y="21"/>
64 <UsageCount Value="65"/> 64 <UsageCount Value="67"/>
65 <DefaultSyntaxHighlighter Value="Delphi"/> 65 <DefaultSyntaxHighlighter Value="Delphi"/>
66 </Unit5> 66 </Unit5>
67 <Unit6> 67 <Unit6>
@@ -70,7 +70,7 @@
70 <EditorIndex Value="-1"/> 70 <EditorIndex Value="-1"/>
71 <TopLine Value="78"/> 71 <TopLine Value="78"/>
72 <CursorPos X="17" Y="92"/> 72 <CursorPos X="17" Y="92"/>
73 <UsageCount Value="65"/> 73 <UsageCount Value="67"/>
74 <DefaultSyntaxHighlighter Value="Delphi"/> 74 <DefaultSyntaxHighlighter Value="Delphi"/>
75 </Unit6> 75 </Unit6>
76 <Unit7> 76 <Unit7>
@@ -79,7 +79,7 @@
79 <EditorIndex Value="-1"/> 79 <EditorIndex Value="-1"/>
80 <TopLine Value="332"/> 80 <TopLine Value="332"/>
81 <CursorPos Y="332"/> 81 <CursorPos Y="332"/>
82 <UsageCount Value="65"/> 82 <UsageCount Value="67"/>
83 <DefaultSyntaxHighlighter Value="Delphi"/> 83 <DefaultSyntaxHighlighter Value="Delphi"/>
84 </Unit7> 84 </Unit7>
85 <Unit8> 85 <Unit8>
@@ -88,7 +88,7 @@
88 <EditorIndex Value="-1"/> 88 <EditorIndex Value="-1"/>
89 <TopLine Value="284"/> 89 <TopLine Value="284"/>
90 <CursorPos X="10" Y="297"/> 90 <CursorPos X="10" Y="297"/>
91 <UsageCount Value="65"/> 91 <UsageCount Value="67"/>
92 <DefaultSyntaxHighlighter Value="Delphi"/> 92 <DefaultSyntaxHighlighter Value="Delphi"/>
93 </Unit8> 93 </Unit8>
94 <Unit9> 94 <Unit9>
@@ -98,26 +98,26 @@
98 <EditorIndex Value="-1"/> 98 <EditorIndex Value="-1"/>
99 <TopLine Value="3329"/> 99 <TopLine Value="3329"/>
100 <CursorPos X="7" Y="5932"/> 100 <CursorPos X="7" Y="5932"/>
101 <UsageCount Value="65"/> 101 <UsageCount Value="67"/>
102 <DefaultSyntaxHighlighter Value="Delphi"/> 102 <DefaultSyntaxHighlighter Value="Delphi"/>
103 </Unit9> 103 </Unit9>
104 <Unit10> 104 <Unit10>
105 <Filename Value="Sound\sound.pas"/> 105 <Filename Value="Sound\sound.pas"/>
106 <IsPartOfProject Value="True"/> 106 <IsPartOfProject Value="True"/>
107 <IsVisibleTab Value="True"/> 107 <IsVisibleTab Value="True"/>
108 <TopLine Value="167"/> 108 <EditorIndex Value="2"/>
109 <CursorPos X="4" Y="177"/> 109 <TopLine Value="213"/>
110 <UsageCount Value="65"/> 110 <CursorPos X="72" Y="225"/>
111 <UsageCount Value="67"/>
111 <Loaded Value="True"/> 112 <Loaded Value="True"/>
112 <DefaultSyntaxHighlighter Value="Delphi"/> 113 <DefaultSyntaxHighlighter Value="Delphi"/>
113 </Unit10> 114 </Unit10>
114 <Unit11> 115 <Unit11>
115 <Filename Value="Global\vars.pas"/> 116 <Filename Value="Global\vars.pas"/>
116 <IsPartOfProject Value="True"/> 117 <IsPartOfProject Value="True"/>
117 <EditorIndex Value="1"/>
118 <TopLine Value="144"/> 118 <TopLine Value="144"/>
119 <CursorPos X="20" Y="660"/> 119 <CursorPos X="31" Y="157"/>
120 <UsageCount Value="65"/> 120 <UsageCount Value="67"/>
121 <Loaded Value="True"/> 121 <Loaded Value="True"/>
122 <DefaultSyntaxHighlighter Value="Delphi"/> 122 <DefaultSyntaxHighlighter Value="Delphi"/>
123 </Unit11> 123 </Unit11>
@@ -127,7 +127,7 @@
127 <EditorIndex Value="3"/> 127 <EditorIndex Value="3"/>
128 <TopLine Value="215"/> 128 <TopLine Value="215"/>
129 <CursorPos X="28" Y="231"/> 129 <CursorPos X="28" Y="231"/>
130 <UsageCount Value="65"/> 130 <UsageCount Value="67"/>
131 <Loaded Value="True"/> 131 <Loaded Value="True"/>
132 <DefaultSyntaxHighlighter Value="Delphi"/> 132 <DefaultSyntaxHighlighter Value="Delphi"/>
133 </Unit12> 133 </Unit12>
@@ -137,21 +137,21 @@
137 <HasResources Value="True"/> 137 <HasResources Value="True"/>
138 <EditorIndex Value="-1"/> 138 <EditorIndex Value="-1"/>
139 <CursorPos Y="21"/> 139 <CursorPos Y="21"/>
140 <UsageCount Value="65"/> 140 <UsageCount Value="67"/>
141 <DefaultSyntaxHighlighter Value="Delphi"/> 141 <DefaultSyntaxHighlighter Value="Delphi"/>
142 </Unit13> 142 </Unit13>
143 <Unit14> 143 <Unit14>
144 <Filename Value="DirectX\Direct3DRM.pas"/> 144 <Filename Value="DirectX\Direct3DRM.pas"/>
145 <IsPartOfProject Value="True"/> 145 <IsPartOfProject Value="True"/>
146 <EditorIndex Value="-1"/> 146 <EditorIndex Value="-1"/>
147 <UsageCount Value="65"/> 147 <UsageCount Value="67"/>
148 <DefaultSyntaxHighlighter Value="Delphi"/> 148 <DefaultSyntaxHighlighter Value="Delphi"/>
149 </Unit14> 149 </Unit14>
150 <Unit15> 150 <Unit15>
151 <Filename Value="DirectX\DirectInput.pas"/> 151 <Filename Value="DirectX\DirectInput.pas"/>
152 <IsPartOfProject Value="True"/> 152 <IsPartOfProject Value="True"/>
153 <EditorIndex Value="-1"/> 153 <EditorIndex Value="-1"/>
154 <UsageCount Value="65"/> 154 <UsageCount Value="67"/>
155 <DefaultSyntaxHighlighter Value="Delphi"/> 155 <DefaultSyntaxHighlighter Value="Delphi"/>
156 </Unit15> 156 </Unit15>
157 <Unit16> 157 <Unit16>
@@ -159,35 +159,35 @@
159 <IsPartOfProject Value="True"/> 159 <IsPartOfProject Value="True"/>
160 <EditorIndex Value="-1"/> 160 <EditorIndex Value="-1"/>
161 <CursorPos X="3" Y="15"/> 161 <CursorPos X="3" Y="15"/>
162 <UsageCount Value="65"/> 162 <UsageCount Value="67"/>
163 <DefaultSyntaxHighlighter Value="Delphi"/> 163 <DefaultSyntaxHighlighter Value="Delphi"/>
164 </Unit16> 164 </Unit16>
165 <Unit17> 165 <Unit17>
166 <Filename Value="DirectX\DirectPlay.pas"/> 166 <Filename Value="DirectX\DirectPlay.pas"/>
167 <IsPartOfProject Value="True"/> 167 <IsPartOfProject Value="True"/>
168 <EditorIndex Value="-1"/> 168 <EditorIndex Value="-1"/>
169 <UsageCount Value="65"/> 169 <UsageCount Value="67"/>
170 <DefaultSyntaxHighlighter Value="Delphi"/> 170 <DefaultSyntaxHighlighter Value="Delphi"/>
171 </Unit17> 171 </Unit17>
172 <Unit18> 172 <Unit18>
173 <Filename Value="DirectX\DirectSetup.pas"/> 173 <Filename Value="DirectX\DirectSetup.pas"/>
174 <IsPartOfProject Value="True"/> 174 <IsPartOfProject Value="True"/>
175 <EditorIndex Value="-1"/> 175 <EditorIndex Value="-1"/>
176 <UsageCount Value="65"/> 176 <UsageCount Value="67"/>
177 <DefaultSyntaxHighlighter Value="Delphi"/> 177 <DefaultSyntaxHighlighter Value="Delphi"/>
178 </Unit18> 178 </Unit18>
179 <Unit19> 179 <Unit19>
180 <Filename Value="DirectX\DirectSound.pas"/> 180 <Filename Value="DirectX\DirectSound.pas"/>
181 <IsPartOfProject Value="True"/> 181 <IsPartOfProject Value="True"/>
182 <EditorIndex Value="-1"/> 182 <EditorIndex Value="-1"/>
183 <UsageCount Value="65"/> 183 <UsageCount Value="67"/>
184 <DefaultSyntaxHighlighter Value="Delphi"/> 184 <DefaultSyntaxHighlighter Value="Delphi"/>
185 </Unit19> 185 </Unit19>
186 <Unit20> 186 <Unit20>
187 <Filename Value="DirectX\Direct3D.pas"/> 187 <Filename Value="DirectX\Direct3D.pas"/>
188 <IsPartOfProject Value="True"/> 188 <IsPartOfProject Value="True"/>
189 <EditorIndex Value="-1"/> 189 <EditorIndex Value="-1"/>
190 <UsageCount Value="65"/> 190 <UsageCount Value="67"/>
191 <DefaultSyntaxHighlighter Value="Delphi"/> 191 <DefaultSyntaxHighlighter Value="Delphi"/>
192 </Unit20> 192 </Unit20>
193 <Unit21> 193 <Unit21>
@@ -197,7 +197,7 @@
197 <EditorIndex Value="-1"/> 197 <EditorIndex Value="-1"/>
198 <TopLine Value="372"/> 198 <TopLine Value="372"/>
199 <CursorPos X="33" Y="405"/> 199 <CursorPos X="33" Y="405"/>
200 <UsageCount Value="65"/> 200 <UsageCount Value="67"/>
201 <DefaultSyntaxHighlighter Value="Delphi"/> 201 <DefaultSyntaxHighlighter Value="Delphi"/>
202 </Unit21> 202 </Unit21>
203 <Unit22> 203 <Unit22>
@@ -278,123 +278,127 @@
278 <UsageCount Value="11"/> 278 <UsageCount Value="11"/>
279 </Unit31> 279 </Unit31>
280 </Units> 280 </Units>
281 <JumpHistory Count="29" HistoryIndex="28"> 281 <JumpHistory Count="30" HistoryIndex="29">
282 <Position1> 282 <Position1>
283 <Filename Value="mainloop.pas"/> 283 <Filename Value="Sound\sound.pas"/>
284 <Caret Line="20" Column="38"/> 284 <Caret Line="169" Column="16" TopLine="153"/>
285 </Position1> 285 </Position1>
286 <Position2> 286 <Position2>
287 <Filename Value="UnitMain.pas"/> 287 <Filename Value="Sound\sound.pas"/>
288 <Caret Line="371" TopLine="357"/> 288 <Caret Line="168" Column="48" TopLine="164"/>
289 </Position2> 289 </Position2>
290 <Position3> 290 <Position3>
291 <Filename Value="UnitMain.pas"/> 291 <Filename Value="Sound\sound.pas"/>
292 <Caret Line="193" Column="40" TopLine="169"/> 292 <Caret Line="177" Column="4" TopLine="167"/>
293 </Position3> 293 </Position3>
294 <Position4> 294 <Position4>
295 <Filename Value="mainloop.pas"/> 295 <Filename Value="Sound\sound.pas"/>
296 <Caret Line="231" Column="28" TopLine="215"/> 296 <Caret Line="161" Column="51" TopLine="152"/>
297 </Position4> 297 </Position4>
298 <Position5> 298 <Position5>
299 <Filename Value="UnitMain.pas"/> 299 <Filename Value="Sound\sound.pas"/>
300 <Caret Line="244" Column="17" TopLine="231"/> 300 <Caret Line="179" TopLine="168"/>
301 </Position5> 301 </Position5>
302 <Position6> 302 <Position6>
303 <Filename Value="UnitMain.pas"/> 303 <Filename Value="Sound\sound.pas"/>
304 <Caret Line="18" Column="22" TopLine="2"/> 304 <Caret Line="16" Column="6"/>
305 </Position6> 305 </Position6>
306 <Position7> 306 <Position7>
307 <Filename Value="UnitMain.pas"/> 307 <Filename Value="Sound\sound.pas"/>
308 <Caret Line="291" Column="3" TopLine="277"/> 308 <Caret Line="183" Column="3" TopLine="166"/>
309 </Position7> 309 </Position7>
310 <Position8> 310 <Position8>
311 <Filename Value="UnitMain.pas"/> 311 <Filename Value="Sound\sound.pas"/>
312 <Caret Line="18" Column="11"/> 312 <Caret Line="185" Column="68" TopLine="167"/>
313 </Position8> 313 </Position8>
314 <Position9> 314 <Position9>
315 <Filename Value="UnitMain.pas"/> 315 <Filename Value="Sound\sound.pas"/>
316 <Caret Line="291" Column="13" TopLine="265"/> 316 <Caret Line="165" Column="34" TopLine="157"/>
317 </Position9> 317 </Position9>
318 <Position10> 318 <Position10>
319 <Filename Value="UnitMain.pas"/> 319 <Filename Value="Sound\sound.pas"/>
320 <Caret Line="340" Column="18" TopLine="325"/> 320 <Caret Line="189" Column="10" TopLine="171"/>
321 </Position10> 321 </Position10>
322 <Position11> 322 <Position11>
323 <Filename Value="UnitMain.pas"/> 323 <Filename Value="Sound\sound.pas"/>
324 <Caret Line="346" Column="7" TopLine="326"/> 324 <Caret Line="570" Column="33" TopLine="558"/>
325 </Position11> 325 </Position11>
326 <Position12> 326 <Position12>
327 <Filename Value="UnitMain.pas"/> 327 <Filename Value="Sound\sound.pas"/>
328 <Caret Line="291" TopLine="269"/> 328 <Caret Line="16" Column="5" TopLine="26"/>
329 </Position12> 329 </Position12>
330 <Position13> 330 <Position13>
331 <Filename Value="UnitMain.pas"/> 331 <Filename Value="Sound\sound.pas"/>
332 <Caret Line="344" Column="12" TopLine="325"/> 332 <Caret Line="171" Column="32" TopLine="167"/>
333 </Position13> 333 </Position13>
334 <Position14> 334 <Position14>
335 <Filename Value="UnitMain.pas"/> 335 <Filename Value="Sound\sound.pas"/>
336 <Caret Line="551" Column="21" TopLine="524"/> 336 <Caret Line="198" TopLine="190"/>
337 </Position14> 337 </Position14>
338 <Position15> 338 <Position15>
339 <Filename Value="UnitMain.pas"/> 339 <Filename Value="Sound\sound.pas"/>
340 <Caret Line="356" Column="37" TopLine="338"/> 340 <Caret Line="229" Column="73" TopLine="217"/>
341 </Position15> 341 </Position15>
342 <Position16> 342 <Position16>
343 <Filename Value="UnitMain.pas"/> 343 <Filename Value="Sound\sound.pas"/>
344 <Caret Line="343" Column="17" TopLine="334"/> 344 <Caret Line="191" Column="24" TopLine="173"/>
345 </Position16> 345 </Position16>
346 <Position17> 346 <Position17>
347 <Filename Value="UnitMain.pas"/> 347 <Filename Value="Sound\sound.pas"/>
348 <Caret Line="108" Column="46" TopLine="93"/> 348 <Caret Line="228" TopLine="201"/>
349 </Position17> 349 </Position17>
350 <Position18> 350 <Position18>
351 <Filename Value="Sound\sound.pas"/> 351 <Filename Value="Sound\sound.pas"/>
352 <Caret Line="126" Column="27" TopLine="117"/> 352 <Caret Line="230" Column="33" TopLine="202"/>
353 </Position18> 353 </Position18>
354 <Position19> 354 <Position19>
355 <Filename Value="Sound\sound.pas"/> 355 <Filename Value="Sound\sound.pas"/>
356 <Caret Line="137" Column="13" TopLine="117"/> 356 <Caret Line="165" Column="5" TopLine="153"/>
357 </Position19> 357 </Position19>
358 <Position20> 358 <Position20>
359 <Filename Value="Sound\sound.pas"/> 359 <Filename Value="Sound\sound.pas"/>
360 <Caret Line="660" Column="21" TopLine="634"/> 360 <Caret Line="213" Column="93" TopLine="204"/>
361 </Position20> 361 </Position20>
362 <Position21> 362 <Position21>
363 <Filename Value="Sound\sound.pas"/> 363 <Filename Value="Sound\sound.pas"/>
364 <Caret Line="664" Column="22" TopLine="635"/> 364 <Caret Line="216" Column="42" TopLine="196"/>
365 </Position21> 365 </Position21>
366 <Position22> 366 <Position22>
367 <Filename Value="Sound\sound.pas"/> 367 <Filename Value="Sound\sound.pas"/>
368 <Caret Line="161" Column="50" TopLine="145"/> 368 <Caret Line="211" Column="8" TopLine="199"/>
369 </Position22> 369 </Position22>
370 <Position23> 370 <Position23>
371 <Filename Value="Sound\sound.pas"/> 371 <Filename Value="Sound\sound.pas"/>
372 <Caret Line="234" Column="38" TopLine="207"/> 372 <Caret Line="216" Column="42" TopLine="201"/>
373 </Position23> 373 </Position23>
374 <Position24> 374 <Position24>
375 <Filename Value="Sound\sound.pas"/> 375 <Filename Value="Sound\sound.pas"/>
376 <Caret Line="664" Column="22" TopLine="635"/> 376 <Caret Line="214" Column="11" TopLine="199"/>
377 </Position24> 377 </Position24>
378 <Position25> 378 <Position25>
379 <Filename Value="Sound\sound.pas"/> 379 <Filename Value="Sound\sound.pas"/>
380 <Caret Line="161" Column="50" TopLine="145"/> 380 <Caret Line="205" Column="21" TopLine="197"/>
381 </Position25> 381 </Position25>
382 <Position26> 382 <Position26>
383 <Filename Value="Sound\sound.pas"/> 383 <Filename Value="Sound\sound.pas"/>
384 <Caret Line="137" Column="5" TopLine="123"/> 384 <Caret Line="297" Column="49" TopLine="276"/>
385 </Position26> 385 </Position26>
386 <Position27> 386 <Position27>
387 <Filename Value="Sound\sound.pas"/> 387 <Filename Value="Sound\sound.pas"/>
388 <Caret Line="288" Column="7" TopLine="273"/> 388 <Caret Line="286" TopLine="280"/>
389 </Position27> 389 </Position27>
390 <Position28> 390 <Position28>
391 <Filename Value="Sound\sound.pas"/> 391 <Filename Value="Sound\sound.pas"/>
392 <Caret Line="169" Column="16" TopLine="153"/> 392 <Caret Line="16" Column="6"/>
393 </Position28> 393 </Position28>
394 <Position29> 394 <Position29>
395 <Filename Value="Sound\sound.pas"/> 395 <Filename Value="Sound\sound.pas"/>
396 <Caret Line="168" Column="48" TopLine="164"/> 396 <Caret Line="222" Column="7" TopLine="209"/>
397 </Position29> 397 </Position29>
398 <Position30>
399 <Filename Value="Sound\sound.pas"/>
400 <Caret Line="165" Column="34" TopLine="151"/>
401 </Position30>
398 </JumpHistory> 402 </JumpHistory>
399 </ProjectSession> 403 </ProjectSession>
400 </CONFIG> 404 </CONFIG>
ModifiedSound/sound.pas +8−86
@@ -13,7 +13,7 @@ unit sound;
13 13
14 interface 14 interface
15 15
16 uses Windows, mmsystem, bass; 16 uses bass;
17 17
18 (* 18 (*
19 19
@@ -156,51 +156,16 @@ implementation
156 uses vars; 156 uses vars;
157 157
158 const 158 const
159 dev: HWAVEOUT = 0;
160 curBlock: longint = 0; 159 curBlock: longint = 0;
161 sampleCycles: longint = (8192 * 1024) div 22050; 160 sampleCycles: longint = (8192 * 1024) div 22050;
162 161
163 var 162 var
164 cs: TRTLCriticalSection; 163 cs: TRTLCriticalSection;
165 bufs: array[0..1] of THANDLE; 164 bufs: array[0..1] of Pointer;
166 bufPtr: array[0..1] of pointer; 165 bufPtr: array[0..1] of pointer;
167 bufHdr: array[0..1] of THANDLE;
168 166
169 ready: integer; 167 ready: integer;
170 bufPos, bufCycles, bufLVal, bufRVal: integer; 168 bufPos, bufCycles, bufLVal, bufRVal: integer;
171 WH: PWAVEHDR;
172
173 MyFile: file of Byte;
174
175 procedure WaveCallback(hdrvr: HDRVR; uMsg: UINT; dwUser: DWORD; dw1, dw2: DWORD); stdcall;
176 var
177 wh: PWaveHDR;
178 hg: HGLOBAL;
179 res: int64;
180 begin
181 if uMsg = WOM_DONE then
182 begin
183 EnterCriticalSection(cs);
184
185 wh := pointer(dw1);
186
187 waveOutUnprepareHeader(dev, wh, sizeof(WAVEHDR));
188
189 //Deallocate the buffer memory
190 hg := GlobalHandle(wh.lpData);
191 GlobalUnlock(hg);
192 GlobalFree(hg);
193
194 //Deallocate the header memory
195 hg := GlobalHandle(wh);
196 GlobalUnlock(hg);
197 GlobalFree(hg);
198
199 Inc(ready);
200
201 LeaveCriticalSection(cs);
202 end;
203 end;
204 169
205 var 170 var
206 sndEv: array[0..1] of THANDLE; 171 sndEv: array[0..1] of THANDLE;
@@ -210,17 +175,11 @@ var
210 175
211 procedure EnableSound; 176 procedure EnableSound;
212 var 177 var
213 outFormatex: TWAVEFORMATEX;
214 p: pointer; 178 p: pointer;
215 begin 179 begin
216 if soundEnable then 180 if soundEnable then
217 exit; 181 exit;
218 182
219 if waveOutGetNumDevs = 0 then
220 begin
221 //MessageBox(0,'No audio devices present','Error',MB_OK or MB_ICONSTOP);
222 exit;
223 end;
224 soundEnable := True; 183 soundEnable := True;
225 ready := 3; 184 ready := 3;
226 bufPos := 0; 185 bufPos := 0;
@@ -228,42 +187,15 @@ begin
228 bufLVal := 0; 187 bufLVal := 0;
229 bufRVal := 0; 188 bufRVal := 0;
230 189
231 outFormatex.wFormatTag := WAVE_FORMAT_PCM; 190 bufs[curBlock] := GetMem(2048); //GlobalAlloc(GMEM_MOVEABLE, 2048);
232 outFormatex.wBitsPerSample := 8; 191 bufPtr[curBlock] := bufs[curBlock]; //GlobalLock(bufs[curBlock]);
233 outFormatex.nChannels := 2;
234 outFormatex.nSamplesPerSec := 22050;
235 outFormatex.nAvgBytesPerSec := 44100;
236 outFormatex.nBlockAlign := 2;
237 if waveOutOpen(@dev, WAVE_MAPPER, @outFormatex,
238 DWORD(addr(Wavecallback)), 0, CALLBACK_FUNCTION) <> MMSYSERR_NOERROR then
239 begin
240 //MessageBox(0,'Could not open audio device','Error',MB_OK or MB_ICONSTOP);
241 exit;
242 end;
243 waveOutReset(dev);
244 InitializeCriticalSection(cs);
245 bufs[curBlock] := GlobalAlloc(GMEM_MOVEABLE, 2048);
246 bufPtr[curBlock] := GlobalLock(bufs[curBlock]);
247 bufHdr[curBlock] := GlobalAlloc(GMEM_MOVEABLE or GMEM_ZEROINIT, sizeof(WAVEHDR));
248 wh := GlobalLock(bufHdr[curBlock]);
249 wh^.dwBufferLength := 2048;
250 wh^.lpData := bufPtr[curBlock];
251 end; 192 end;
252 193
253 procedure DisableSound; 194 procedure DisableSound;
254 begin 195 begin
255 if not soundEnable then 196 if not soundEnable then
256 exit; 197 exit;
257 if dev > 0 then
258 begin
259 while ready < 2 do
260 Sleep(50);
261 waveOutReset(dev); //reset the device
262 waveOutClose(dev); //close the device
263 dev := 0;
264 end;
265 198
266 DeleteCriticalSection(cs);
267 soundEnable := False; 199 soundEnable := False;
268 end; 200 end;
269 201
@@ -284,23 +216,12 @@ begin
284 bufRVal := 0; 216 bufRVal := 0;
285 if bufPos >= 2048 then 217 if bufPos >= 2048 then
286 begin 218 begin
287 //TODO: put data in push stream
288 BASS_StreamPutData(PlayStream, bufPtr[curBlock], 2048); 219 BASS_StreamPutData(PlayStream, bufPtr[curBlock], 2048);
289 {for Idx := 0 to 2048 do begin
290 Write(Char((bufPtr[curBlock]+Idx)^));
291 byte(PChar(bufPtr[curBlock])[bufPos]) := 0;
292 end;}
293 Dec(ready); 220 Dec(ready);
294 waveOutPrepareHeader(dev, wh, sizeof(WAVEHDR)); 221
295 waveOutWrite(dev, wh, sizeof(WAVEHDR));
296 curBlock := (curBlock + 1) and 1; 222 curBlock := (curBlock + 1) and 1;
297 bufs[curBlock] := GlobalAlloc(GMEM_MOVEABLE, 2048); 223 bufs[curBlock] := GetMem(2048); //GlobalAlloc(GMEM_MOVEABLE, 2048);
298 bufPtr[curBlock] := GlobalLock(bufs[curBlock]); 224 bufPtr[curBlock] := bufs[curBlock]; //GlobalLock(bufs[curBlock]);
299 bufHdr[curBlock] :=
300 GlobalAlloc(GMEM_MOVEABLE or GMEM_ZEROINIT, sizeof(WAVEHDR));
301 wh := GlobalLock(bufHdr[curBlock]);
302 wh.dwBufferLength := 2048;
303 wh.lpData := bufPtr[curBlock];
304 bufPos := 0; 225 bufPos := 0;
305 end; 226 end;
306 end; 227 end;
@@ -669,6 +590,7 @@ begin
669 BASS_SAMPLE_8BITS, 590 BASS_SAMPLE_8BITS,
670 StreamProc(STREAMPROC_PUSH), 591 StreamProc(STREAMPROC_PUSH),
671 nil); 592 nil);
593 BASS_ChannelPlay(PlayStream, True);
672 //Assign(MyFile, 'outf2.pcm'); 594 //Assign(MyFile, 'outf2.pcm');
673 //Rewrite(MyFile); 595 //Rewrite(MyFile);
674 end. 596 end.