comparison src/audio/mint/SDL_mintaudio_dma8.c @ 3846:66fb40445587 SDL-ryan-multiple-audio-device

Removed distinction between "available" and "init" in audio backends, since both had to be checked for success as a pair at the higher level and several of the Available methods were just always-succeed placeholders anyhow. Now the availability check is done in the init code, and the higher level tries all possible drivers until one manages to initialize successfully.
author Ryan C. Gordon <icculus@icculus.org>
date Tue, 17 Oct 2006 09:09:21 +0000
parents 1f156fd874fa
children
comparison
equal deleted inserted replaced
3845:ee5dfa7f7993 3846:66fb40445587
58 #endif 58 #endif
59 59
60 /*--- Static variables ---*/ 60 /*--- Static variables ---*/
61 61
62 static unsigned long cookie_snd, cookie_mch; 62 static unsigned long cookie_snd, cookie_mch;
63
64
65 static int
66 MINTDMA8_Available(void)
67 {
68 /* Cookie _MCH present ? if not, assume ST machine */
69 if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) {
70 cookie_mch = MCH_ST;
71 }
72
73 /* Cookie _SND present ? if not, assume ST machine */
74 if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
75 cookie_snd = SND_PSG;
76 }
77
78 /* Check if we have 8 bits audio */
79 if ((cookie_snd & SND_8BIT) == 0) {
80 DEBUG_PRINT((DEBUG_NAME "no 8 bits sound\n"));
81 return (0);
82 }
83
84 /* Check if audio is lockable */
85 if (cookie_snd & SND_16BIT) {
86 if (Locksnd() != 1) {
87 DEBUG_PRINT((DEBUG_NAME "audio locked by other application\n"));
88 return (0);
89 }
90
91 Unlocksnd();
92 }
93
94 DEBUG_PRINT((DEBUG_NAME "8 bits audio available!\n"));
95 return (1);
96 }
97 63
98 static void 64 static void
99 MINTDMA8_LockDevice(_THIS) 65 MINTDMA8_LockDevice(_THIS)
100 { 66 {
101 void *oldpile; 67 void *oldpile;
328 } 294 }
329 295
330 static int 296 static int
331 MINTDMA8_Init(SDL_AudioDriverImpl *impl) 297 MINTDMA8_Init(SDL_AudioDriverImpl *impl)
332 { 298 {
299 /* Cookie _MCH present ? if not, assume ST machine */
300 if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) {
301 cookie_mch = MCH_ST;
302 }
303
304 /* Cookie _SND present ? if not, assume ST machine */
305 if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
306 cookie_snd = SND_PSG;
307 }
308
309 /* Check if we have 8 bits audio */
310 if ((cookie_snd & SND_8BIT) == 0) {
311 SDL_SetError(DEBUG_NAME "no 8 bits sound");
312 return 0;
313 }
314
315 /* Check if audio is lockable */
316 if (cookie_snd & SND_16BIT) {
317 if (Locksnd() != 1) {
318 SDL_SetError(DEBUG_NAME "audio locked by other application");
319 return 0;
320 }
321
322 Unlocksnd();
323 }
324
325 DEBUG_PRINT((DEBUG_NAME "8 bits audio available!\n"));
326
333 /* Set the function pointers */ 327 /* Set the function pointers */
334 impl->OpenDevice = MINTDMA8_OpenDevice; 328 impl->OpenDevice = MINTDMA8_OpenDevice;
335 impl->CloseDevice = MINTDMA8_CloseDevice; 329 impl->CloseDevice = MINTDMA8_CloseDevice;
336 impl->LockAudio = MINTDMA8_LockAudio; 330 impl->LockAudio = MINTDMA8_LockAudio;
337 impl->UnlockAudio = MINTDMA8_UnlockAudio; 331 impl->UnlockAudio = MINTDMA8_UnlockAudio;
341 335
342 return 1; 336 return 1;
343 } 337 }
344 338
345 AudioBootStrap MINTAUDIO_DMA8_bootstrap = { 339 AudioBootStrap MINTAUDIO_DMA8_bootstrap = {
346 MINT_AUDIO_DRIVER_NAME, "MiNT DMA 8 bits audio driver", 340 MINT_AUDIO_DRIVER_NAME, "MiNT DMA 8 bits audio driver", MINTDMA8_Init, 0
347 MINTDMA8_Available, MINTDMA8_Init, 0
348 }; 341 };
349 342
350 /* vi: set ts=4 sw=4 expandtab: */ 343 /* vi: set ts=4 sw=4 expandtab: */