snd_win.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. /*
  2. Copyright (C) 1996-1997 Id Software, Inc.
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. See the GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. #include "quakedef.h"
  16. #include "winquake.h"
  17. #define iDirectSoundCreate(a,b,c) pDirectSoundCreate(a,b,c)
  18. HRESULT (WINAPI *pDirectSoundCreate)(GUID FAR *lpGUID, LPDIRECTSOUND FAR *lplpDS, IUnknown FAR *pUnkOuter);
  19. // 64K is > 1 second at 16-bit, 22050 Hz
  20. #define WAV_BUFFERS 64
  21. #define WAV_MASK 0x3F
  22. #define WAV_BUFFER_SIZE 0x0400
  23. #define SECONDARY_BUFFER_SIZE 0x10000
  24. typedef enum {SIS_SUCCESS, SIS_FAILURE, SIS_NOTAVAIL} sndinitstat;
  25. static qboolean wavonly;
  26. static qboolean dsound_init;
  27. static qboolean wav_init;
  28. static qboolean snd_firsttime = true, snd_isdirect, snd_iswave;
  29. static qboolean primary_format_set;
  30. static int sample16;
  31. static int snd_sent, snd_completed;
  32. /*
  33. * Global variables. Must be visible to window-procedure function
  34. * so it can unlock and free the data block after it has been played.
  35. */
  36. HANDLE hData;
  37. HPSTR lpData, lpData2;
  38. HGLOBAL hWaveHdr;
  39. LPWAVEHDR lpWaveHdr;
  40. HWAVEOUT hWaveOut;
  41. WAVEOUTCAPS wavecaps;
  42. DWORD gSndBufSize;
  43. MMTIME mmstarttime;
  44. LPDIRECTSOUND pDS;
  45. LPDIRECTSOUNDBUFFER pDSBuf, pDSPBuf;
  46. HINSTANCE hInstDS;
  47. qboolean SNDDMA_InitDirect (void);
  48. qboolean SNDDMA_InitWav (void);
  49. /*
  50. ==================
  51. S_BlockSound
  52. ==================
  53. */
  54. void S_BlockSound (void)
  55. {
  56. // DirectSound takes care of blocking itself
  57. if (snd_iswave)
  58. {
  59. snd_blocked++;
  60. if (snd_blocked == 1)
  61. {
  62. waveOutReset (hWaveOut);
  63. }
  64. }
  65. }
  66. /*
  67. ==================
  68. S_UnblockSound
  69. ==================
  70. */
  71. void S_UnblockSound (void)
  72. {
  73. // DirectSound takes care of blocking itself
  74. if (snd_iswave)
  75. {
  76. snd_blocked--;
  77. }
  78. }
  79. /*
  80. ==================
  81. FreeSound
  82. ==================
  83. */
  84. void FreeSound (void)
  85. {
  86. int i;
  87. if (pDSBuf)
  88. {
  89. pDSBuf->lpVtbl->Stop(pDSBuf);
  90. pDSBuf->lpVtbl->Release(pDSBuf);
  91. }
  92. // only release primary buffer if it's not also the mixing buffer we just released
  93. if (pDSPBuf && (pDSBuf != pDSPBuf))
  94. {
  95. pDSPBuf->lpVtbl->Release(pDSPBuf);
  96. }
  97. if (pDS)
  98. {
  99. pDS->lpVtbl->SetCooperativeLevel (pDS, mainwindow, DSSCL_NORMAL);
  100. pDS->lpVtbl->Release(pDS);
  101. }
  102. if (hWaveOut)
  103. {
  104. waveOutReset (hWaveOut);
  105. if (lpWaveHdr)
  106. {
  107. for (i=0 ; i< WAV_BUFFERS ; i++)
  108. waveOutUnprepareHeader (hWaveOut, lpWaveHdr+i, sizeof(WAVEHDR));
  109. }
  110. waveOutClose (hWaveOut);
  111. if (hWaveHdr)
  112. {
  113. GlobalUnlock(hWaveHdr);
  114. GlobalFree(hWaveHdr);
  115. }
  116. if (hData)
  117. {
  118. GlobalUnlock(hData);
  119. GlobalFree(hData);
  120. }
  121. }
  122. pDS = NULL;
  123. pDSBuf = NULL;
  124. pDSPBuf = NULL;
  125. hWaveOut = 0;
  126. hData = 0;
  127. hWaveHdr = 0;
  128. lpData = NULL;
  129. lpWaveHdr = NULL;
  130. dsound_init = false;
  131. wav_init = false;
  132. }
  133. /*
  134. ==================
  135. SNDDMA_InitDirect
  136. Direct-Sound support
  137. ==================
  138. */
  139. sndinitstat SNDDMA_InitDirect (void)
  140. {
  141. DSBUFFERDESC dsbuf;
  142. DSBCAPS dsbcaps;
  143. DWORD dwSize, dwWrite;
  144. DSCAPS dscaps;
  145. WAVEFORMATEX format, pformat;
  146. HRESULT hresult;
  147. int reps;
  148. memset ((void *)&sn, 0, sizeof (sn));
  149. shm = &sn;
  150. shm->channels = 2;
  151. shm->samplebits = 16;
  152. shm->speed = 11025;
  153. memset (&format, 0, sizeof(format));
  154. format.wFormatTag = WAVE_FORMAT_PCM;
  155. format.nChannels = shm->channels;
  156. format.wBitsPerSample = shm->samplebits;
  157. format.nSamplesPerSec = shm->speed;
  158. format.nBlockAlign = format.nChannels
  159. *format.wBitsPerSample / 8;
  160. format.cbSize = 0;
  161. format.nAvgBytesPerSec = format.nSamplesPerSec
  162. *format.nBlockAlign;
  163. if (!hInstDS)
  164. {
  165. hInstDS = LoadLibrary("dsound.dll");
  166. if (hInstDS == NULL)
  167. {
  168. Con_SafePrintf ("Couldn't load dsound.dll\n");
  169. return SIS_FAILURE;
  170. }
  171. pDirectSoundCreate = (void *)GetProcAddress(hInstDS,"DirectSoundCreate");
  172. if (!pDirectSoundCreate)
  173. {
  174. Con_SafePrintf ("Couldn't get DS proc addr\n");
  175. return SIS_FAILURE;
  176. }
  177. }
  178. while ((hresult = iDirectSoundCreate(NULL, &pDS, NULL)) != DS_OK)
  179. {
  180. if (hresult != DSERR_ALLOCATED)
  181. {
  182. Con_SafePrintf ("DirectSound create failed\n");
  183. return SIS_FAILURE;
  184. }
  185. if (MessageBox (NULL,
  186. "The sound hardware is in use by another app.\n\n"
  187. "Select Retry to try to start sound again or Cancel to run Quake with no sound.",
  188. "Sound not available",
  189. MB_RETRYCANCEL | MB_SETFOREGROUND | MB_ICONEXCLAMATION) != IDRETRY)
  190. {
  191. Con_SafePrintf ("DirectSoundCreate failure\n"
  192. " hardware already in use\n");
  193. return SIS_NOTAVAIL;
  194. }
  195. }
  196. dscaps.dwSize = sizeof(dscaps);
  197. if (DS_OK != pDS->lpVtbl->GetCaps (pDS, &dscaps))
  198. {
  199. Con_SafePrintf ("Couldn't get DS caps\n");
  200. }
  201. if (dscaps.dwFlags & DSCAPS_EMULDRIVER)
  202. {
  203. Con_SafePrintf ("No DirectSound driver installed\n");
  204. FreeSound ();
  205. return SIS_FAILURE;
  206. }
  207. if (DS_OK != pDS->lpVtbl->SetCooperativeLevel (pDS, mainwindow, DSSCL_EXCLUSIVE))
  208. {
  209. Con_SafePrintf ("Set coop level failed\n");
  210. FreeSound ();
  211. return SIS_FAILURE;
  212. }
  213. // get access to the primary buffer, if possible, so we can set the
  214. // sound hardware format
  215. memset (&dsbuf, 0, sizeof(dsbuf));
  216. dsbuf.dwSize = sizeof(DSBUFFERDESC);
  217. dsbuf.dwFlags = DSBCAPS_PRIMARYBUFFER;
  218. dsbuf.dwBufferBytes = 0;
  219. dsbuf.lpwfxFormat = NULL;
  220. memset(&dsbcaps, 0, sizeof(dsbcaps));
  221. dsbcaps.dwSize = sizeof(dsbcaps);
  222. primary_format_set = false;
  223. if (!COM_CheckParm ("-snoforceformat"))
  224. {
  225. if (DS_OK == pDS->lpVtbl->CreateSoundBuffer(pDS, &dsbuf, &pDSPBuf, NULL))
  226. {
  227. pformat = format;
  228. if (DS_OK != pDSPBuf->lpVtbl->SetFormat (pDSPBuf, &pformat))
  229. {
  230. if (snd_firsttime)
  231. Con_SafePrintf ("Set primary sound buffer format: no\n");
  232. }
  233. else
  234. {
  235. if (snd_firsttime)
  236. Con_SafePrintf ("Set primary sound buffer format: yes\n");
  237. primary_format_set = true;
  238. }
  239. }
  240. }
  241. if (!primary_format_set || !COM_CheckParm ("-primarysound"))
  242. {
  243. // create the secondary buffer we'll actually work with
  244. memset (&dsbuf, 0, sizeof(dsbuf));
  245. dsbuf.dwSize = sizeof(DSBUFFERDESC);
  246. dsbuf.dwFlags = DSBCAPS_CTRLFREQUENCY | DSBCAPS_LOCSOFTWARE;
  247. dsbuf.dwBufferBytes = SECONDARY_BUFFER_SIZE;
  248. dsbuf.lpwfxFormat = &format;
  249. memset(&dsbcaps, 0, sizeof(dsbcaps));
  250. dsbcaps.dwSize = sizeof(dsbcaps);
  251. if (DS_OK != pDS->lpVtbl->CreateSoundBuffer(pDS, &dsbuf, &pDSBuf, NULL))
  252. {
  253. Con_SafePrintf ("DS:CreateSoundBuffer Failed");
  254. FreeSound ();
  255. return SIS_FAILURE;
  256. }
  257. shm->channels = format.nChannels;
  258. shm->samplebits = format.wBitsPerSample;
  259. shm->speed = format.nSamplesPerSec;
  260. if (DS_OK != pDSBuf->lpVtbl->GetCaps (pDSBuf, &dsbcaps))
  261. {
  262. Con_SafePrintf ("DS:GetCaps failed\n");
  263. FreeSound ();
  264. return SIS_FAILURE;
  265. }
  266. if (snd_firsttime)
  267. Con_SafePrintf ("Using secondary sound buffer\n");
  268. }
  269. else
  270. {
  271. if (DS_OK != pDS->lpVtbl->SetCooperativeLevel (pDS, mainwindow, DSSCL_WRITEPRIMARY))
  272. {
  273. Con_SafePrintf ("Set coop level failed\n");
  274. FreeSound ();
  275. return SIS_FAILURE;
  276. }
  277. if (DS_OK != pDSPBuf->lpVtbl->GetCaps (pDSPBuf, &dsbcaps))
  278. {
  279. Con_Printf ("DS:GetCaps failed\n");
  280. return SIS_FAILURE;
  281. }
  282. pDSBuf = pDSPBuf;
  283. Con_SafePrintf ("Using primary sound buffer\n");
  284. }
  285. // Make sure mixer is active
  286. pDSBuf->lpVtbl->Play(pDSBuf, 0, 0, DSBPLAY_LOOPING);
  287. if (snd_firsttime)
  288. Con_SafePrintf(" %d channel(s)\n"
  289. " %d bits/sample\n"
  290. " %d bytes/sec\n",
  291. shm->channels, shm->samplebits, shm->speed);
  292. gSndBufSize = dsbcaps.dwBufferBytes;
  293. // initialize the buffer
  294. reps = 0;
  295. while ((hresult = pDSBuf->lpVtbl->Lock(pDSBuf, 0, gSndBufSize, &lpData, &dwSize, NULL, NULL, 0)) != DS_OK)
  296. {
  297. if (hresult != DSERR_BUFFERLOST)
  298. {
  299. Con_SafePrintf ("SNDDMA_InitDirect: DS::Lock Sound Buffer Failed\n");
  300. FreeSound ();
  301. return SIS_FAILURE;
  302. }
  303. if (++reps > 10000)
  304. {
  305. Con_SafePrintf ("SNDDMA_InitDirect: DS: couldn't restore buffer\n");
  306. FreeSound ();
  307. return SIS_FAILURE;
  308. }
  309. }
  310. memset(lpData, 0, dwSize);
  311. // lpData[4] = lpData[5] = 0x7f; // force a pop for debugging
  312. pDSBuf->lpVtbl->Unlock(pDSBuf, lpData, dwSize, NULL, 0);
  313. /* we don't want anyone to access the buffer directly w/o locking it first. */
  314. lpData = NULL;
  315. pDSBuf->lpVtbl->Stop(pDSBuf);
  316. pDSBuf->lpVtbl->GetCurrentPosition(pDSBuf, &mmstarttime.u.sample, &dwWrite);
  317. pDSBuf->lpVtbl->Play(pDSBuf, 0, 0, DSBPLAY_LOOPING);
  318. shm->soundalive = true;
  319. shm->splitbuffer = false;
  320. shm->samples = gSndBufSize/(shm->samplebits/8);
  321. shm->samplepos = 0;
  322. shm->submission_chunk = 1;
  323. shm->buffer = (unsigned char *) lpData;
  324. sample16 = (shm->samplebits/8) - 1;
  325. dsound_init = true;
  326. return SIS_SUCCESS;
  327. }
  328. /*
  329. ==================
  330. SNDDM_InitWav
  331. Crappy windows multimedia base
  332. ==================
  333. */
  334. qboolean SNDDMA_InitWav (void)
  335. {
  336. WAVEFORMATEX format;
  337. int i;
  338. HRESULT hr;
  339. snd_sent = 0;
  340. snd_completed = 0;
  341. shm = &sn;
  342. shm->channels = 2;
  343. shm->samplebits = 16;
  344. shm->speed = 11025;
  345. memset (&format, 0, sizeof(format));
  346. format.wFormatTag = WAVE_FORMAT_PCM;
  347. format.nChannels = shm->channels;
  348. format.wBitsPerSample = shm->samplebits;
  349. format.nSamplesPerSec = shm->speed;
  350. format.nBlockAlign = format.nChannels
  351. *format.wBitsPerSample / 8;
  352. format.cbSize = 0;
  353. format.nAvgBytesPerSec = format.nSamplesPerSec
  354. *format.nBlockAlign;
  355. /* Open a waveform device for output using window callback. */
  356. while ((hr = waveOutOpen((LPHWAVEOUT)&hWaveOut, WAVE_MAPPER,
  357. &format,
  358. 0, 0L, CALLBACK_NULL)) != MMSYSERR_NOERROR)
  359. {
  360. if (hr != MMSYSERR_ALLOCATED)
  361. {
  362. Con_SafePrintf ("waveOutOpen failed\n");
  363. return false;
  364. }
  365. if (MessageBox (NULL,
  366. "The sound hardware is in use by another app.\n\n"
  367. "Select Retry to try to start sound again or Cancel to run Quake with no sound.",
  368. "Sound not available",
  369. MB_RETRYCANCEL | MB_SETFOREGROUND | MB_ICONEXCLAMATION) != IDRETRY)
  370. {
  371. Con_SafePrintf ("waveOutOpen failure;\n"
  372. " hardware already in use\n");
  373. return false;
  374. }
  375. }
  376. /*
  377. * Allocate and lock memory for the waveform data. The memory
  378. * for waveform data must be globally allocated with
  379. * GMEM_MOVEABLE and GMEM_SHARE flags.
  380. */
  381. gSndBufSize = WAV_BUFFERS*WAV_BUFFER_SIZE;
  382. hData = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, gSndBufSize);
  383. if (!hData)
  384. {
  385. Con_SafePrintf ("Sound: Out of memory.\n");
  386. FreeSound ();
  387. return false;
  388. }
  389. lpData = GlobalLock(hData);
  390. if (!lpData)
  391. {
  392. Con_SafePrintf ("Sound: Failed to lock.\n");
  393. FreeSound ();
  394. return false;
  395. }
  396. memset (lpData, 0, gSndBufSize);
  397. /*
  398. * Allocate and lock memory for the header. This memory must
  399. * also be globally allocated with GMEM_MOVEABLE and
  400. * GMEM_SHARE flags.
  401. */
  402. hWaveHdr = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE,
  403. (DWORD) sizeof(WAVEHDR) * WAV_BUFFERS);
  404. if (hWaveHdr == NULL)
  405. {
  406. Con_SafePrintf ("Sound: Failed to Alloc header.\n");
  407. FreeSound ();
  408. return false;
  409. }
  410. lpWaveHdr = (LPWAVEHDR) GlobalLock(hWaveHdr);
  411. if (lpWaveHdr == NULL)
  412. {
  413. Con_SafePrintf ("Sound: Failed to lock header.\n");
  414. FreeSound ();
  415. return false;
  416. }
  417. memset (lpWaveHdr, 0, sizeof(WAVEHDR) * WAV_BUFFERS);
  418. /* After allocation, set up and prepare headers. */
  419. for (i=0 ; i<WAV_BUFFERS ; i++)
  420. {
  421. lpWaveHdr[i].dwBufferLength = WAV_BUFFER_SIZE;
  422. lpWaveHdr[i].lpData = lpData + i*WAV_BUFFER_SIZE;
  423. if (waveOutPrepareHeader(hWaveOut, lpWaveHdr+i, sizeof(WAVEHDR)) !=
  424. MMSYSERR_NOERROR)
  425. {
  426. Con_SafePrintf ("Sound: failed to prepare wave headers\n");
  427. FreeSound ();
  428. return false;
  429. }
  430. }
  431. shm->soundalive = true;
  432. shm->splitbuffer = false;
  433. shm->samples = gSndBufSize/(shm->samplebits/8);
  434. shm->samplepos = 0;
  435. shm->submission_chunk = 1;
  436. shm->buffer = (unsigned char *) lpData;
  437. sample16 = (shm->samplebits/8) - 1;
  438. wav_init = true;
  439. return true;
  440. }
  441. /*
  442. ==================
  443. SNDDMA_Init
  444. Try to find a sound device to mix for.
  445. Returns false if nothing is found.
  446. ==================
  447. */
  448. int SNDDMA_Init(void)
  449. {
  450. sndinitstat stat;
  451. if (COM_CheckParm ("-wavonly"))
  452. wavonly = true;
  453. dsound_init = wav_init = 0;
  454. stat = SIS_FAILURE; // assume DirectSound won't initialize
  455. /* Init DirectSound */
  456. if (!wavonly)
  457. {
  458. if (snd_firsttime || snd_isdirect)
  459. {
  460. stat = SNDDMA_InitDirect ();;
  461. if (stat == SIS_SUCCESS)
  462. {
  463. snd_isdirect = true;
  464. if (snd_firsttime)
  465. Con_SafePrintf ("DirectSound initialized\n");
  466. }
  467. else
  468. {
  469. snd_isdirect = false;
  470. Con_SafePrintf ("DirectSound failed to init\n");
  471. }
  472. }
  473. }
  474. // if DirectSound didn't succeed in initializing, try to initialize
  475. // waveOut sound, unless DirectSound failed because the hardware is
  476. // already allocated (in which case the user has already chosen not
  477. // to have sound)
  478. if (!dsound_init && (stat != SIS_NOTAVAIL))
  479. {
  480. if (snd_firsttime || snd_iswave)
  481. {
  482. snd_iswave = SNDDMA_InitWav ();
  483. if (snd_iswave)
  484. {
  485. if (snd_firsttime)
  486. Con_SafePrintf ("Wave sound initialized\n");
  487. }
  488. else
  489. {
  490. Con_SafePrintf ("Wave sound failed to init\n");
  491. }
  492. }
  493. }
  494. snd_firsttime = false;
  495. if (!dsound_init && !wav_init)
  496. {
  497. if (snd_firsttime)
  498. Con_SafePrintf ("No sound device initialized\n");
  499. return 0;
  500. }
  501. return 1;
  502. }
  503. /*
  504. ==============
  505. SNDDMA_GetDMAPos
  506. return the current sample position (in mono samples read)
  507. inside the recirculating dma buffer, so the mixing code will know
  508. how many sample are required to fill it up.
  509. ===============
  510. */
  511. int SNDDMA_GetDMAPos(void)
  512. {
  513. MMTIME mmtime;
  514. int s;
  515. DWORD dwWrite;
  516. if (dsound_init)
  517. {
  518. mmtime.wType = TIME_SAMPLES;
  519. pDSBuf->lpVtbl->GetCurrentPosition(pDSBuf, &mmtime.u.sample, &dwWrite);
  520. s = mmtime.u.sample - mmstarttime.u.sample;
  521. }
  522. else if (wav_init)
  523. {
  524. s = snd_sent * WAV_BUFFER_SIZE;
  525. }
  526. s >>= sample16;
  527. s &= (shm->samples-1);
  528. return s;
  529. }
  530. /*
  531. ==============
  532. SNDDMA_Submit
  533. Send sound to device if buffer isn't really the dma buffer
  534. ===============
  535. */
  536. void SNDDMA_Submit(void)
  537. {
  538. LPWAVEHDR h;
  539. int wResult;
  540. if (!wav_init)
  541. return;
  542. //
  543. // find which sound blocks have completed
  544. //
  545. while (1)
  546. {
  547. if ( snd_completed == snd_sent )
  548. {
  549. Con_DPrintf ("Sound overrun\n");
  550. break;
  551. }
  552. if ( ! (lpWaveHdr[ snd_completed & WAV_MASK].dwFlags & WHDR_DONE) )
  553. {
  554. break;
  555. }
  556. snd_completed++; // this buffer has been played
  557. }
  558. //
  559. // submit two new sound blocks
  560. //
  561. while (((snd_sent - snd_completed) >> sample16) < 4)
  562. {
  563. h = lpWaveHdr + ( snd_sent&WAV_MASK );
  564. snd_sent++;
  565. /*
  566. * Now the data block can be sent to the output device. The
  567. * waveOutWrite function returns immediately and waveform
  568. * data is sent to the output device in the background.
  569. */
  570. wResult = waveOutWrite(hWaveOut, h, sizeof(WAVEHDR));
  571. if (wResult != MMSYSERR_NOERROR)
  572. {
  573. Con_SafePrintf ("Failed to write block to device\n");
  574. FreeSound ();
  575. return;
  576. }
  577. }
  578. }
  579. /*
  580. ==============
  581. SNDDMA_Shutdown
  582. Reset the sound device for exiting
  583. ===============
  584. */
  585. void SNDDMA_Shutdown(void)
  586. {
  587. FreeSound ();
  588. }