diff 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
line wrap: on
line diff
--- a/src/audio/mint/SDL_mintaudio_xbios.c	Tue Aug 09 07:28:35 2005 +0000
+++ b/src/audio/mint/SDL_mintaudio_xbios.c	Wed Aug 10 13:29:49 2005 +0000
@@ -31,6 +31,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
+#include <support.h>
 
 /* Mint includes */
 #include <mint/osbind.h>
@@ -85,12 +86,9 @@
 	unsigned long dummy;
 	const char *envr = getenv("SDL_AUDIODRIVER");
 
-	/* We can't use XBIOS in interrupt under MiNT */
-	if (Getcookie(C_MiNT, &dummy) == C_FOUND) {
-		return(0);
-	}
+	SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND);
 
-	/* nor with Magic */
+	/* We can't use XBIOS in interrupt with Magic, don't know about thread */
 	if (Getcookie(C_MagX, &dummy) == C_FOUND) {
 		return(0);
 	}
@@ -180,10 +178,13 @@
 static void Mint_CloseAudio(_THIS)
 {
 	/* Stop replay */
+	SDL_MintAudio_WaitThread();
 	Buffoper(0);
 
-	/* Uninstall interrupt */
-	Jdisint(MFP_DMASOUND);
+	if (!SDL_MintAudio_mint_present) {
+		/* Uninstall interrupt */
+		Jdisint(MFP_DMASOUND);
+	}
 
 	/* Wait if currently playing sound */
 	while (SDL_MintAudio_mutex != 0) {
@@ -391,6 +392,9 @@
 	void *buffer;
 
 	/* Stop currently playing sound */
+	SDL_MintAudio_quit_thread = SDL_FALSE;
+	SDL_MintAudio_thread_finished = SDL_TRUE;
+	SDL_MintAudio_WaitThread();
 	Buffoper(0);
 
 	/* Set replay tracks */
@@ -428,13 +432,17 @@
 		DEBUG_PRINT((DEBUG_NAME "Setbuffer() failed\n"));
 	}
 	
-	/* Install interrupt */
-	Jdisint(MFP_DMASOUND);
-	Xbtimer(XB_TIMERA, 8, 1, SDL_MintAudio_XbiosInterrupt);
-	Jenabint(MFP_DMASOUND);
+	if (SDL_MintAudio_mint_present) {
+		SDL_MintAudio_thread_pid = tfork(SDL_MintAudio_Thread, 0);
+	} else {
+		/* Install interrupt */
+		Jdisint(MFP_DMASOUND);
+		Xbtimer(XB_TIMERA, 8, 1, SDL_MintAudio_XbiosInterrupt);
+		Jenabint(MFP_DMASOUND);
 
-	if (Setinterrupt(SI_TIMERA, SI_PLAY)<0) {
-		DEBUG_PRINT((DEBUG_NAME "Setinterrupt() failed\n"));
+		if (Setinterrupt(SI_TIMERA, SI_PLAY)<0) {
+			DEBUG_PRINT((DEBUG_NAME "Setinterrupt() failed\n"));
+		}
 	}
 
 	/* Go */
@@ -479,5 +487,5 @@
 	/* Setup audio hardware */
 	Mint_InitAudio(this, spec);
 
-    return(1);	/* We don't use threaded audio */
+    return(1);	/* We don't use SDL threaded audio */
 }