Mercurial > sdl-ios-xcode
comparison src/audio/mint/SDL_mintaudio_mcsn.c @ 1111:12c49532be00
Use MiNT thread to update DMA pointers instead of unusable MFP interrupt
author | Patrice Mandin <patmandin@gmail.com> |
---|---|
date | Wed, 10 Aug 2005 13:29:49 +0000 |
parents | 856f76a099c7 |
children | 3692456e7b0f |
comparison
equal
deleted
inserted
replaced
1110:b6fdf299a2f3 | 1111:12c49532be00 |
---|---|
28 */ | 28 */ |
29 | 29 |
30 #include <stdlib.h> | 30 #include <stdlib.h> |
31 #include <stdio.h> | 31 #include <stdio.h> |
32 #include <string.h> | 32 #include <string.h> |
33 #include <support.h> | |
33 | 34 |
34 /* Mint includes */ | 35 /* Mint includes */ |
35 #include <mint/osbind.h> | 36 #include <mint/osbind.h> |
36 #include <mint/falcon.h> | 37 #include <mint/falcon.h> |
37 #include <mint/cookie.h> | 38 #include <mint/cookie.h> |
83 static int Audio_Available(void) | 84 static int Audio_Available(void) |
84 { | 85 { |
85 unsigned long dummy; | 86 unsigned long dummy; |
86 const char *envr = getenv("SDL_AUDIODRIVER"); | 87 const char *envr = getenv("SDL_AUDIODRIVER"); |
87 | 88 |
88 /* We can't use XBIOS in interrupt under MiNT */ | 89 SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND); |
89 if (Getcookie(C_MiNT, &dummy) == C_FOUND) { | 90 |
90 return(0); | 91 /* We can't use XBIOS in interrupt with Magic, don't know about thread */ |
91 } | |
92 | |
93 /* nor with Magic */ | |
94 if (Getcookie(C_MagX, &dummy) == C_FOUND) { | 92 if (Getcookie(C_MagX, &dummy) == C_FOUND) { |
95 return(0); | 93 return(0); |
96 } | 94 } |
97 | 95 |
98 /* Check if user asked a different audio driver */ | 96 /* Check if user asked a different audio driver */ |
195 } | 193 } |
196 | 194 |
197 static void Mint_CloseAudio(_THIS) | 195 static void Mint_CloseAudio(_THIS) |
198 { | 196 { |
199 /* Stop replay */ | 197 /* Stop replay */ |
198 SDL_MintAudio_WaitThread(); | |
200 Buffoper(0); | 199 Buffoper(0); |
201 | 200 |
202 /* Uninstall interrupt */ | 201 if (!SDL_MintAudio_mint_present) { |
203 Jdisint(MFP_DMASOUND); | 202 /* Uninstall interrupt */ |
203 Jdisint(MFP_DMASOUND); | |
204 } | |
204 | 205 |
205 /* Wait if currently playing sound */ | 206 /* Wait if currently playing sound */ |
206 while (SDL_MintAudio_mutex != 0) { | 207 while (SDL_MintAudio_mutex != 0) { |
207 } | 208 } |
208 | 209 |
296 { | 297 { |
297 int channels_mode, prediv, dmaclock; | 298 int channels_mode, prediv, dmaclock; |
298 void *buffer; | 299 void *buffer; |
299 | 300 |
300 /* Stop currently playing sound */ | 301 /* Stop currently playing sound */ |
302 SDL_MintAudio_quit_thread = SDL_FALSE; | |
303 SDL_MintAudio_thread_finished = SDL_TRUE; | |
304 SDL_MintAudio_WaitThread(); | |
301 Buffoper(0); | 305 Buffoper(0); |
302 | 306 |
303 /* Set replay tracks */ | 307 /* Set replay tracks */ |
304 Settracks(0,0); | 308 Settracks(0,0); |
305 Setmontracks(0); | 309 Setmontracks(0); |
337 buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf]; | 341 buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf]; |
338 if (Setbuffer(0, buffer, buffer + spec->size)<0) { | 342 if (Setbuffer(0, buffer, buffer + spec->size)<0) { |
339 DEBUG_PRINT((DEBUG_NAME "Setbuffer() failed\n")); | 343 DEBUG_PRINT((DEBUG_NAME "Setbuffer() failed\n")); |
340 } | 344 } |
341 | 345 |
342 /* Install interrupt */ | 346 if (SDL_MintAudio_mint_present) { |
343 Jdisint(MFP_DMASOUND); | 347 SDL_MintAudio_thread_pid = tfork(SDL_MintAudio_Thread, 0); |
344 Xbtimer(XB_TIMERA, 8, 1, SDL_MintAudio_XbiosInterrupt); | 348 } else { |
345 Jenabint(MFP_DMASOUND); | 349 /* Install interrupt */ |
346 | 350 Jdisint(MFP_DMASOUND); |
347 if (Setinterrupt(SI_TIMERA, SI_PLAY)<0) { | 351 Xbtimer(XB_TIMERA, 8, 1, SDL_MintAudio_XbiosInterrupt); |
348 DEBUG_PRINT((DEBUG_NAME "Setinterrupt() failed\n")); | 352 Jenabint(MFP_DMASOUND); |
353 | |
354 if (Setinterrupt(SI_TIMERA, SI_PLAY)<0) { | |
355 DEBUG_PRINT((DEBUG_NAME "Setinterrupt() failed\n")); | |
356 } | |
349 } | 357 } |
350 | 358 |
351 /* Go */ | 359 /* Go */ |
352 Buffoper(SB_PLA_ENA|SB_PLA_RPT); | 360 Buffoper(SB_PLA_ENA|SB_PLA_RPT); |
353 DEBUG_PRINT((DEBUG_NAME "hardware initialized\n")); | 361 DEBUG_PRINT((DEBUG_NAME "hardware initialized\n")); |
388 DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n", SDL_MintAudio_audiobuf[1])); | 396 DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n", SDL_MintAudio_audiobuf[1])); |
389 | 397 |
390 /* Setup audio hardware */ | 398 /* Setup audio hardware */ |
391 Mint_InitAudio(this, spec); | 399 Mint_InitAudio(this, spec); |
392 | 400 |
393 return(1); /* We don't use threaded audio */ | 401 return(1); /* We don't use SDL threaded audio */ |
394 } | 402 } |