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

Latest commit

 

History

History
452 lines (395 loc) · 15.5 KB

SDL_dart.c

File metadata and controls

452 lines (395 loc) · 15.5 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
Jul 10, 2006
Jul 10, 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
} tMixBufferDesc, *pMixBufferDesc;
//---------------------------------------------------------------------
// DARTEventFunc
//
Oct 17, 2006
Oct 17, 2006
45
// This function is called by DART, when an event occurs, like end of
Nov 23, 2005
Nov 23, 2005
46
47
// playback of a buffer, etc...
//---------------------------------------------------------------------
Oct 17, 2006
Oct 17, 2006
48
static LONG APIENTRY
Jul 10, 2006
Jul 10, 2006
49
DARTEventFunc(ULONG ulStatus, PMCI_MIX_BUFFER pBuffer, ULONG ulFlags)
Nov 23, 2005
Nov 23, 2005
50
{
Jul 10, 2006
Jul 10, 2006
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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)
DosPostEventSem(pSDLAudioDevice->hidden->
hevAudioBufferPlayed);
}
}
Nov 23, 2005
Nov 23, 2005
69
}
Jul 10, 2006
Jul 10, 2006
70
return TRUE;
Nov 23, 2005
Nov 23, 2005
71
72
73
}
Oct 17, 2006
Oct 17, 2006
74
75
static int
DART_OpenDevice(_THIS, const char *devname, int iscapture)
Nov 23, 2005
Nov 23, 2005
76
{
Oct 17, 2006
Oct 17, 2006
77
SDL_AudioFormat test_format = SDL_FirstAudioFormat(_this->spec.format);
Aug 31, 2006
Aug 31, 2006
78
int valid_datatype = 0;
Jul 10, 2006
Jul 10, 2006
79
80
81
82
83
84
85
86
87
88
89
90
MCI_AMP_OPEN_PARMS AmpOpenParms;
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;
Oct 17, 2006
Oct 17, 2006
91
92
93
94
95
96
97
98
99
/* Initialize all variables that we clean on shutdown */
_this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *_this->hidden));
if (_this->hidden == NULL) {
SDL_OutOfMemory();
return 0;
}
SDL_memset(_this->hidden, 0, (sizeof *_this->hidden));
Jul 10, 2006
Jul 10, 2006
100
101
102
103
104
105
106
107
108
109
110
// First thing is to try to open a given DART device!
SDL_memset(&AmpOpenParms, 0, sizeof(MCI_AMP_OPEN_PARMS));
// 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;
rc = mciSendCommand(0, MCI_OPEN, iOpenMode, (PVOID) & AmpOpenParms, 0);
Oct 17, 2006
Oct 17, 2006
111
112
113
114
115
116
if (rc != MCIERR_SUCCESS) { // No audio available??
DART_CloseDevice(_this);
SDL_SetError("DART: Couldn't open audio device.");
return 0;
}
Jul 10, 2006
Jul 10, 2006
117
118
// Save the device ID we got from DART!
// We will use this in the next calls!
Oct 17, 2006
Oct 17, 2006
119
_this->hidden->iCurrDeviceOrd = iDeviceOrd = AmpOpenParms.usDeviceID;
Jul 10, 2006
Jul 10, 2006
120
121
// Determine the audio parameters from the AudioSpec
Oct 17, 2006
Oct 17, 2006
122
123
if (_this->spec.channels > 4)
_this->spec.channels = 4;
Aug 31, 2006
Aug 31, 2006
124
Aug 31, 2006
Aug 31, 2006
125
while ((!valid_datatype) && (test_format)) {
Oct 17, 2006
Oct 17, 2006
126
_this->spec.format = test_format;
Aug 31, 2006
Aug 31, 2006
127
valid_datatype = 1;
Aug 31, 2006
Aug 31, 2006
128
switch (test_format) {
Sep 24, 2006
Sep 24, 2006
129
130
131
case AUDIO_U8:
// Unsigned 8 bit audio data
iSilence = 0x80;
Oct 17, 2006
Oct 17, 2006
132
_this->hidden->iCurrBits = iBits = 8;
Sep 24, 2006
Sep 24, 2006
133
134
135
136
137
break;
case AUDIO_S16LSB:
// Signed 16 bit audio data
iSilence = 0x00;
Oct 17, 2006
Oct 17, 2006
138
_this->hidden->iCurrBits = iBits = 16;
Sep 24, 2006
Sep 24, 2006
139
break;
Aug 31, 2006
Aug 31, 2006
140
141
142
// !!! FIXME: int32?
Sep 24, 2006
Sep 24, 2006
143
144
145
146
default:
valid_datatype = 0;
test_format = SDL_NextAudioFormat();
break;
Aug 31, 2006
Aug 31, 2006
147
148
149
}
}
Sep 24, 2006
Sep 24, 2006
150
if (!valid_datatype) { // shouldn't happen, but just in case...
Nov 23, 2005
Nov 23, 2005
151
// Close DART, and exit with error code!
Oct 17, 2006
Oct 17, 2006
152
DART_CloseDevice(_this);
Nov 23, 2005
Nov 23, 2005
153
SDL_SetError("Unsupported audio format");
Oct 17, 2006
Oct 17, 2006
154
return 0;
Jul 10, 2006
Jul 10, 2006
155
}
Aug 31, 2006
Aug 31, 2006
156
Oct 17, 2006
Oct 17, 2006
157
158
_this->hidden->iCurrFreq = iFreq = _this->spec.freq;
_this->hidden->iCurrChannels = iChannels = _this->spec.channels;
Jul 10, 2006
Jul 10, 2006
159
/* Update the fragment size as size in bytes */
Oct 17, 2006
Oct 17, 2006
160
161
SDL_CalculateAudioSpec(&_this->spec);
_this->hidden->iCurrBufSize = iBufSize = _this->spec.size;
Jul 10, 2006
Jul 10, 2006
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
// Now query this device if it supports the given freq/bits/channels!
SDL_memset(&(_this->hidden->MixSetupParms), 0,
sizeof(MCI_MIXSETUP_PARMS));
_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;
rc = mciSendCommand(iDeviceOrd, MCI_MIXSETUP,
MCI_WAIT | MCI_MIXSETUP_QUERYMODE,
&(_this->hidden->MixSetupParms), 0);
if (rc != MCIERR_SUCCESS) { // The device cannot handle this format!
// Close DART, and exit with error code!
Oct 17, 2006
Oct 17, 2006
178
DART_CloseDevice(_this);
Jul 10, 2006
Jul 10, 2006
179
SDL_SetError("Audio device doesn't support requested audio format");
Oct 17, 2006
Oct 17, 2006
180
return 0;
Jul 10, 2006
Jul 10, 2006
181
182
183
184
185
186
}
// The device can handle this format, so initialize!
rc = mciSendCommand(iDeviceOrd, MCI_MIXSETUP,
MCI_WAIT | MCI_MIXSETUP_INIT,
&(_this->hidden->MixSetupParms), 0);
if (rc != MCIERR_SUCCESS) { // The device could not be opened!
Nov 23, 2005
Nov 23, 2005
187
// Close DART, and exit with error code!
Oct 17, 2006
Oct 17, 2006
188
DART_CloseDevice(_this);
Jul 10, 2006
Jul 10, 2006
189
SDL_SetError("Audio device could not be set up");
Oct 17, 2006
Oct 17, 2006
190
return 0;
Nov 23, 2005
Nov 23, 2005
191
}
Jul 10, 2006
Jul 10, 2006
192
193
194
195
196
197
198
// 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 =
(MCI_MIX_BUFFER *) SDL_malloc(sizeof(MCI_MIX_BUFFER) * iNumBufs);
if (!(_this->hidden->pMixBuffers)) { // Not enough memory!
// Close DART, and exit with error code!
Oct 17, 2006
Oct 17, 2006
199
200
201
DART_CloseDevice(_this);
SDL_OutOfMemory();
return 0;
Jul 10, 2006
Jul 10, 2006
202
203
204
205
206
207
208
209
210
211
212
213
214
215
}
// 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!
rc = mciSendCommand(iDeviceOrd, MCI_BUFFER,
MCI_WAIT | MCI_ALLOCATE_MEMORY,
&(_this->hidden->BufferParms), 0);
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!
Oct 17, 2006
Oct 17, 2006
216
DART_CloseDevice(_this);
Jul 10, 2006
Jul 10, 2006
217
SDL_SetError("DART could not allocate buffers");
Oct 17, 2006
Oct 17, 2006
218
return 0;
Jul 10, 2006
Jul 10, 2006
219
}
Oct 17, 2006
Oct 17, 2006
220
221
_this->hidden->iCurrNumBufs = iNumBufs;
Jul 10, 2006
Jul 10, 2006
222
// Ok, we have all the buffers allocated, let's mark them!
Nov 23, 2005
Nov 23, 2005
223
{
Jul 10, 2006
Jul 10, 2006
224
225
226
227
228
229
230
int i;
for (i = 0; i < iNumBufs; i++) {
pMixBufferDesc pBufferDesc =
(pMixBufferDesc) SDL_malloc(sizeof(tMixBufferDesc));;
// Check if this buffer was really allocated by DART
if ((!(_this->hidden->pMixBuffers[i].pBuffer))
|| (!pBufferDesc)) { // Wrong buffer!
Oct 17, 2006
Oct 17, 2006
231
DART_CloseDevice(_this);
Jul 10, 2006
Jul 10, 2006
232
SDL_SetError("Error at internal buffer check");
Oct 17, 2006
Oct 17, 2006
233
return 0;
Jul 10, 2006
Jul 10, 2006
234
235
236
237
238
239
240
241
242
243
244
245
246
}
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.:)
SDL_memset(_this->hidden->pMixBuffers[i].pBuffer, iSilence,
iBufSize);
}
Nov 23, 2005
Nov 23, 2005
247
}
Jul 10, 2006
Jul 10, 2006
248
249
250
251
252
253
_this->hidden->iNextFreeBuffer = 0;
_this->hidden->iLastPlayedBuf = -1;
// Create event semaphore
if (DosCreateEventSem
(NULL, &(_this->hidden->hevAudioBufferPlayed), 0, FALSE) != NO_ERROR)
{
Oct 17, 2006
Oct 17, 2006
254
DART_CloseDevice(_this);
Jul 10, 2006
Jul 10, 2006
255
SDL_SetError("Could not create event semaphore");
Oct 17, 2006
Oct 17, 2006
256
return 0;
Jul 10, 2006
Jul 10, 2006
257
258
}
Oct 17, 2006
Oct 17, 2006
259
return 1;
Nov 23, 2005
Nov 23, 2005
260
261
}
Oct 17, 2006
Oct 17, 2006
262
static void
Jul 10, 2006
Jul 10, 2006
263
DART_ThreadInit(_THIS)
Nov 23, 2005
Nov 23, 2005
264
{
Oct 17, 2006
Oct 17, 2006
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
/* Increase the priority of this thread to make sure that
the audio will be continuous all the time! */
#ifdef USE_DOSSETPRIORITY
if (SDL_getenv("SDL_USE_TIMECRITICAL_AUDIO")) {
#ifdef DEBUG_BUILD
printf
("[DART_ThreadInit] : Setting priority to TimeCritical+0! (TID%d)\n",
SDL_ThreadID());
#endif
DosSetPriority(PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, 0);
} else {
#ifdef DEBUG_BUILD
printf
("[DART_ThreadInit] : Setting priority to ForegroundServer+0! (TID%d)\n",
SDL_ThreadID());
#endif
DosSetPriority(PRTYS_THREAD, PRTYC_FOREGROUNDSERVER, 0, 0);
}
#endif
Nov 23, 2005
Nov 23, 2005
284
285
286
}
/* This function waits until it is possible to write a full sound buffer */
Oct 17, 2006
Oct 17, 2006
287
288
static void
DART_WaitDevice(_THIS)
Nov 23, 2005
Nov 23, 2005
289
{
Jul 10, 2006
Jul 10, 2006
290
291
292
293
294
295
296
297
298
299
300
301
302
303
int i;
pMixBufferDesc pBufDesc;
ULONG ulPostCount;
DosResetEventSem(_this->hidden->hevAudioBufferPlayed, &ulPostCount);
// 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!
DosWaitEventSem(_this->hidden->hevAudioBufferPlayed, 1000); // Wait max 1 sec!!! Important!
return;
Nov 23, 2005
Nov 23, 2005
304
305
}
Oct 17, 2006
Oct 17, 2006
306
307
static void
DART_PlayDevice(_THIS)
Nov 23, 2005
Nov 23, 2005
308
{
Jul 10, 2006
Jul 10, 2006
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
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
_this->hidden->MixSetupParms.pmixWrite(_this->hidden->MixSetupParms.
ulMixHandle,
&(_this->hidden->
pMixBuffers[iFreeBuf]), 1);
_this->hidden->iLastPlayedBuf = iFreeBuf;
iFreeBuf = (iFreeBuf + 1) % _this->hidden->iCurrNumBufs;
_this->hidden->iNextFreeBuffer = iFreeBuf;
Nov 23, 2005
Nov 23, 2005
324
325
}
Oct 17, 2006
Oct 17, 2006
326
327
static Uint8 *
DART_GetDeviceBuf(_THIS)
Nov 23, 2005
Nov 23, 2005
328
{
Jul 10, 2006
Jul 10, 2006
329
330
331
int iFreeBuf;
Uint8 *pResult;
pMixBufferDesc pBufDesc;
Nov 23, 2005
Nov 23, 2005
332
Jul 10, 2006
Jul 10, 2006
333
334
335
336
337
338
339
340
341
342
343
344
345
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
Oct 17, 2006
Oct 17, 2006
346
printf("[DART_GetDeviceBuf] : ERROR! pBufDesc = %p\n",
Jul 10, 2006
Jul 10, 2006
347
348
pBufDesc);
} else
Oct 17, 2006
Oct 17, 2006
349
printf("[DART_GetDeviceBuf] : ERROR! _this->hidden = %p\n",
Jul 10, 2006
Jul 10, 2006
350
_this->hidden);
Nov 23, 2005
Nov 23, 2005
351
} else
Oct 17, 2006
Oct 17, 2006
352
printf("[DART_GetDeviceBuf] : ERROR! _this = %p\n", _this);
Jul 10, 2006
Jul 10, 2006
353
return NULL;
Nov 23, 2005
Nov 23, 2005
354
355
}
Oct 17, 2006
Oct 17, 2006
356
static void
Jul 10, 2006
Jul 10, 2006
357
DART_WaitDone(_THIS)
Nov 23, 2005
Nov 23, 2005
358
{
Jul 10, 2006
Jul 10, 2006
359
pMixBufferDesc pBufDesc;
Oct 17, 2006
Oct 17, 2006
360
361
362
363
364
ULONG ulPostCount = 0;
APIRET rc = NO_ERROR;
pBufDesc = (pMixBufferDesc)
_this->hidden->pMixBuffers[_this->hidden->iLastPlayedBuf].ulUserParm;
Jul 10, 2006
Jul 10, 2006
365
366
367
368
369
while ((pBufDesc->iBufferUsage != BUFFER_EMPTY) && (rc == NO_ERROR)) {
DosResetEventSem(_this->hidden->hevAudioBufferPlayed, &ulPostCount);
rc = DosWaitEventSem(_this->hidden->hevAudioBufferPlayed, 1000); // 1 sec timeout! Important!
}
Nov 23, 2005
Nov 23, 2005
370
371
}
Oct 17, 2006
Oct 17, 2006
372
373
static void
DART_CloseDevice(_THIS)
Nov 23, 2005
Nov 23, 2005
374
{
Jul 10, 2006
Jul 10, 2006
375
376
MCI_GENERIC_PARMS GenericParms;
int rc;
Oct 17, 2006
Oct 17, 2006
377
int i;
Nov 23, 2005
Nov 23, 2005
378
Oct 17, 2006
Oct 17, 2006
379
380
381
382
383
if (_this->hidden != NULL) {
// Stop DART playback
if (_this->hidden->iCurrDeviceOrd) {
rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_STOP,
MCI_WAIT, &GenericParms, 0);
Nov 23, 2005
Nov 23, 2005
384
#ifdef SFX_DEBUG_BUILD
Oct 17, 2006
Oct 17, 2006
385
386
387
388
if (rc != MCIERR_SUCCESS) {
printf("Could not stop DART playback!\n");
fflush(stdout);
}
Nov 23, 2005
Nov 23, 2005
389
#endif
Oct 17, 2006
Oct 17, 2006
390
}
Nov 23, 2005
Nov 23, 2005
391
Oct 17, 2006
Oct 17, 2006
392
393
394
395
396
// Close event semaphore
if (_this->hidden->hevAudioBufferPlayed) {
DosCloseEventSem(_this->hidden->hevAudioBufferPlayed);
_this->hidden->hevAudioBufferPlayed = 0;
}
Nov 23, 2005
Nov 23, 2005
397
Oct 17, 2006
Oct 17, 2006
398
399
400
401
402
403
// Free memory of buffer descriptions
for (i = 0; i < _this->hidden->iCurrNumBufs; i++) {
SDL_free((void *) (_this->hidden->pMixBuffers[i].ulUserParm));
_this->hidden->pMixBuffers[i].ulUserParm = 0;
}
_this->hidden->iCurrNumBufs = 0;
Nov 23, 2005
Nov 23, 2005
404
Oct 17, 2006
Oct 17, 2006
405
406
407
408
409
410
// Deallocate buffers
if (_this->hidden->iCurrDeviceOrd) {
rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_BUFFER,
MCI_WAIT | MCI_DEALLOCATE_MEMORY,
&(_this->hidden->BufferParms), 0);
}
Nov 23, 2005
Nov 23, 2005
411
Oct 17, 2006
Oct 17, 2006
412
413
414
415
416
// Free bufferlist
if (_this->hidden->pMixBuffers != NULL) {
SDL_free(_this->hidden->pMixBuffers);
_this->hidden->pMixBuffers = NULL;
}
Nov 23, 2005
Nov 23, 2005
417
Oct 17, 2006
Oct 17, 2006
418
419
420
421
422
423
// Close dart
if (_this->hidden->iCurrDeviceOrd) {
rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_CLOSE,
MCI_WAIT, &(GenericParms), 0);
}
_this->hidden->iCurrDeviceOrd = 0;
Nov 23, 2005
Nov 23, 2005
424
Oct 17, 2006
Oct 17, 2006
425
426
427
SDL_free(_this->hidden);
_this->hidden = NULL;
}
Nov 23, 2005
Nov 23, 2005
428
429
430
}
Oct 17, 2006
Oct 17, 2006
431
432
static int
DART_Init(SDL_AudioDriverImpl *impl)
Nov 23, 2005
Nov 23, 2005
433
{
Jul 10, 2006
Jul 10, 2006
434
/* Set the function pointers */
Oct 17, 2006
Oct 17, 2006
435
436
437
438
439
440
441
442
443
444
impl->OpenDevice = DART_OpenDevice;
impl->ThreadInit = DART_ThreadInit;
impl->WaitDevice = DART_WaitDevice;
impl->GetDeviceBuf = DART_GetDeviceBuf;
impl->PlayDevice = DART_PlayDevice;
impl->WaitDone = DART_WaitDone;
impl->CloseDevice = DART_CloseDevice;
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: is this right? */
return 1;
Nov 23, 2005
Nov 23, 2005
445
446
}
Oct 17, 2006
Oct 17, 2006
447
Nov 23, 2005
Nov 23, 2005
448
AudioBootStrap DART_bootstrap = {
Oct 17, 2006
Oct 17, 2006
449
"dart", "OS/2 Direct Audio RouTines (DART)", DART_Init, 0
Nov 23, 2005
Nov 23, 2005
450
451
};
Jul 10, 2006
Jul 10, 2006
452
/* vi: set ts=4 sw=4 expandtab: */