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