Mercurial > sdl-ios-xcode
comparison src/audio/mint/SDL_mintaudio_mcsn.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 |
---|---|
63 | 63 |
64 static unsigned long cookie_snd = 0; | 64 static unsigned long cookie_snd = 0; |
65 static unsigned long cookie_mch = 0; | 65 static unsigned long cookie_mch = 0; |
66 static cookie_mcsn_t *cookie_mcsn = NULL; | 66 static cookie_mcsn_t *cookie_mcsn = NULL; |
67 | 67 |
68 static int | |
69 MINTMCSN_Available(void) | |
70 { | |
71 unsigned long dummy = 0; | |
72 | |
73 SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND); | |
74 | |
75 /* We can't use XBIOS in interrupt with Magic, don't know about thread */ | |
76 if (Getcookie(C_MagX, &dummy) == C_FOUND) { | |
77 return (0); | |
78 } | |
79 | |
80 /* Cookie _MCH present ? if not, assume ST machine */ | |
81 if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) { | |
82 cookie_mch = MCH_ST; | |
83 } | |
84 | |
85 /* Cookie _SND present ? if not, assume ST machine */ | |
86 if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) { | |
87 cookie_snd = SND_PSG; | |
88 } | |
89 | |
90 /* Check if we have 16 bits audio */ | |
91 if ((cookie_snd & SND_16BIT) == 0) { | |
92 DEBUG_PRINT((DEBUG_NAME "no 16 bits sound\n")); | |
93 return (0); | |
94 } | |
95 | |
96 /* Cookie MCSN present ? */ | |
97 if (Getcookie(C_McSn, (long *) &cookie_mcsn) != C_FOUND) { | |
98 DEBUG_PRINT((DEBUG_NAME "no MCSN audio\n")); | |
99 return (0); | |
100 } | |
101 | |
102 /* Check if interrupt at end of replay */ | |
103 if (cookie_mcsn->pint == 0) { | |
104 DEBUG_PRINT((DEBUG_NAME "no interrupt at end of replay\n")); | |
105 return (0); | |
106 } | |
107 | |
108 /* Check if audio is lockable */ | |
109 if (Locksnd() != 1) { | |
110 DEBUG_PRINT((DEBUG_NAME "audio locked by other application\n")); | |
111 return (0); | |
112 } | |
113 | |
114 Unlocksnd(); | |
115 | |
116 DEBUG_PRINT((DEBUG_NAME "MCSN audio available!\n")); | |
117 return (1); | |
118 } | |
119 | |
120 static void | 68 static void |
121 MINTMCSN_LockDevice(_THIS) | 69 MINTMCSN_LockDevice(_THIS) |
122 { | 70 { |
123 /* Stop replay */ | 71 /* Stop replay */ |
124 Buffoper(0); | 72 Buffoper(0); |
379 } | 327 } |
380 | 328 |
381 static int | 329 static int |
382 MINTMCSN_Init(SDL_AudioDriverImpl *impl) | 330 MINTMCSN_Init(SDL_AudioDriverImpl *impl) |
383 { | 331 { |
332 unsigned long dummy = 0; | |
333 | |
334 SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND); | |
335 | |
336 /* We can't use XBIOS in interrupt with Magic, don't know about thread */ | |
337 if (Getcookie(C_MagX, &dummy) == C_FOUND) { | |
338 return 0; | |
339 } | |
340 | |
341 /* Cookie _MCH present ? if not, assume ST machine */ | |
342 if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) { | |
343 cookie_mch = MCH_ST; | |
344 } | |
345 | |
346 /* Cookie _SND present ? if not, assume ST machine */ | |
347 if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) { | |
348 cookie_snd = SND_PSG; | |
349 } | |
350 | |
351 /* Check if we have 16 bits audio */ | |
352 if ((cookie_snd & SND_16BIT) == 0) { | |
353 SDL_SetError(DEBUG_NAME "no 16-bit sound"); | |
354 return 0; | |
355 } | |
356 | |
357 /* Cookie MCSN present ? */ | |
358 if (Getcookie(C_McSn, (long *) &cookie_mcsn) != C_FOUND) { | |
359 SDL_SetError(DEBUG_NAME "no MCSN audio"); | |
360 return 0; | |
361 } | |
362 | |
363 /* Check if interrupt at end of replay */ | |
364 if (cookie_mcsn->pint == 0) { | |
365 SDL_SetError(DEBUG_NAME "no interrupt at end of replay"); | |
366 return 0; | |
367 } | |
368 | |
369 /* Check if audio is lockable */ | |
370 if (Locksnd() != 1) { | |
371 SDL_SetError(DEBUG_NAME "audio locked by other application"); | |
372 return 0; | |
373 } | |
374 | |
375 Unlocksnd(); | |
376 | |
377 DEBUG_PRINT((DEBUG_NAME "MCSN audio available!\n")); | |
378 | |
384 /* Set the function pointers */ | 379 /* Set the function pointers */ |
385 impl->OpenDevice = MINTMCSN_OpenDevice; | 380 impl->OpenDevice = MINTMCSN_OpenDevice; |
386 impl->CloseDevice = MINTMCSN_CloseDevice; | 381 impl->CloseDevice = MINTMCSN_CloseDevice; |
387 impl->LockAudio = MINTMCSN_LockAudio; | 382 impl->LockAudio = MINTMCSN_LockAudio; |
388 impl->UnlockAudio = MINTMCSN_UnlockAudio; | 383 impl->UnlockAudio = MINTMCSN_UnlockAudio; |
392 | 387 |
393 return 1; | 388 return 1; |
394 } | 389 } |
395 | 390 |
396 AudioBootStrap MINTAUDIO_MCSN_bootstrap = { | 391 AudioBootStrap MINTAUDIO_MCSN_bootstrap = { |
397 MINT_AUDIO_DRIVER_NAME, "MiNT MCSN audio driver", | 392 MINT_AUDIO_DRIVER_NAME, "MiNT MCSN audio driver", MINTMCSN_Init, 0 |
398 MINTMCSN_Available, MINTMCSN_Init, 0 | |
399 }; | 393 }; |
400 | 394 |
401 /* vi: set ts=4 sw=4 expandtab: */ | 395 /* vi: set ts=4 sw=4 expandtab: */ |