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