Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
454 lines (403 loc) · 15.6 KB

SDL_dart.c

File metadata and controls

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