comparison src/audio/mint/SDL_mintaudio_xbios.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
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 <unistd.h> 33 #include <unistd.h>
34 #include <support.h>
34 35
35 /* Mint includes */ 36 /* Mint includes */
36 #include <mint/osbind.h> 37 #include <mint/osbind.h>
37 #include <mint/falcon.h> 38 #include <mint/falcon.h>
38 #include <mint/cookie.h> 39 #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 */
178 } 176 }
179 177
180 static void Mint_CloseAudio(_THIS) 178 static void Mint_CloseAudio(_THIS)
181 { 179 {
182 /* Stop replay */ 180 /* Stop replay */
181 SDL_MintAudio_WaitThread();
183 Buffoper(0); 182 Buffoper(0);
184 183
185 /* Uninstall interrupt */ 184 if (!SDL_MintAudio_mint_present) {
186 Jdisint(MFP_DMASOUND); 185 /* Uninstall interrupt */
186 Jdisint(MFP_DMASOUND);
187 }
187 188
188 /* Wait if currently playing sound */ 189 /* Wait if currently playing sound */
189 while (SDL_MintAudio_mutex != 0) { 190 while (SDL_MintAudio_mutex != 0) {
190 } 191 }
191 192
389 { 390 {
390 int channels_mode, dmaclock, prediv; 391 int channels_mode, dmaclock, prediv;
391 void *buffer; 392 void *buffer;
392 393
393 /* Stop currently playing sound */ 394 /* Stop currently playing sound */
395 SDL_MintAudio_quit_thread = SDL_FALSE;
396 SDL_MintAudio_thread_finished = SDL_TRUE;
397 SDL_MintAudio_WaitThread();
394 Buffoper(0); 398 Buffoper(0);
395 399
396 /* Set replay tracks */ 400 /* Set replay tracks */
397 Settracks(0,0); 401 Settracks(0,0);
398 Setmontracks(0); 402 Setmontracks(0);
426 buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf]; 430 buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf];
427 if (Setbuffer(0, buffer, buffer + spec->size)<0) { 431 if (Setbuffer(0, buffer, buffer + spec->size)<0) {
428 DEBUG_PRINT((DEBUG_NAME "Setbuffer() failed\n")); 432 DEBUG_PRINT((DEBUG_NAME "Setbuffer() failed\n"));
429 } 433 }
430 434
431 /* Install interrupt */ 435 if (SDL_MintAudio_mint_present) {
432 Jdisint(MFP_DMASOUND); 436 SDL_MintAudio_thread_pid = tfork(SDL_MintAudio_Thread, 0);
433 Xbtimer(XB_TIMERA, 8, 1, SDL_MintAudio_XbiosInterrupt); 437 } else {
434 Jenabint(MFP_DMASOUND); 438 /* Install interrupt */
435 439 Jdisint(MFP_DMASOUND);
436 if (Setinterrupt(SI_TIMERA, SI_PLAY)<0) { 440 Xbtimer(XB_TIMERA, 8, 1, SDL_MintAudio_XbiosInterrupt);
437 DEBUG_PRINT((DEBUG_NAME "Setinterrupt() failed\n")); 441 Jenabint(MFP_DMASOUND);
442
443 if (Setinterrupt(SI_TIMERA, SI_PLAY)<0) {
444 DEBUG_PRINT((DEBUG_NAME "Setinterrupt() failed\n"));
445 }
438 } 446 }
439 447
440 /* Go */ 448 /* Go */
441 Buffoper(SB_PLA_ENA|SB_PLA_RPT); 449 Buffoper(SB_PLA_ENA|SB_PLA_RPT);
442 DEBUG_PRINT((DEBUG_NAME "hardware initialized\n")); 450 DEBUG_PRINT((DEBUG_NAME "hardware initialized\n"));
477 DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n", SDL_MintAudio_audiobuf[1])); 485 DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n", SDL_MintAudio_audiobuf[1]));
478 486
479 /* Setup audio hardware */ 487 /* Setup audio hardware */
480 Mint_InitAudio(this, spec); 488 Mint_InitAudio(this, spec);
481 489
482 return(1); /* We don't use threaded audio */ 490 return(1); /* We don't use SDL threaded audio */
483 } 491 }