Mercurial > sdl-ios-xcode
annotate src/audio/dart/SDL_dart.c @ 1358:c71e05b4dc2e
More header massaging... works great on Windows. ;-)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 10 Feb 2006 06:48:43 +0000 |
parents | 604d73db6802 |
children | 19418e4422cb |
rev | line source |
---|---|
1190 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1190
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
1190 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1190
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
1190 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1190
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
1190 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1190
diff
changeset
|
13 Lesser General Public License for more details. |
1190 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1190
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1190
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1190
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
1190 | 18 |
19 Sam Lantinga | |
20 slouken@libsdl.org | |
21 */ | |
22 | |
23 /* Allow access to a raw mixing buffer */ | |
24 | |
25 #include "SDL_timer.h" | |
26 #include "SDL_audio.h" | |
27 #include "SDL_audio_c.h" | |
28 #include "SDL_dart.h" | |
29 | |
30 // Buffer states: | |
31 #define BUFFER_EMPTY 0 | |
32 #define BUFFER_USED 1 | |
33 | |
34 typedef struct _tMixBufferDesc { | |
35 int iBufferUsage; // BUFFER_EMPTY or BUFFER_USED | |
36 SDL_AudioDevice *pSDLAudioDevice; | |
37 } tMixBufferDesc, *pMixBufferDesc; | |
38 | |
39 | |
40 //--------------------------------------------------------------------- | |
41 // DARTEventFunc | |
42 // | |
43 // This function is called by DART, when an event occures, like end of | |
44 // playback of a buffer, etc... | |
45 //--------------------------------------------------------------------- | |
46 LONG APIENTRY DARTEventFunc(ULONG ulStatus, | |
47 PMCI_MIX_BUFFER pBuffer, | |
48 ULONG ulFlags) | |
49 { | |
50 if (ulFlags && MIX_WRITE_COMPLETE) | |
51 { // Playback of buffer completed! | |
52 | |
53 // Get pointer to buffer description | |
54 pMixBufferDesc pBufDesc; | |
55 | |
56 if (pBuffer) | |
57 { | |
58 pBufDesc = (pMixBufferDesc) (*pBuffer).ulUserParm; | |
59 | |
60 if (pBufDesc) | |
61 { | |
62 SDL_AudioDevice *pSDLAudioDevice = pBufDesc->pSDLAudioDevice; | |
63 // Set the buffer to be empty | |
64 pBufDesc->iBufferUsage = BUFFER_EMPTY; | |
65 // And notify DART feeder thread that it will have to work a bit. | |
66 if (pSDLAudioDevice) | |
67 DosPostEventSem(pSDLAudioDevice->hidden->hevAudioBufferPlayed); | |
68 } | |
69 } | |
70 } | |
71 return TRUE; | |
72 } | |
73 | |
74 | |
75 int DART_OpenAudio(_THIS, SDL_AudioSpec *spec) | |
76 { | |
77 MCI_AMP_OPEN_PARMS AmpOpenParms; | |
78 MCI_GENERIC_PARMS GenericParms; | |
79 int iDeviceOrd = 0; // Default device to be used | |
80 int bOpenShared = 1; // Try opening it shared | |
81 int iBits = 16; // Default is 16 bits signed | |
82 int iFreq = 44100; // Default is 44KHz | |
83 int iChannels = 2; // Default is 2 channels (Stereo) | |
84 int iNumBufs = 2; // Number of audio buffers: 2 | |
85 int iBufSize; | |
86 int iOpenMode; | |
87 int iSilence; | |
88 int rc; | |
89 | |
90 // First thing is to try to open a given DART device! | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
91 SDL_memset(&AmpOpenParms, 0, sizeof(MCI_AMP_OPEN_PARMS)); |
1190 | 92 // pszDeviceType should contain the device type in low word, and device ordinal in high word! |
93 AmpOpenParms.pszDeviceType = (PSZ) (MCI_DEVTYPE_AUDIO_AMPMIX | (iDeviceOrd << 16)); | |
94 | |
95 iOpenMode = MCI_WAIT | MCI_OPEN_TYPE_ID; | |
96 if (bOpenShared) iOpenMode |= MCI_OPEN_SHAREABLE; | |
97 | |
98 rc = mciSendCommand( 0, MCI_OPEN, | |
99 iOpenMode, | |
100 (PVOID) &AmpOpenParms, 0); | |
101 if (rc!=MCIERR_SUCCESS) // No audio available?? | |
102 return (-1); | |
103 // Save the device ID we got from DART! | |
104 // We will use this in the next calls! | |
105 iDeviceOrd = AmpOpenParms.usDeviceID; | |
106 | |
107 // Determine the audio parameters from the AudioSpec | |
108 switch ( spec->format & 0xFF ) | |
109 { | |
110 case 8: | |
111 /* Unsigned 8 bit audio data */ | |
112 spec->format = AUDIO_U8; | |
113 iSilence = 0x80; | |
114 iBits = 8; | |
115 break; | |
116 case 16: | |
117 /* Signed 16 bit audio data */ | |
118 spec->format = AUDIO_S16; | |
119 iSilence = 0x00; | |
120 iBits = 16; | |
121 break; | |
122 default: | |
123 // Close DART, and exit with error code! | |
124 mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0); | |
125 SDL_SetError("Unsupported audio format"); | |
126 return(-1); | |
127 } | |
128 iFreq = spec->freq; | |
129 iChannels = spec->channels; | |
130 /* Update the fragment size as size in bytes */ | |
131 SDL_CalculateAudioSpec(spec); | |
132 iBufSize = spec->size; | |
133 | |
134 // Now query this device if it supports the given freq/bits/channels! | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
135 SDL_memset(&(_this->hidden->MixSetupParms), 0, sizeof(MCI_MIXSETUP_PARMS)); |
1190 | 136 _this->hidden->MixSetupParms.ulBitsPerSample = iBits; |
137 _this->hidden->MixSetupParms.ulFormatTag = MCI_WAVE_FORMAT_PCM; | |
138 _this->hidden->MixSetupParms.ulSamplesPerSec = iFreq; | |
139 _this->hidden->MixSetupParms.ulChannels = iChannels; | |
140 _this->hidden->MixSetupParms.ulFormatMode = MCI_PLAY; | |
141 _this->hidden->MixSetupParms.ulDeviceType = MCI_DEVTYPE_WAVEFORM_AUDIO; | |
142 _this->hidden->MixSetupParms.pmixEvent = DARTEventFunc; | |
143 rc = mciSendCommand (iDeviceOrd, MCI_MIXSETUP, | |
144 MCI_WAIT | MCI_MIXSETUP_QUERYMODE, | |
145 &(_this->hidden->MixSetupParms), 0); | |
146 if (rc!=MCIERR_SUCCESS) | |
147 { // The device cannot handle this format! | |
148 // Close DART, and exit with error code! | |
149 mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0); | |
150 SDL_SetError("Audio device doesn't support requested audio format"); | |
151 return(-1); | |
152 } | |
153 // The device can handle this format, so initialize! | |
154 rc = mciSendCommand(iDeviceOrd, MCI_MIXSETUP, | |
155 MCI_WAIT | MCI_MIXSETUP_INIT, | |
156 &(_this->hidden->MixSetupParms), 0); | |
157 if (rc!=MCIERR_SUCCESS) | |
158 { // The device could not be opened! | |
159 // Close DART, and exit with error code! | |
160 mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0); | |
161 SDL_SetError("Audio device could not be set up"); | |
162 return(-1); | |
163 } | |
164 // Ok, the device is initialized. | |
165 // Now we should allocate buffers. For this, we need a place where | |
166 // the buffer descriptors will be: | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
167 _this->hidden->pMixBuffers = (MCI_MIX_BUFFER *) SDL_malloc(sizeof(MCI_MIX_BUFFER)*iNumBufs); |
1190 | 168 if (!(_this->hidden->pMixBuffers)) |
169 { // Not enough memory! | |
170 // Close DART, and exit with error code! | |
171 mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0); | |
172 SDL_SetError("Not enough memory for audio buffer descriptors"); | |
173 return(-1); | |
174 } | |
175 // Now that we have the place for buffer list, we can ask DART for the | |
176 // buffers! | |
177 _this->hidden->BufferParms.ulNumBuffers = iNumBufs; // Number of buffers | |
178 _this->hidden->BufferParms.ulBufferSize = iBufSize; // each with this size | |
179 _this->hidden->BufferParms.pBufList = _this->hidden->pMixBuffers; // getting descriptorts into this list | |
180 // Allocate buffers! | |
181 rc = mciSendCommand(iDeviceOrd, MCI_BUFFER, | |
182 MCI_WAIT | MCI_ALLOCATE_MEMORY, | |
183 &(_this->hidden->BufferParms), 0); | |
184 if ((rc!=MCIERR_SUCCESS) || (iNumBufs != _this->hidden->BufferParms.ulNumBuffers) || (_this->hidden->BufferParms.ulBufferSize==0)) | |
185 { // Could not allocate memory! | |
186 // Close DART, and exit with error code! | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
187 SDL_free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL; |
1190 | 188 mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0); |
189 SDL_SetError("DART could not allocate buffers"); | |
190 return(-1); | |
191 } | |
192 // Ok, we have all the buffers allocated, let's mark them! | |
193 { | |
194 int i; | |
195 for (i=0; i<iNumBufs; i++) | |
196 { | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
197 pMixBufferDesc pBufferDesc = (pMixBufferDesc) SDL_malloc(sizeof(tMixBufferDesc));; |
1190 | 198 // Check if this buffer was really allocated by DART |
199 if ((!(_this->hidden->pMixBuffers[i].pBuffer)) || (!pBufferDesc)) | |
200 { // Wrong buffer! | |
201 // Close DART, and exit with error code! | |
202 // Free buffer descriptions | |
203 { int j; | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
204 for (j=0; j<i; j++) SDL_free((void *)(_this->hidden->pMixBuffers[j].ulUserParm)); |
1190 | 205 } |
206 // and cleanup | |
207 mciSendCommand(iDeviceOrd, MCI_BUFFER, MCI_WAIT | MCI_DEALLOCATE_MEMORY, &(_this->hidden->BufferParms), 0); | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
208 SDL_free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL; |
1190 | 209 mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0); |
210 SDL_SetError("Error at internal buffer check"); | |
211 return(-1); | |
212 } | |
213 pBufferDesc->iBufferUsage = BUFFER_EMPTY; | |
214 pBufferDesc->pSDLAudioDevice = _this; | |
215 | |
216 _this->hidden->pMixBuffers[i].ulBufferLength = _this->hidden->BufferParms.ulBufferSize; | |
217 _this->hidden->pMixBuffers[i].ulUserParm = (ULONG) pBufferDesc; // User parameter: Description of buffer | |
218 _this->hidden->pMixBuffers[i].ulFlags = 0; // Some stuff should be flagged here for DART, like end of | |
219 // audio data, but as we will continously send | |
220 // audio data, there will be no end.:) | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
221 SDL_memset(_this->hidden->pMixBuffers[i].pBuffer, iSilence, iBufSize); |
1190 | 222 } |
223 } | |
224 _this->hidden->iNextFreeBuffer = 0; | |
225 _this->hidden->iLastPlayedBuf = -1; | |
226 // Create event semaphore | |
227 if (DosCreateEventSem(NULL, &(_this->hidden->hevAudioBufferPlayed), 0, FALSE)!=NO_ERROR) | |
228 { | |
229 // Could not create event semaphore! | |
230 { | |
231 int i; | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
232 for (i=0; i<iNumBufs; i++) SDL_free((void *)(_this->hidden->pMixBuffers[i].ulUserParm)); |
1190 | 233 } |
234 mciSendCommand(iDeviceOrd, MCI_BUFFER, MCI_WAIT | MCI_DEALLOCATE_MEMORY, &(_this->hidden->BufferParms), 0); | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
235 SDL_free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL; |
1190 | 236 mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0); |
237 SDL_SetError("Could not create event semaphore"); | |
238 return(-1); | |
239 } | |
240 | |
241 // Store the new settings in global variables | |
242 _this->hidden->iCurrDeviceOrd = iDeviceOrd; | |
243 _this->hidden->iCurrFreq = iFreq; | |
244 _this->hidden->iCurrBits = iBits; | |
245 _this->hidden->iCurrChannels = iChannels; | |
246 _this->hidden->iCurrNumBufs = iNumBufs; | |
247 _this->hidden->iCurrBufSize = iBufSize; | |
248 | |
249 return (0); | |
250 } | |
251 | |
252 | |
253 | |
254 void DART_ThreadInit(_THIS) | |
255 { | |
256 return; | |
257 } | |
258 | |
259 /* This function waits until it is possible to write a full sound buffer */ | |
260 void DART_WaitAudio(_THIS) | |
261 { | |
262 int i; | |
263 pMixBufferDesc pBufDesc; | |
264 ULONG ulPostCount; | |
265 | |
266 DosResetEventSem(_this->hidden->hevAudioBufferPlayed, &ulPostCount); | |
267 // If there is already an empty buffer, then return now! | |
268 for (i=0; i<_this->hidden->iCurrNumBufs; i++) | |
269 { | |
270 pBufDesc = (pMixBufferDesc) _this->hidden->pMixBuffers[i].ulUserParm; | |
271 if (pBufDesc->iBufferUsage == BUFFER_EMPTY) | |
272 return; | |
273 } | |
274 // If there is no empty buffer, wait for one to be empty! | |
275 DosWaitEventSem(_this->hidden->hevAudioBufferPlayed, 1000); // Wait max 1 sec!!! Important! | |
276 return; | |
277 } | |
278 | |
279 void DART_PlayAudio(_THIS) | |
280 { | |
281 int iFreeBuf = _this->hidden->iNextFreeBuffer; | |
282 pMixBufferDesc pBufDesc; | |
283 | |
284 pBufDesc = (pMixBufferDesc) _this->hidden->pMixBuffers[iFreeBuf].ulUserParm; | |
285 pBufDesc->iBufferUsage = BUFFER_USED; | |
286 // Send it to DART to be queued | |
287 _this->hidden->MixSetupParms.pmixWrite(_this->hidden->MixSetupParms.ulMixHandle, | |
288 &(_this->hidden->pMixBuffers[iFreeBuf]), 1); | |
289 | |
290 _this->hidden->iLastPlayedBuf = iFreeBuf; | |
291 iFreeBuf = (iFreeBuf+1) % _this->hidden->iCurrNumBufs; | |
292 _this->hidden->iNextFreeBuffer = iFreeBuf; | |
293 } | |
294 | |
295 Uint8 *DART_GetAudioBuf(_THIS) | |
296 { | |
297 int iFreeBuf; | |
298 Uint8 *pResult; | |
299 pMixBufferDesc pBufDesc; | |
300 | |
301 if (_this) | |
302 { | |
303 if (_this->hidden) | |
304 { | |
305 iFreeBuf = _this->hidden->iNextFreeBuffer; | |
306 pBufDesc = (pMixBufferDesc) _this->hidden->pMixBuffers[iFreeBuf].ulUserParm; | |
307 | |
308 if (pBufDesc) | |
309 { | |
310 if (pBufDesc->iBufferUsage == BUFFER_EMPTY) | |
311 { | |
312 pResult = _this->hidden->pMixBuffers[iFreeBuf].pBuffer; | |
313 return pResult; | |
314 } | |
315 } else | |
316 printf("[DART_GetAudioBuf] : ERROR! pBufDesc = %p\n", pBufDesc); | |
317 } else | |
318 printf("[DART_GetAudioBuf] : ERROR! _this->hidden = %p\n", _this->hidden); | |
319 } else | |
320 printf("[DART_GetAudioBuf] : ERROR! _this = %p\n", _this); | |
321 return NULL; | |
322 } | |
323 | |
324 void DART_WaitDone(_THIS) | |
325 { | |
326 pMixBufferDesc pBufDesc; | |
327 ULONG ulPostCount; | |
328 APIRET rc; | |
329 | |
330 pBufDesc = (pMixBufferDesc) _this->hidden->pMixBuffers[_this->hidden->iLastPlayedBuf].ulUserParm; | |
331 rc = NO_ERROR; | |
332 while ((pBufDesc->iBufferUsage != BUFFER_EMPTY) && (rc==NO_ERROR)) | |
333 { | |
334 DosResetEventSem(_this->hidden->hevAudioBufferPlayed, &ulPostCount); | |
335 rc = DosWaitEventSem(_this->hidden->hevAudioBufferPlayed, 1000); // 1 sec timeout! Important! | |
336 } | |
337 } | |
338 | |
339 void DART_CloseAudio(_THIS) | |
340 { | |
341 MCI_GENERIC_PARMS GenericParms; | |
342 int rc; | |
343 | |
344 // Stop DART playback | |
345 rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_STOP, MCI_WAIT, &GenericParms, 0); | |
346 if (rc!=MCIERR_SUCCESS) | |
347 { | |
348 #ifdef SFX_DEBUG_BUILD | |
349 printf("Could not stop DART playback!\n"); | |
350 fflush(stdout); | |
351 #endif | |
352 } | |
353 | |
354 // Close event semaphore | |
355 DosCloseEventSem(_this->hidden->hevAudioBufferPlayed); | |
356 | |
357 // Free memory of buffer descriptions | |
358 { | |
359 int i; | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
360 for (i=0; i<_this->hidden->iCurrNumBufs; i++) SDL_free((void *)(_this->hidden->pMixBuffers[i].ulUserParm)); |
1190 | 361 } |
362 | |
363 // Deallocate buffers | |
364 rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_BUFFER, MCI_WAIT | MCI_DEALLOCATE_MEMORY, &(_this->hidden->BufferParms), 0); | |
365 | |
366 // Free bufferlist | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
367 SDL_free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL; |
1190 | 368 |
369 // Close dart | |
370 rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_CLOSE, MCI_WAIT, &(GenericParms), 0); | |
371 } | |
372 | |
373 /* Audio driver bootstrap functions */ | |
374 | |
375 int Audio_Available(void) | |
376 { | |
377 return(1); | |
378 } | |
379 | |
380 void Audio_DeleteDevice(SDL_AudioDevice *device) | |
381 { | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
382 SDL_free(device->hidden); |
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
383 SDL_free(device); |
1190 | 384 } |
385 | |
386 SDL_AudioDevice *Audio_CreateDevice(int devindex) | |
387 { | |
388 SDL_AudioDevice *this; | |
389 | |
390 /* Initialize all variables that we clean on shutdown */ | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
391 this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice)); |
1190 | 392 if ( this ) |
393 { | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
394 SDL_memset(this, 0, (sizeof *this)); |
1190 | 395 this->hidden = (struct SDL_PrivateAudioData *) |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
396 SDL_malloc((sizeof *this->hidden)); |
1190 | 397 } |
398 if ( (this == NULL) || (this->hidden == NULL) ) | |
399 { | |
400 SDL_OutOfMemory(); | |
401 if ( this ) | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
402 SDL_free(this); |
1190 | 403 return(0); |
404 } | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
405 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); |
1190 | 406 |
407 /* Set the function pointers */ | |
408 this->OpenAudio = DART_OpenAudio; | |
409 this->ThreadInit = DART_ThreadInit; | |
410 this->WaitAudio = DART_WaitAudio; | |
411 this->PlayAudio = DART_PlayAudio; | |
412 this->GetAudioBuf = DART_GetAudioBuf; | |
413 this->WaitDone = DART_WaitDone; | |
414 this->CloseAudio = DART_CloseAudio; | |
415 | |
416 this->free = Audio_DeleteDevice; | |
417 | |
418 return this; | |
419 } | |
420 | |
421 AudioBootStrap DART_bootstrap = { | |
422 "dart", "OS/2 Direct Audio RouTines (DART)", | |
423 Audio_Available, Audio_CreateDevice | |
424 }; | |
425 |