Mercurial > sdl-ios-xcode
comparison src/audio/mint/SDL_mintaudio_gsxb.c @ 2049:5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Tue, 17 Oct 2006 09:15:21 +0000 |
parents | 8d5d119b1640 |
children | 866052b01ee5 |
comparison
equal
deleted
inserted
replaced
2048:6067c7f9a672 | 2049:5f6550e5184f |
---|---|
61 | 61 |
62 static unsigned long cookie_snd, cookie_gsxb; | 62 static unsigned long cookie_snd, cookie_gsxb; |
63 | 63 |
64 /*--- Audio driver functions ---*/ | 64 /*--- Audio driver functions ---*/ |
65 | 65 |
66 static void Mint_CloseAudio(_THIS); | |
67 static int Mint_OpenAudio(_THIS, SDL_AudioSpec * spec); | |
68 static void Mint_LockAudio(_THIS); | |
69 static void Mint_UnlockAudio(_THIS); | |
70 | |
71 /* To check/init hardware audio */ | |
72 static int Mint_CheckAudio(_THIS, SDL_AudioSpec * spec); | |
73 static void Mint_InitAudio(_THIS, SDL_AudioSpec * spec); | |
74 | |
75 /* GSXB callbacks */ | 66 /* GSXB callbacks */ |
76 static void Mint_GsxbInterrupt(void); | 67 static void MINTGSXB_GsxbInterrupt(void); |
77 static void Mint_GsxbNullInterrupt(void); | 68 static void MINTGSXB_GsxbNullInterrupt(void); |
78 | 69 |
79 /*--- Audio driver bootstrap functions ---*/ | 70 static void |
80 | 71 MINTGSXB_LockDevice(_THIS) |
81 static int | |
82 Audio_Available(void) | |
83 { | |
84 const char *envr = SDL_getenv("SDL_AUDIODRIVER"); | |
85 | |
86 /* Check if user asked a different audio driver */ | |
87 if ((envr) && (SDL_strcmp(envr, MINT_AUDIO_DRIVER_NAME) != 0)) { | |
88 DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n")); | |
89 return (0); | |
90 } | |
91 | |
92 /* Cookie _SND present ? if not, assume ST machine */ | |
93 if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) { | |
94 cookie_snd = SND_PSG; | |
95 } | |
96 | |
97 /* Check if we have 16 bits audio */ | |
98 if ((cookie_snd & SND_16BIT) == 0) { | |
99 DEBUG_PRINT((DEBUG_NAME "no 16 bits sound\n")); | |
100 return (0); | |
101 } | |
102 | |
103 /* Cookie GSXB present ? */ | |
104 cookie_gsxb = (Getcookie(C_GSXB, &cookie_gsxb) == C_FOUND); | |
105 | |
106 /* Is it GSXB ? */ | |
107 if (((cookie_snd & SND_GSXB) == 0) || (cookie_gsxb == 0)) { | |
108 DEBUG_PRINT((DEBUG_NAME "no GSXB audio\n")); | |
109 return (0); | |
110 } | |
111 | |
112 /* Check if audio is lockable */ | |
113 if (Locksnd() != 1) { | |
114 DEBUG_PRINT((DEBUG_NAME "audio locked by other application\n")); | |
115 return (0); | |
116 } | |
117 | |
118 Unlocksnd(); | |
119 | |
120 DEBUG_PRINT((DEBUG_NAME "GSXB audio available!\n")); | |
121 return (1); | |
122 } | |
123 | |
124 static void | |
125 Audio_DeleteDevice(SDL_AudioDevice * device) | |
126 { | |
127 SDL_free(device->hidden); | |
128 SDL_free(device); | |
129 } | |
130 | |
131 static SDL_AudioDevice * | |
132 Audio_CreateDevice(int devindex) | |
133 { | |
134 SDL_AudioDevice *this; | |
135 | |
136 /* Initialize all variables that we clean on shutdown */ | |
137 this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); | |
138 if (this) { | |
139 SDL_memset(this, 0, (sizeof *this)); | |
140 this->hidden = (struct SDL_PrivateAudioData *) | |
141 SDL_malloc((sizeof *this->hidden)); | |
142 } | |
143 if ((this == NULL) || (this->hidden == NULL)) { | |
144 SDL_OutOfMemory(); | |
145 if (this) { | |
146 SDL_free(this); | |
147 } | |
148 return (0); | |
149 } | |
150 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); | |
151 | |
152 /* Set the function pointers */ | |
153 this->OpenAudio = Mint_OpenAudio; | |
154 this->CloseAudio = Mint_CloseAudio; | |
155 this->LockAudio = Mint_LockAudio; | |
156 this->UnlockAudio = Mint_UnlockAudio; | |
157 this->free = Audio_DeleteDevice; | |
158 | |
159 return this; | |
160 } | |
161 | |
162 AudioBootStrap MINTAUDIO_GSXB_bootstrap = { | |
163 MINT_AUDIO_DRIVER_NAME, "MiNT GSXB audio driver", | |
164 Audio_Available, Audio_CreateDevice | |
165 }; | |
166 | |
167 static void | |
168 Mint_LockAudio(_THIS) | |
169 { | 72 { |
170 /* Stop replay */ | 73 /* Stop replay */ |
171 Buffoper(0); | 74 Buffoper(0); |
172 } | 75 } |
173 | 76 |
174 static void | 77 static void |
175 Mint_UnlockAudio(_THIS) | 78 MINTGSXB_UnlockDevice(_THIS) |
176 { | 79 { |
177 /* Restart replay */ | 80 /* Restart replay */ |
178 Buffoper(SB_PLA_ENA | SB_PLA_RPT); | 81 Buffoper(SB_PLA_ENA | SB_PLA_RPT); |
179 } | 82 } |
180 | 83 |
181 static void | 84 static void |
182 Mint_CloseAudio(_THIS) | 85 MINTGSXB_CloseDevice(_THIS) |
183 { | 86 { |
184 /* Stop replay */ | 87 if (this->hidden != NULL) { |
185 Buffoper(0); | 88 /* Stop replay */ |
186 | 89 Buffoper(0); |
187 /* Uninstall interrupt */ | 90 |
188 if (NSetinterrupt(2, SI_NONE, Mint_GsxbNullInterrupt) < 0) { | 91 /* Uninstall interrupt */ |
189 DEBUG_PRINT((DEBUG_NAME "NSetinterrupt() failed in close\n")); | 92 if (NSetinterrupt(2, SI_NONE, MINTGSXB_GsxbNullInterrupt) < 0) { |
190 } | 93 DEBUG_PRINT((DEBUG_NAME "NSetinterrupt() failed in close\n")); |
191 | 94 } |
192 /* Wait if currently playing sound */ | 95 |
193 while (SDL_MintAudio_mutex != 0) { | 96 /* Wait if currently playing sound */ |
194 } | 97 while (SDL_MintAudio_mutex != 0) {} |
195 | 98 |
196 /* Clear buffers */ | 99 /* Clear buffers */ |
197 if (SDL_MintAudio_audiobuf[0]) { | 100 if (SDL_MintAudio_audiobuf[0]) { |
198 Mfree(SDL_MintAudio_audiobuf[0]); | 101 Mfree(SDL_MintAudio_audiobuf[0]); |
199 SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL; | 102 SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL; |
200 } | 103 } |
201 | 104 |
202 /* Unlock sound system */ | 105 /* Unlock sound system */ |
203 Unlocksnd(); | 106 Unlocksnd(); |
107 | |
108 SDL_free(this->hidden); | |
109 this->hidden = NULL; | |
110 } | |
204 } | 111 } |
205 | 112 |
206 static int | 113 static int |
207 Mint_CheckAudio(_THIS, SDL_AudioSpec * spec) | 114 MINTGSXB_CheckAudio(_THIS) |
208 { | 115 { |
209 long snd_format; | 116 long snd_format; |
210 int i, resolution, format_signed, format_bigendian; | 117 int i, resolution, format_signed, format_bigendian; |
211 SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format); | 118 SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format); |
212 int valid_datatype = 0; | 119 int valid_datatype = 0; |
213 | 120 |
214 resolution = SDL_AUDIO_BITSIZE(spec->format); | 121 resolution = SDL_AUDIO_BITSIZE(this->spec.format); |
215 format_signed = SDL_AUDIO_ISSIGNED(spec->format); | 122 format_signed = SDL_AUDIO_ISSIGNED(this->spec.format); |
216 format_bigendian = SDL_AUDIO_ISBIGENDIAN(spec->format); | 123 format_bigendian = SDL_AUDIO_ISBIGENDIAN(this->spec.format); |
217 | 124 |
218 DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", resolution)); | 125 DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", resolution)); |
219 DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(spec->format))); | 126 DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format))); |
220 DEBUG_PRINT(("signed=%d, ", format_signed)); | 127 DEBUG_PRINT(("signed=%d, ", format_signed)); |
221 DEBUG_PRINT(("big endian=%d, ", format_bigendian)); | 128 DEBUG_PRINT(("big endian=%d, ", format_bigendian)); |
222 DEBUG_PRINT(("channels=%d, ", spec->channels)); | 129 DEBUG_PRINT(("channels=%d, ", this->spec.channels)); |
223 DEBUG_PRINT(("freq=%d\n", spec->freq)); | 130 DEBUG_PRINT(("freq=%d\n", this->spec.freq)); |
224 | 131 |
225 if (spec->channels > 2) { | 132 if (this->spec.channels > 2) { |
226 spec->channels = 2; /* no more than stereo! */ | 133 this->spec.channels = 2; /* no more than stereo! */ |
227 } | 134 } |
228 | 135 |
229 while ((!valid_datatype) && (test_format)) { | 136 while ((!valid_datatype) && (test_format)) { |
230 /* Check formats available */ | 137 /* Check formats available */ |
231 snd_format = Sndstatus(SND_QUERYFORMATS); | 138 snd_format = Sndstatus(SND_QUERYFORMATS); |
232 spec->format = test_format; | 139 this->spec.format = test_format; |
233 resolution = SDL_AUDIO_BITSIZE(spec->format); | 140 resolution = SDL_AUDIO_BITSIZE(this->spec.format); |
234 format_signed = SDL_AUDIO_ISSIGNED(spec->format); | 141 format_signed = SDL_AUDIO_ISSIGNED(this->spec.format); |
235 format_bigendian = SDL_AUDIO_ISBIGENDIAN(spec->format); | 142 format_bigendian = SDL_AUDIO_ISBIGENDIAN(this->spec.format); |
236 switch (test_format) { | 143 switch (test_format) { |
237 case AUDIO_U8: | 144 case AUDIO_U8: |
238 case AUDIO_S8: | 145 case AUDIO_S8: |
239 if (snd_format & SND_FORMAT8) { | 146 if (snd_format & SND_FORMAT8) { |
240 valid_datatype = 1; | 147 valid_datatype = 1; |
277 if (format_signed) { | 184 if (format_signed) { |
278 if (snd_format & SND_FORMATSIGNED) { | 185 if (snd_format & SND_FORMATSIGNED) { |
279 /* Ok */ | 186 /* Ok */ |
280 } else if (snd_format & SND_FORMATUNSIGNED) { | 187 } else if (snd_format & SND_FORMATUNSIGNED) { |
281 /* Give unsigned format */ | 188 /* Give unsigned format */ |
282 spec->format = spec->format & (~SDL_AUDIO_MASK_SIGNED); | 189 this->spec.format = this->spec.format & (~SDL_AUDIO_MASK_SIGNED); |
283 } | 190 } |
284 } else { | 191 } else { |
285 if (snd_format & SND_FORMATUNSIGNED) { | 192 if (snd_format & SND_FORMATUNSIGNED) { |
286 /* Ok */ | 193 /* Ok */ |
287 } else if (snd_format & SND_FORMATSIGNED) { | 194 } else if (snd_format & SND_FORMATSIGNED) { |
288 /* Give signed format */ | 195 /* Give signed format */ |
289 spec->format |= SDL_AUDIO_MASK_SIGNED; | 196 this->spec.format |= SDL_AUDIO_MASK_SIGNED; |
290 } | 197 } |
291 } | 198 } |
292 | 199 |
293 if (format_bigendian) { | 200 if (format_bigendian) { |
294 if (snd_format & SND_FORMATBIGENDIAN) { | 201 if (snd_format & SND_FORMATBIGENDIAN) { |
295 /* Ok */ | 202 /* Ok */ |
296 } else if (snd_format & SND_FORMATLITTLEENDIAN) { | 203 } else if (snd_format & SND_FORMATLITTLEENDIAN) { |
297 /* Give little endian format */ | 204 /* Give little endian format */ |
298 spec->format = spec->format & (~SDL_AUDIO_MASK_ENDIAN); | 205 this->spec.format = this->spec.format & (~SDL_AUDIO_MASK_ENDIAN); |
299 } | 206 } |
300 } else { | 207 } else { |
301 if (snd_format & SND_FORMATLITTLEENDIAN) { | 208 if (snd_format & SND_FORMATLITTLEENDIAN) { |
302 /* Ok */ | 209 /* Ok */ |
303 } else if (snd_format & SND_FORMATBIGENDIAN) { | 210 } else if (snd_format & SND_FORMATBIGENDIAN) { |
304 /* Give big endian format */ | 211 /* Give big endian format */ |
305 spec->format |= SDL_AUDIO_MASK_ENDIAN; | 212 this->spec.format |= SDL_AUDIO_MASK_ENDIAN; |
306 } | 213 } |
307 } | 214 } |
308 | 215 |
309 /* Calculate and select the closest frequency */ | 216 /* Calculate and select the closest frequency */ |
310 MINTAUDIO_freqcount = 0; | 217 MINTAUDIO_freqcount = 0; |
322 MINTAUDIO_frequencies[i].masterclock, | 229 MINTAUDIO_frequencies[i].masterclock, |
323 MINTAUDIO_frequencies[i].predivisor)); | 230 MINTAUDIO_frequencies[i].predivisor)); |
324 } | 231 } |
325 #endif | 232 #endif |
326 | 233 |
327 MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency(this, spec->freq); | 234 MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency(this, this->spec.freq); |
328 spec->freq = MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency; | 235 this->spec.freq = MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency; |
329 | 236 |
330 DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", | 237 DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", |
331 SDL_AUDIO_BITSIZE(spec->format))); | 238 SDL_AUDIO_BITSIZE(this->spec.format))); |
332 DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(spec->format))); | 239 DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format))); |
333 DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(spec->format))); | 240 DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format))); |
334 DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(spec->format))); | 241 DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(this->spec.format))); |
335 DEBUG_PRINT(("channels=%d, ", spec->channels)); | 242 DEBUG_PRINT(("channels=%d, ", this->spec.channels)); |
336 DEBUG_PRINT(("freq=%d\n", spec->freq)); | 243 DEBUG_PRINT(("freq=%d\n", this->spec.freq)); |
337 | 244 |
338 return 0; | 245 return 0; |
339 } | 246 } |
340 | 247 |
341 static void | 248 static void |
342 Mint_InitAudio(_THIS, SDL_AudioSpec * spec) | 249 MINTGSXB_InitAudio(_THIS) |
343 { | 250 { |
344 int channels_mode, prediv; | 251 int channels_mode, prediv; |
345 void *buffer; | 252 void *buffer; |
346 | 253 |
347 /* Stop currently playing sound */ | 254 /* Stop currently playing sound */ |
350 /* Set replay tracks */ | 257 /* Set replay tracks */ |
351 Settracks(0, 0); | 258 Settracks(0, 0); |
352 Setmontracks(0); | 259 Setmontracks(0); |
353 | 260 |
354 /* Select replay format */ | 261 /* Select replay format */ |
355 switch (SDL_AUDIO_BITSIZE(spec->format)) { | 262 switch (SDL_AUDIO_BITSIZE(this->spec.format)) { |
356 case 8: | 263 case 8: |
357 if (spec->channels == 2) { | 264 if (this->spec.channels == 2) { |
358 channels_mode = STEREO8; | 265 channels_mode = STEREO8; |
359 } else { | 266 } else { |
360 channels_mode = MONO8; | 267 channels_mode = MONO8; |
361 } | 268 } |
362 break; | 269 break; |
363 case 16: | 270 case 16: |
364 if (spec->channels == 2) { | 271 if (this->spec.channels == 2) { |
365 channels_mode = STEREO16; | 272 channels_mode = STEREO16; |
366 } else { | 273 } else { |
367 channels_mode = MONO16; | 274 channels_mode = MONO16; |
368 } | 275 } |
369 break; | 276 break; |
370 case 32: | 277 case 32: |
371 if (spec->channels == 2) { | 278 if (this->spec.channels == 2) { |
372 channels_mode = STEREO32; | 279 channels_mode = STEREO32; |
373 } else { | 280 } else { |
374 channels_mode = MONO32; | 281 channels_mode = MONO32; |
375 } | 282 } |
376 break; | 283 break; |
385 prediv = MINTAUDIO_frequencies[MINTAUDIO_numfreq].predivisor; | 292 prediv = MINTAUDIO_frequencies[MINTAUDIO_numfreq].predivisor; |
386 Devconnect(DMAPLAY, DAC, CLKEXT, prediv, 1); | 293 Devconnect(DMAPLAY, DAC, CLKEXT, prediv, 1); |
387 | 294 |
388 /* Set buffer */ | 295 /* Set buffer */ |
389 buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf]; | 296 buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf]; |
390 if (Setbuffer(0, buffer, buffer + spec->size) < 0) { | 297 if (Setbuffer(0, buffer, buffer + this->spec.size) < 0) { |
391 DEBUG_PRINT((DEBUG_NAME "Setbuffer() failed\n")); | 298 DEBUG_PRINT((DEBUG_NAME "Setbuffer() failed\n")); |
392 } | 299 } |
393 | 300 |
394 /* Install interrupt */ | 301 /* Install interrupt */ |
395 if (NSetinterrupt(2, SI_PLAY, Mint_GsxbInterrupt) < 0) { | 302 if (NSetinterrupt(2, SI_PLAY, MINTGSXB_GsxbInterrupt) < 0) { |
396 DEBUG_PRINT((DEBUG_NAME "NSetinterrupt() failed\n")); | 303 DEBUG_PRINT((DEBUG_NAME "NSetinterrupt() failed\n")); |
397 } | 304 } |
398 | 305 |
399 /* Go */ | 306 /* Go */ |
400 Buffoper(SB_PLA_ENA | SB_PLA_RPT); | 307 Buffoper(SB_PLA_ENA | SB_PLA_RPT); |
401 DEBUG_PRINT((DEBUG_NAME "hardware initialized\n")); | 308 DEBUG_PRINT((DEBUG_NAME "hardware initialized\n")); |
402 } | 309 } |
403 | 310 |
404 static int | 311 static int |
405 Mint_OpenAudio(_THIS, SDL_AudioSpec * spec) | 312 MINTGSXB_OpenDevice(_THIS, const char *devname, int iscapture) |
406 { | 313 { |
407 /* Lock sound system */ | 314 /* Lock sound system */ |
408 if (Locksnd() != 1) { | 315 if (Locksnd() != 1) { |
409 SDL_SetError("Mint_OpenAudio: Audio system already in use"); | 316 SDL_SetError("MINTGSXB_OpenDevice: Audio system already in use"); |
410 return (-1); | 317 return 0; |
411 } | 318 } |
412 | 319 |
413 SDL_MintAudio_device = this; | 320 SDL_MintAudio_device = this; |
414 | 321 |
415 /* Check audio capabilities */ | 322 /* Check audio capabilities */ |
416 if (Mint_CheckAudio(this, spec) == -1) { | 323 if (MINTGSXB_CheckAudio(this) == -1) { |
417 return -1; | 324 return 0; |
418 } | 325 } |
419 | 326 |
420 SDL_CalculateAudioSpec(spec); | 327 /* Initialize all variables that we clean on shutdown */ |
328 this->hidden = (struct SDL_PrivateAudioData *) | |
329 SDL_malloc((sizeof *this->hidden)); | |
330 if (this->hidden == NULL) { | |
331 SDL_OutOfMemory(); | |
332 return 0; | |
333 } | |
334 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); | |
335 | |
336 SDL_CalculateAudioSpec(&this->spec); | |
421 | 337 |
422 /* Allocate memory for audio buffers in DMA-able RAM */ | 338 /* Allocate memory for audio buffers in DMA-able RAM */ |
423 DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", spec->size)); | 339 DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", this->spec.size)); |
424 | 340 |
425 SDL_MintAudio_audiobuf[0] = Atari_SysMalloc(spec->size * 2, MX_STRAM); | 341 SDL_MintAudio_audiobuf[0] = Atari_SysMalloc(this->spec.size * 2, MX_STRAM); |
426 if (SDL_MintAudio_audiobuf[0] == NULL) { | 342 if (SDL_MintAudio_audiobuf[0] == NULL) { |
427 SDL_SetError("MINT_OpenAudio: Not enough memory for audio buffer"); | 343 SDL_free(this->hidden); |
428 return (-1); | 344 this->hidden = NULL; |
429 } | 345 SDL_OutOfMemory(); |
430 SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + spec->size; | 346 return 0; |
347 } | |
348 SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + this->spec.size; | |
431 SDL_MintAudio_numbuf = 0; | 349 SDL_MintAudio_numbuf = 0; |
432 SDL_memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size * 2); | 350 SDL_memset(SDL_MintAudio_audiobuf[0],this->spec.silence,this->spec.size*2); |
433 SDL_MintAudio_audiosize = spec->size; | 351 SDL_MintAudio_audiosize = this->spec.size; |
434 SDL_MintAudio_mutex = 0; | 352 SDL_MintAudio_mutex = 0; |
435 | 353 |
436 DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n", | 354 DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n", |
437 SDL_MintAudio_audiobuf[0])); | 355 SDL_MintAudio_audiobuf[0])); |
438 DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n", | 356 DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n", |
439 SDL_MintAudio_audiobuf[1])); | 357 SDL_MintAudio_audiobuf[1])); |
440 | 358 |
441 SDL_MintAudio_CheckFpu(); | 359 SDL_MintAudio_CheckFpu(); |
442 | 360 |
443 /* Setup audio hardware */ | 361 /* Setup audio hardware */ |
444 Mint_InitAudio(this, spec); | 362 MINTGSXB_InitAudio(this); |
445 | 363 |
446 return (1); /* We don't use threaded audio */ | 364 return 1; /* good to go. */ |
447 } | 365 } |
448 | 366 |
449 static void | 367 static void |
450 Mint_GsxbInterrupt(void) | 368 MINTGSXB_GsxbInterrupt(void) |
451 { | 369 { |
452 Uint8 *newbuf; | 370 Uint8 *newbuf; |
453 | 371 |
454 if (SDL_MintAudio_mutex) | 372 if (SDL_MintAudio_mutex) |
455 return; | 373 return; |
463 | 381 |
464 SDL_MintAudio_mutex = 0; | 382 SDL_MintAudio_mutex = 0; |
465 } | 383 } |
466 | 384 |
467 static void | 385 static void |
468 Mint_GsxbNullInterrupt(void) | 386 MINTGSXB_GsxbNullInterrupt(void) |
469 { | 387 { |
470 } | 388 } |
389 | |
390 static int | |
391 MINTGSXB_Init(SDL_AudioDriverImpl *impl) | |
392 { | |
393 /* Cookie _SND present ? if not, assume ST machine */ | |
394 if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) { | |
395 cookie_snd = SND_PSG; | |
396 } | |
397 | |
398 /* Check if we have 16 bits audio */ | |
399 if ((cookie_snd & SND_16BIT) == 0) { | |
400 SDL_SetError(DEBUG_NAME "no 16-bit sound"); | |
401 return 0; | |
402 } | |
403 | |
404 /* Cookie GSXB present ? */ | |
405 cookie_gsxb = (Getcookie(C_GSXB, &cookie_gsxb) == C_FOUND); | |
406 | |
407 /* Is it GSXB ? */ | |
408 if (((cookie_snd & SND_GSXB) == 0) || (cookie_gsxb == 0)) { | |
409 SDL_SetError(DEBUG_NAME "no GSXB audio"); | |
410 return 0; | |
411 } | |
412 | |
413 /* Check if audio is lockable */ | |
414 if (Locksnd() != 1) { | |
415 SDL_SetError(DEBUG_NAME "audio locked by other application"); | |
416 return 0; | |
417 } | |
418 | |
419 Unlocksnd(); | |
420 | |
421 DEBUG_PRINT((DEBUG_NAME "GSXB audio available!\n")); | |
422 | |
423 /* Set the function pointers */ | |
424 impl->OpenDevice = MINTGSXB_OpenDevice; | |
425 impl->CloseDevice = MINTGSXB_CloseDevice; | |
426 impl->LockAudio = MINTGSXB_LockAudio; | |
427 impl->UnlockAudio = MINTGSXB_UnlockAudio; | |
428 impl->OnlyHasDefaultOutputDevice = 1; | |
429 impl->ProvidesOwnCallbackThread = 1; | |
430 impl->SkipMixerLock = 1; | |
431 | |
432 return 1; | |
433 } | |
434 | |
435 AudioBootStrap MINTAUDIO_GSXB_bootstrap = { | |
436 MINT_AUDIO_DRIVER_NAME, "MiNT GSXB audio driver", MINTGSXB_Init, 0 | |
437 }; | |
471 | 438 |
472 /* vi: set ts=4 sw=4 expandtab: */ | 439 /* vi: set ts=4 sw=4 expandtab: */ |