SDL-1.2: atari:audio: replace SDL's routines with uSound

From 1af51022b4e951bf10b8c9429ba5888e70c2782f Mon Sep 17 00:00:00 2001
From: Miro Kropacek <[EMAIL REDACTED]>
Date: Thu, 25 Jun 2026 15:37:36 +1000
Subject: [PATCH] atari:audio: replace SDL's routines with uSound

There's no point in offering STFA, McSn etc as separate backends: if the
cookie is present, uSound uses it. There's no use case for having STFA
and MacSound installed together.

This not only makes source code less messy but also more correct. Should
fix all audio issues on the FireBee.
---
 README.MiNT                          |  20 +-
 configure                            |  15 +-
 configure.ac                         |   9 +-
 include/SDL_config.h.in              |   1 +
 src/audio/SDL_audio.c                |   5 +-
 src/audio/SDL_sysaudio.h             |   5 +-
 src/audio/mint/SDL_mintaudio.c       |  68 +----
 src/audio/mint/SDL_mintaudio.h       |  14 -
 src/audio/mint/SDL_mintaudio_dma8.c  |   5 +-
 src/audio/mint/SDL_mintaudio_gsxb.c  | 402 ---------------------------
 src/audio/mint/SDL_mintaudio_gsxb.h  |  90 ------
 src/audio/mint/SDL_mintaudio_it.S    |  35 ---
 src/audio/mint/SDL_mintaudio_mcsn.c  | 383 -------------------------
 src/audio/mint/SDL_mintaudio_mcsn.h  |  59 ----
 src/audio/mint/SDL_mintaudio_stfa.c  | 279 -------------------
 src/audio/mint/SDL_mintaudio_stfa.h  |  97 -------
 src/audio/mint/SDL_mintaudio_xbios.c | 366 ++++++------------------
 17 files changed, 117 insertions(+), 1736 deletions(-)
 delete mode 100644 src/audio/mint/SDL_mintaudio_gsxb.c
 delete mode 100644 src/audio/mint/SDL_mintaudio_gsxb.h
 delete mode 100644 src/audio/mint/SDL_mintaudio_mcsn.c
 delete mode 100644 src/audio/mint/SDL_mintaudio_mcsn.h
 delete mode 100644 src/audio/mint/SDL_mintaudio_stfa.c
 delete mode 100644 src/audio/mint/SDL_mintaudio_stfa.h

diff --git a/README.MiNT b/README.MiNT
index daf3c4004..089999526 100644
--- a/README.MiNT
+++ b/README.MiNT
@@ -54,23 +54,12 @@ Mouse (XBIOS, GEM(2), Ikbd)
 Video (XBIOS (Fullscreen), GEM (Windowed and Fullscreen))
 Timer (Timer C interrupt, GNU pth library)
 Joysticks (XBIOS, Ikbd) and joypads (Hardware)
-Audio (Hardware, XBIOS, GSXB, MCSN, STFA, /dev/audio if threads enabled)
+Audio (XBIOS, Hardware)
 Threads (Multitasking OS only via GNU pth library)
 Shared object loader (using LDG library from http://ldg.atari.org/)
 Audio CD (MetaDOS)
 OpenGL (using Mesa offscreen rendering driver)
 
-Audio   O/S     Misc
-dma8    All     Uses MFP Timer A interrupt
-xbios	TOS     Uses MFP Timer A interrupt
-xbios   MiNT    Uses MFP Timer A interrupt
-xbios   Magic   Uses MFP Timer A interrupt
-stfa    All     Uses MFP interrupt
-mcsn	TOS     Uses MFP Timer A interrupt
-mcsn    MiNT    Uses MiNT thread
-mcsn    Magic   Disabled
-gsxb    All     Uses GSXB callback
-
 Joypad driver always uses hardware access.
 OpenGL driver always uses OSMesa.
 
@@ -94,11 +83,8 @@ SDL_VIDEO_ALIGNED_WINDOWS:
 	(e.g. for speed reasons)
 
 SDL_AUDIODRIVER:
-	Set to 'mint_gsxb' to force Atari GSXB audio driver
-	Set to 'mint_mcsn' to force Atari MCSN audio driver
-	Set to 'mint_stfa' to force Atari STFA audio driver
-	Set to 'mint_xbios' to force Atari Xbios audio driver
-	Set to 'mint_dma8' to force Atari 8 bits DMA audio driver
+	Set to 'xbios' to force Atari Xbios audio driver
+	Set to 'dma8' to force Atari DMA audio driver
 	Set to 'audio' to force Sun /dev/audio audio driver
 	Set to 'disk' to force disk-writing audio driver
 
diff --git a/configure b/configure
index e540d665d..991ec623c 100755
--- a/configure
+++ b/configure
@@ -17837,9 +17837,22 @@ fi
             mintaudio=yes
             $as_echo "#define SDL_AUDIO_DRIVER_MINT 1" >>confdefs.h
 
-            SOURCES="$SOURCES $srcdir/src/audio/mint/*.c"
+            SOURCES="$SOURCES $srcdir/src/audio/mint/SDL_mintaudio.c"
+            SOURCES="$SOURCES $srcdir/src/audio/mint/SDL_mintaudio_dma8.c"
             SOURCES="$SOURCES $srcdir/src/audio/mint/*.S"
             have_audio=yes
+
+            ac_fn_c_check_header_mongrel "$LINENO" "usound.h" "ac_cv_header_usound_h" "$ac_includes_default"
+if test "x$ac_cv_header_usound_h" = xyes; then :
+  have_usound_hdr=yes
+fi
+
+
+            if test x$have_usound_hdr = xyes; then
+                $as_echo "#define SDL_AUDIO_DRIVER_MINT_XBIOS 1" >>confdefs.h
+
+                SOURCES="$SOURCES $srcdir/src/audio/mint/SDL_mintaudio_xbios.c"
+            fi
         fi
     fi
 }
diff --git a/configure.ac b/configure.ac
index 059761ec4..ddbd40711 100644
--- a/configure.ac
+++ b/configure.ac
@@ -689,9 +689,16 @@ CheckAtariAudio()
         if test x$have_mint_falcon_hdr = xyes; then
             mintaudio=yes
             AC_DEFINE(SDL_AUDIO_DRIVER_MINT)
-            SOURCES="$SOURCES $srcdir/src/audio/mint/*.c"
+            SOURCES="$SOURCES $srcdir/src/audio/mint/SDL_mintaudio.c"
+            SOURCES="$SOURCES $srcdir/src/audio/mint/SDL_mintaudio_dma8.c"
             SOURCES="$SOURCES $srcdir/src/audio/mint/*.S"
             have_audio=yes
+
+            AC_CHECK_HEADER(usound.h, have_usound_hdr=yes)
+            if test x$have_usound_hdr = xyes; then
+                AC_DEFINE(SDL_AUDIO_DRIVER_MINT_XBIOS)
+                SOURCES="$SOURCES $srcdir/src/audio/mint/SDL_mintaudio_xbios.c"
+            fi
         fi
     fi
 }
diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in
index df307c05d..c118912cd 100644
--- a/include/SDL_config.h.in
+++ b/include/SDL_config.h.in
@@ -179,6 +179,7 @@
 #undef SDL_AUDIO_DRIVER_ESD
 #undef SDL_AUDIO_DRIVER_ESD_DYNAMIC
 #undef SDL_AUDIO_DRIVER_MINT
+#undef SDL_AUDIO_DRIVER_MINT_XBIOS
 #undef SDL_AUDIO_DRIVER_MMEAUDIO
 #undef SDL_AUDIO_DRIVER_NAS
 #undef SDL_AUDIO_DRIVER_NAS_DYNAMIC
diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index 5b6138449..3bc41a7e1 100644
--- a/src/audio/SDL_audio.c
+++ b/src/audio/SDL_audio.c
@@ -83,10 +83,9 @@ static AudioBootStrap *bootstrap[] = {
 	&SNDMGR_bootstrap,
 #endif
 #if SDL_AUDIO_DRIVER_MINT
-	&MINTAUDIO_GSXB_bootstrap,
-	&MINTAUDIO_MCSN_bootstrap,
-	&MINTAUDIO_STFA_bootstrap,
+#if SDL_AUDIO_DRIVER_MINT_XBIOS
 	&MINTAUDIO_XBIOS_bootstrap,
+#endif
 	&MINTAUDIO_DMA8_bootstrap,
 #endif
 #if SDL_AUDIO_DRIVER_DISK
diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h
index 3dcecf604..cb7b931ce 100644
--- a/src/audio/SDL_sysaudio.h
+++ b/src/audio/SDL_sysaudio.h
@@ -155,10 +155,9 @@ extern AudioBootStrap COREAUDIO_bootstrap;
 extern AudioBootStrap SNDMGR_bootstrap;
 #endif
 #if SDL_AUDIO_DRIVER_MINT
-extern AudioBootStrap MINTAUDIO_GSXB_bootstrap;
-extern AudioBootStrap MINTAUDIO_MCSN_bootstrap;
-extern AudioBootStrap MINTAUDIO_STFA_bootstrap;
+#if SDL_AUDIO_DRIVER_MINT_XBIOS
 extern AudioBootStrap MINTAUDIO_XBIOS_bootstrap;
+#endif
 extern AudioBootStrap MINTAUDIO_DMA8_bootstrap;
 #endif
 #if SDL_AUDIO_DRIVER_DISK
diff --git a/src/audio/mint/SDL_mintaudio.c b/src/audio/mint/SDL_mintaudio.c
index 61ab26763..cb974ad8f 100644
--- a/src/audio/mint/SDL_mintaudio.c
+++ b/src/audio/mint/SDL_mintaudio.c
@@ -27,11 +27,8 @@
 	Patrice Mandin
 */
 
-#include <unistd.h>
-
 #include <mint/osbind.h>
 #include <mint/falcon.h>
-#include <mint/mintbind.h>
 #include <mint/cookie.h>
 
 #include "SDL_audio.h"
@@ -54,12 +51,6 @@ static int SDL_MintAudio_numbuf;	/* Buffer to play */
 
 static void SDL_MintAudio_Callback(void);
 
-/* MiNT thread variables */
-SDL_bool SDL_MintAudio_mint_present;
-SDL_bool SDL_MintAudio_quit_thread;
-SDL_bool SDL_MintAudio_thread_finished;
-long SDL_MintAudio_thread_pid;
-
 /* Debug print info */
 #define DEBUG_NAME "audio:mint: "
 #if 0
@@ -134,6 +125,11 @@ void SDL_AtariMint_UpdateAudio(void)
 {
 	SDL_AudioDevice *this = SDL_MintAudio_device;
 
+	/* Called from SDL_AtariMint_BackgroundTasks() */
+	if (this == NULL) {
+		return;
+	}
+
 	++SDL_MintAudio_num_upd;
 
 	/* No interrupt triggered? still playing current buffer */
@@ -265,57 +261,3 @@ int SDL_MintAudio_SearchFrequency(_THIS, int desired_freq)
 	/* Not in the array, give the latest */
 	return MINTAUDIO_freqcount-1;
 }
-
-/* The thread function, used under MiNT with xbios */
-int SDL_MintAudio_Thread(long param)
-{
-	SndBufPtr	pointers;
-	SDL_bool	buffers_filled[2] = {SDL_FALSE, SDL_FALSE};
-	SDL_AudioDevice *this = SDL_MintAudio_device;
-
-	SDL_MintAudio_thread_finished = SDL_FALSE;
-	while (!SDL_MintAudio_quit_thread) {
-		if (Buffptr(&pointers)!=0)
-			continue;
-
-		if (( (unsigned long)pointers.play>=(unsigned long)MINTAUDIO_audiobuf[0])
-			&& ( (unsigned long)pointers.play<=(unsigned long)MINTAUDIO_audiobuf[1])) 
-		{
-			/* DMA is reading buffer #0, setup buffer #1 if not already done */
-			if (!buffers_filled[1]) {
-				SDL_MintAudio_numbuf = 1;
-				SDL_MintAudio_Callback();
-				Setbuffer(0, MINTAUDIO_audiobuf[1], MINTAUDIO_audiobuf[1] + MINTAUDIO_audiosize);
-				buffers_filled[1]=SDL_TRUE;
-				buffers_filled[0]=SDL_FALSE;
-			}
-		} else {
-			/* DMA is reading buffer #1, setup buffer #0 if not already done */
-			if (!buffers_filled[0]) {
-				SDL_MintAudio_numbuf = 0;
-				SDL_MintAudio_Callback();
-				Setbuffer(0, MINTAUDIO_audiobuf[0], MINTAUDIO_audiobuf[0] + MINTAUDIO_audiosize);
-				buffers_filled[0]=SDL_TRUE;
-				buffers_filled[1]=SDL_FALSE;
-			}
-		}
-
-		usleep(100);
-	}
-	SDL_MintAudio_thread_finished = SDL_TRUE;
-	return 0;
-}
-
-void SDL_MintAudio_WaitThread(void)
-{
-	if (!SDL_MintAudio_mint_present)
-		return;
-
-	if (SDL_MintAudio_thread_finished)
-		return;
-
-	SDL_MintAudio_quit_thread = SDL_TRUE;
-	while (!SDL_MintAudio_thread_finished) {
-		Syield();
-	}
-}
diff --git a/src/audio/mint/SDL_mintaudio.h b/src/audio/mint/SDL_mintaudio.h
index 50a2d4abc..57129bc88 100644
--- a/src/audio/mint/SDL_mintaudio.h
+++ b/src/audio/mint/SDL_mintaudio.h
@@ -31,7 +31,6 @@
 #define _SDL_mintaudio_h
 
 #include "../SDL_sysaudio.h"
-#include "SDL_mintaudio_stfa.h"
 
 /* Hidden "this" pointer for the audio functions */
 #define _THIS	SDL_AudioDevice *this
@@ -96,12 +95,6 @@ enum {
 /* Variables */
 extern SDL_AudioDevice *SDL_MintAudio_device;
 
-/* MiNT thread variables */
-extern SDL_bool	SDL_MintAudio_mint_present;
-extern SDL_bool SDL_MintAudio_quit_thread;
-extern SDL_bool SDL_MintAudio_thread_finished;
-extern long SDL_MintAudio_thread_pid;
-
 /* Functions */
 void SDL_AtariMint_UpdateAudio(void);
 
@@ -111,14 +104,9 @@ void SDL_MintAudio_AddFrequency(_THIS, Uint32 frequency, Uint32 clock,
 	Uint32 prediv, int gpio_bits);
 int SDL_MintAudio_SearchFrequency(_THIS, int desired_freq);
 
-/* MiNT thread functions */
-int SDL_MintAudio_Thread(long param);
-void SDL_MintAudio_WaitThread(void);
-
 /*--- SDL_mintaudio_it.S stuff ---*/
 
 /* Variables */
-extern volatile unsigned long SDL_MintAudio_clocktics;
 extern volatile unsigned long SDL_MintAudio_num_its;
 
 extern volatile void *SDL_MintAudio_itbuffer;
@@ -126,9 +114,7 @@ extern volatile unsigned long SDL_MintAudio_itbuflen;
 extern volatile unsigned long SDL_MintAudio_itsilence;
 
 /* Functions */
-void SDL_MintAudio_XbiosInterruptMeasureClock(void);
 void SDL_MintAudio_XbiosInterrupt(void);
 void SDL_MintAudio_Dma8Interrupt(void);
-void SDL_MintAudio_StfaInterrupt(void);
 
 #endif /* _SDL_mintaudio_h */
diff --git a/src/audio/mint/SDL_mintaudio_dma8.c b/src/audio/mint/SDL_mintaudio_dma8.c
index 38f430536..11666218d 100644
--- a/src/audio/mint/SDL_mintaudio_dma8.c
+++ b/src/audio/mint/SDL_mintaudio_dma8.c
@@ -44,7 +44,7 @@
 
 /*--- Defines ---*/
 
-#define MINT_AUDIO_DRIVER_NAME "mint_dma8"
+#define MINT_AUDIO_DRIVER_NAME "dma8"
 
 /* Debug print info */
 #define DEBUG_NAME "audio:dma8: "
@@ -183,6 +183,9 @@ static void Mint_CloseAudio(_THIS)
 	DEBUG_PRINT((DEBUG_NAME "closeaudio: interrupt disabled\n"));
 
 	SDL_MintAudio_FreeBuffers();
+
+	SDL_MintAudio_num_its = 0;
+	SDL_MintAudio_device = NULL;
 }
 
 static int Mint_CheckAudio(_THIS, SDL_AudioSpec *spec)
diff --git a/src/audio/mint/SDL_mintaudio_gsxb.c b/src/audio/mint/SDL_mintaudio_gsxb.c
deleted file mode 100644
index 4b540030b..000000000
--- a/src/audio/mint/SDL_mintaudio_gsxb.c
+++ /dev/null
@@ -1,402 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2012 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License as published by the Free Software Foundation; either
-    version 2 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Library General Public License for more details.
-
-    You should have received a copy of the GNU Library General Public
-    License along with this library; if not, write to the Free
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/*
-	MiNT audio driver
-	using XBIOS functions (GSXB compatible driver)
-
-	Patrice Mandin
-*/
-
-/* Mint includes */
-#include <mint/osbind.h>
-#include <mint/falcon.h>
-#include <mint/cookie.h>
-
-#include "SDL_audio.h"
-#include "../SDL_audio_c.h"
-#include "../SDL_sysaudio.h"
-
-#include "SDL_mintaudio.h"
-#include "SDL_mintaudio_gsxb.h"
-
-/*--- Defines ---*/
-
-#define MINT_AUDIO_DRIVER_NAME "mint_gsxb"
-
-/* Debug print info */
-#define DEBUG_NAME "audio:gsxb: "
-#if 0
-#define DEBUG_PRINT(what) \
-	{ \
-		printf what; \
-	}
-#else
-#define DEBUG_PRINT(what)
-#endif
-
-/*--- Static variables ---*/
-
-static long cookie_snd, cookie_gsxb;
-
-/*--- Audio driver functions ---*/
-
-static void Mint_CloseAudio(_THIS);
-static int Mint_OpenAudio(_THIS, SDL_AudioSpec *spec);
-static void Mint_LockAudio(_THIS);
-static void Mint_UnlockAudio(_THIS);
-
-/* To check/init hardware audio */
-static int Mint_CheckAudio(_THIS, SDL_AudioSpec *spec);
-static void Mint_InitAudio(_THIS, SDL_AudioSpec *spec);
-static void Mint_SwapBuffers(Uint8 *nextbuf, int nextsize);
-
-/* GSXB callbacks */
-static void Mint_GsxbInterrupt(void);
-static void Mint_GsxbNullInterrupt(void);
-
-/*--- Audio driver bootstrap functions ---*/
-
-static int Audio_Available(void)
-{
-	const char *envr = SDL_getenv("SDL_AUDIODRIVER");
-
-	/* Check if user asked a different audio driver */
-	if ((envr) && (SDL_strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) {
-		DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n"));
-		return(0);
-	}
-
-	/* Cookie _SND present ? if not, assume ST machine */
-	if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
-		cookie_snd = SND_PSG;
-	}
-
-	/* Check if we have 16 bits audio */
-	if ((cookie_snd & SND_16BIT)==0) {
-		DEBUG_PRINT((DEBUG_NAME "no 16 bits sound\n"));
-	    return(0);
-	}
-
-	/* Cookie GSXB present ? */
-	cookie_gsxb = (Getcookie(C_GSXB, &cookie_gsxb) == C_FOUND);
-
-	/* Is it GSXB ? */
-	if (((cookie_snd & SND_GSXB)==0) || (cookie_gsxb==0)) {
-		DEBUG_PRINT((DEBUG_NAME "no GSXB audio\n"));
-		return(0);
-	}
-
-	/* Check if audio is lockable */
-	if (Locksnd()!=1) {
-		DEBUG_PRINT((DEBUG_NAME "audio locked by other application\n"));
-		return(0);
-	}
-
-	Unlocksnd();
-
-	DEBUG_PRINT((DEBUG_NAME "GSXB audio available!\n"));
-	return(1);
-}
-
-static void Audio_DeleteDevice(SDL_AudioDevice *device)
-{
-    SDL_free(device->hidden);
-    SDL_free(device);
-}
-
-static SDL_AudioDevice *Audio_CreateDevice(int devindex)
-{
-	SDL_AudioDevice *this;
-
-	/* Initialize all variables that we clean on shutdown */
-	this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
-    if ( this ) {
-        SDL_memset(this, 0, (sizeof *this));
-        this->hidden = (struct SDL_PrivateAudioData *)
-                SDL_malloc((sizeof *this->hidden));
-    }
-    if ( (this == NULL) || (this->hidden == NULL) ) {
-        SDL_OutOfMemory();
-        if ( this ) {
-            SDL_free(this);
-        }
-        return(0);
-    }
-    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
-
-    /* Set the function pointers */
-    this->OpenAudio   = Mint_OpenAudio;
-    this->CloseAudio  = Mint_CloseAudio;
-    this->LockAudio   = Mint_LockAudio;
-    this->UnlockAudio = Mint_UnlockAudio;
-    this->free        = Audio_DeleteDevice;
-
-    return this;
-}
-
-AudioBootStrap MINTAUDIO_GSXB_bootstrap = {
-	MINT_AUDIO_DRIVER_NAME, "MiNT GSXB audio driver",
-	Audio_Available, Audio_CreateDevice
-};
-
-static void Mint_LockAudio(_THIS)
-{
-	/* Stop replay */
-	Buffoper(0);
-}
-
-static void Mint_UnlockAudio(_THIS)
-{
-	/* Restart replay */
-	Buffoper(SB_PLA_ENA|SB_PLA_RPT);
-}
-
-static void Mint_CloseAudio(_THIS)
-{
-	/* Stop replay */
-	Buffoper(0);
-
-	/* Uninstall interrupt */
-	if (NSetinterrupt(2, SI_NONE, Mint_GsxbNullInterrupt)<0) {
-		DEBUG_PRINT((DEBUG_NAME "NSetinterrupt() failed in close\n"));
-	}
-
-	SDL_MintAudio_FreeBuffers();
-
-	/* Unlock sound system */
-	Unlocksnd();
-}
-
-static int Mint_CheckAudio(_THIS, SDL_AudioSpec *spec)
-{
-	long snd_format = 0;
-	int i, /*resolution,*/ format_signed, format_bigendian;
-    Uint16 test_format = SDL_FirstAudioFormat(spec->format);
-    int valid_datatype = 0;
-
-	/*resolution = spec->format & 0x00ff;*/
-	format_signed = ((spec->format & 0x8000)!=0);
-	format_bigendian = ((spec->format & 0x1000)!=0);
-
-	DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ",spec->format & 0x00ff));
-	DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000)!=0)));
-	DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000)!=0)));
-	DEBUG_PRINT(("channels=%d, ", spec->channels));
-	DEBUG_PRINT(("freq=%d\n", spec->freq));
-
-    if (spec->channels > 2) {
-        spec->channels = 2;  /* no more than stereo! */
-    }
-
-    while ((!valid_datatype) && (test_format)) {
-        /* Check formats available */
-        snd_format = Sndstatus(SND_QUERYFORMATS);
-        spec->format = test_format;
-        /*resolution = spec->format & 0xff;*/
-        format_signed = (spec->format & (1<<15));
-        format_bigendian = (spec->format & (1<<12));
-        switch (test_format) {
-            case AUDIO_U8:
-            case AUDIO_S8:
-                if (snd_format & SND_FORMAT8) {
-                    valid_datatype = 1;
-                    snd_format = Sndstatus(SND_QUERY8BIT);
-                }
-                break;
-
-            case AUDIO_U16LSB:
-            case AUDIO_S16LSB:
-            case AUDIO_U16MSB:
-            case AUDIO_S16MSB:
-                if (snd_format & SND_FORMAT16) {
-                    valid_datatype = 1;
-                    snd_format = Sndstatus(SND_QUERY16BIT);
-                }
-                break;
-
-            default:
-                test_format = SDL_NextAudioFormat();
-                break;
-        }
-    }
-
-    if (!valid_datatype) {
-        SDL_SetError("Unsupported audio format");
-        return (-1);
-    }
-
-	/* Check signed/unsigned format */
-	if (format_signed) {
-		if (snd_format & SND_FORMATSIGNED) {
-			/* Ok */
-		} else if (snd_format & SND_FORMATUNSIGNED) {
-			/* Give unsigned format */
-			spec->format = spec->format & (~0x8000);
-		}
-	} else {
-		if (snd_format & SND_FORMATUNSIGNED) {
-			/* Ok */
-		} else if (snd_format & SND_FORMATSIGNED) {
-			/* Give signed format */
-			spec->format |= 0x8000;
-		}
-	}
-
-	if (format_bigendian) {
-		if (snd_format & SND_FORMATBIGENDIAN) {
-			/* Ok */
-		} else if (snd_format & SND_FORMATLITTLEENDIAN) {
-			/* Give little endian format */
-			spec->format = spec->format & (~0x1000);
-		}
-	} else {
-		if (snd_format & SND_FORMATLITTLEENDIAN) {
-			/* Ok */
-		} else if (snd_format & SND_FORMATBIGENDIAN) {
-			/* Give big endian format */
-			spec->format |= 0x1000;
-		}
-	}
-	
-	/* Calculate and select the closest frequency */
-	MINTAUDIO_freqcount=0;
-	for (i=1;i<4;i++) {
-		SDL_MintAudio_AddFrequency(this,
-			MASTERCLOCK_44K/(MASTERPREDIV_MILAN*(1<<i)), MASTERCLOCK_44K,
-			(1<<i)-1, -1);
-	}
-
-#if 1
-	for (i=0; i<MINTAUDIO_freqcount; i++) {
-		DEBUG_PRINT((DEBUG_NAME "freq %d: %lu Hz, clock %lu, prediv %d\n",
-			i, MINTAUDIO_frequencies[i].frequency, MINTAUDIO_frequencies[i].masterclock,
-			MINTAUDIO_frequencies[i].predivisor
-		));
-	}
-#endif
-
-	MINTAUDIO_numfreq=SDL_MintAudio_SearchFrequency(this, spec->freq);
-	spec->freq=MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency;
-
-	DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ",spec->format & 0x00ff));
-	DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000)!=0)));
-	DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000)!=0)));
-	DEBUG_PRINT(("channels=%d, ", spec->channels));
-	DEBUG_PRINT(("freq=%d\n", spec->freq));
-
-	return 0;
-}
-
-static void Mint_InitAudio(_THIS, SDL_AudioSpec *spec)
-{
-	int channels_mode, prediv;
-
-	/* Stop currently playing sound */
-	Buffoper(0);
-
-	/* Set replay tracks */
-	Settracks(0,0);
-	Setmontracks(0);
-
-	/* Select replay format */
-	switch (spec->format & 0xff) {
-		case 8:
-			if (spec->channels==2) {
-				channels_mode=STEREO8;
-			} else {
-				channels_mode=MONO8;
-			}
-			break;
-		case 16:
-			if (spec->channels==2) {
-				channels_mode=STEREO16;
-			} else {
-				channels_mode=MONO16;
-			}
-			break;
-		default:
-			channels_mode=STEREO16;
-			break;
-	}
-	if (Setmode(channels_mode)<0) {
-		DEBUG_PRINT((DEBUG_NAME "Setmode() failed\n"));
-	}
-
-	prediv = MINTAUDIO_frequencies[MINTAUDIO_numfreq].predivisor;
-	Devconnect(DMAPLAY, DAC, CLKEXT, prediv, 1);
-
-	/* Set buffer */
-	Mint_SwapBuffers(MINTAUDIO_audiobuf[0], MINTAUDIO_audiosize);
-	
-	/* Install interrupt */
-	if (NSetinterrupt(2, SI_PLAY, Mint_GsxbInterrupt)<0) {
-		DEBUG_PRINT((DEBUG_NAME "NSetinterrupt() failed\n"));
-	}
-
-	/* Go */
-	Buffoper(SB_PLA_ENA|SB_PLA_RPT);
-	DEBUG_PRINT((DEBUG_NAME "hardware initialized\n"));
-}
-
-static int Mint_OpenAudio(_THIS, SDL_AudioSpec *spec)
-{
-	/* Lock sound system */
-	if (Locksnd()!=1) {
-   	    SDL_SetError("Mint_OpenAudio: Audio system already in use");
-        return(-1);
-	}
-
-	SDL_MintAudio_device = this;
-
-	/* Check audio capabilities */
-	if (Mint_CheckAudio(this, spec)==-1) {
-		return -1;
-	}
-
-	if (!SDL_MintAudio_InitBuffers(spec)) {
-		return -1;
-	}
-
-	/* Setup audio hardware */
-	MINTAUDIO_swapbuf = Mint_SwapBuffers;
-	Mint_InitAudio(this, spec);
-
-    return(1);	/* We don't use threaded audio */
-}
-
-static void Mint_SwapBuffers(Uint8 *nextbuf, int nextsize)
-{
-	unsigned long buffer = (unsigned long) nextbuf;
-
-	Setbuffer(0, buffer, buffer + nextsize);
-}
-
-static void Mint_GsxbInterrupt(void)
-{
-	++SDL_MintAudio_num_its;
-}
-
-static void Mint_GsxbNullInterrupt(void)
-{
-}
diff --git a/src/audio/mint/SDL_mintaudio_gsxb.h b/src/audio/mint/SDL_mintaudio_gsxb.h
deleted file mode 100644
index 87d1c2a50..000000000
--- a/src/audio/mint/SDL_mintaudio_gsxb.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2012 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/*
- * GSXB audio definitions
- * 
- * Patrice Mandin
- */
-
-#ifndef _SDL_mintaudio_gsxb_h
-#define _SDL_mintaudio_gsxb_h
-
-/* NSoundcmd modes */
-
-#define SETRATE			7	/* Set sample rate */
-#define SET8BITFORMAT	8	/* 8 bits format */
-#define SET16BITFORMAT	9	/* 16 bits format */
-#define SET24BITFORMAT	10	/* 24 bits format */
-#define SET32BITFORMAT	11	/* 32 bits format */
-#define LTATTEN_MASTER	12	/* Attenuation */
-#define RTATTEN_MASTER	13
-#define LTATTEN_MICIN	14
-#define RTATTEN_MICIN	15
-#define LTATTEN_FMGEN	16
-#define RTATTEN_FMGEN	17
-#define LTATTEN_LINEIN	18
-#define RTATTEN_LINEIN	19
-#define LTATTEN_CDIN	20
-#define RTATTEN_CDIN	21
-#define LTATTEN_VIDIN	22
-#define RTATTEN_VIDIN	23
-#define LTATTEN_AUXIN	24
-#define RTATTEN_AUXIN	25
-
-/* Setmode modes */
-
-#define MONO16		3
-#define STEREO24	4
-#define STEREO32	5
-#define MONO24		6
-#define MONO32		7
-
-/* Sndstatus modes */
-
-#define SND_QUERYFORMATS	2
-#define SND_QUERYMIXERS		3
-#define SND_QUERYSOURCES	4
-#define SND_QUERYDUPLEX		5
-#define SND_QUERY8BIT		8
-#define SND_QUERY16BIT		9
-#define SND_QUERY24BIT		10
-#define SND_QUERY32BIT		11
-
-#define SND_FORMAT8		(1<<0)
-#define SND_FORMAT16	(1<<1)
-#define SND_FORMAT24	(1<<2)
-#define SND_FORMAT32	(1<<3)
-
-#define SND_FORMATSIGNED		(1<<0)
-#define SND_FORMATUNSIGNED		(1<<1)
-#define SND_FORMATBIGENDIAN		(1<<2)
-#define SND_FORMATLITTLEENDIAN	(1<<3)
-
-/* Devconnect prescalers */
-
-#define CLK_44K		1
-#define CLK_22K		3
-#define CLK_11K		7
-
-#endif /* _SDL_mintaudio_gsxb_h */
diff --git a/src/audio/mint/SDL_mintaudio_it.S b/src/audio/mint/SDL_mintaudio_it.S
index ee7775f22..9a1dd7dfa 100644
--- a/src/audio/mint/SDL_mintaudio_it.S
+++ b/src/audio/mint/SDL_mintaudio_it.S
@@ -30,12 +30,8 @@
 
 	.text
 
-	.globl	SYM(SDL_MintAudio_XbiosInterruptMeasureClock)
-	.globl	SYM(SDL_MintAudio_clocktics)
-
 	.globl	SYM(SDL_MintAudio_XbiosInterrupt)
 	.globl	SYM(SDL_MintAudio_Dma8Interrupt)
-	.globl	SYM(SDL_MintAudio_StfaInterrupt)
 
 	.globl	SYM(SDL_MintAudio_num_its)
 
@@ -43,37 +39,8 @@
 	.globl	SYM(SDL_MintAudio_itbuflen)
 	.globl	SYM(SDL_MintAudio_itsilence)
 
-/*--- Xbios interrupt vector to measure Falcon external clock ---*/
-
-SYM(SDL_MintAudio_XbiosInterruptMeasureClock):          /* 1 mS */
-
-	/* state DMA sound */
-#if defined(__mcoldfire__)
-	movel	d0,sp@-
-	
-	moveql	#0,d0
-	btst	d0,0xFFFF8901:w
-#else
-	btst	#0,0xFFFF8901:w
-#endif
-	beqs	SDL_MintAudio_EndIntMeasure
-	addql	#1,SYM(SDL_MintAudio_clocktics)
-SDL_MintAudio_EndIntMeasure:
-
-	/* Clear service bit */
-#if defined(__mcoldfire__)
-	moveql	#5,d0
-	bclr	d0,0xFFFFFA0F:w
-
-	movel	sp@+,d0
-#else
-	bclr	#5,0xFFFFFA0F:w
-#endif
-	rte
-
 /*--- Interrupt vectors ---*/
 /*    Xbios, DMA 8 bits: need to set ISR on MFP */
-/*    STFA: do not touch MFP */
 
 SYM(SDL_MintAudio_XbiosInterrupt):
 SYM(SDL_MintAudio_Dma8Interrupt):
@@ -92,7 +59,6 @@ SYM(SDL_MintAudio_Dma8Interrupt):
 	bclr	#5,0xfffffa0f:w
 #endif
 
-SYM(SDL_MintAudio_StfaInterrupt):
 	move.l	SYM(SDL_MintAudio_num_its),d0
 	addql	#1,d0
 	move.l	d0,SYM(SDL_MintAudio_num_its)
@@ -123,7 +89,6 @@ nosilence:
 	.bss
 
 	.even
-	.comm	SYM(SDL_MintAudio_clocktics),4
 	.comm	SYM(SDL_MintAudio_num_its),4
 
 	.comm	SYM(SDL_MintAudio_itbuffer),4	/* Audio DMA buffer */
diff --git a/src/audio/mint/SDL_mintaudio_mcsn.c b/src/audio/mint/SDL_mintaudio_mcsn.c
deleted file mode 100644
index df88fefdc..000000000
--- a/src/audio/mint/SDL_mintaudio_mcsn.c
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2012 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License as published by the Free Software Foundation; either
-    version 2 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Library General Public License for more details.
-
-    You should have received a copy of the GNU Library General Public
-    License along with this library; if not, write to the Free
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/*
-	MiNT audio driver
-	using XBIOS functions (MacSound compatible driver)
-
-	Patrice Mandin
-*/
-
-#include <support.h>
-
-/* Mint includes */
-#include <mint/osbind.h>
-#include <mint/falcon.h>
-#include <mint/cookie.h>
-
-#include "SDL_audio.h"
-#include "../SDL_audio_c.h"
-#include "../SDL_sysaudio.h"
-
-#include "SDL_mintaudio.h"
-#include "SDL_mintaudio_mcsn.h"
-
-/*--- Defines ---*/
-
-#define MINT_AUDIO_DRIVER_NAME "mint_mcsn"
-
-/* Debug print info */
-#define DEBUG_NAME "audio:mcsn: "
-#if 0
-#define DEBUG_PRINT(what) \
-	{ \
-		printf what; \
-	}
-#else
-#define DEBUG_PRINT(what)
-#endif
-
-/*--- Static variables ---*/
-
-static long cookie_snd, cookie_mch;
-static cookie_mcsn_t *cookie_mcsn;
-
-/*--- Audio driver functions ---*/
-
-static void Mint_CloseAudio(_THIS);
-static int Mint_OpenAudio(_THIS, SDL_AudioSpec *spec);
-static void Mint_LockAudio(_THIS);
-static void Mint_UnlockAudio(_THIS);
-
-/* To check/init hardware audio */
-static int Mint_CheckAudio(_THIS, SDL_AudioSpec *spec);
-static void Mint_InitAudio(_THIS, SDL_AudioSpec *spec);
-static void Mint_SwapBuffers(Uint8 *nextbuf, int nextsize);
-
-/*--- Audio driver bootstrap functions ---*/
-
-static int Audio_Available(void)
-{
-	long dummy;
-	const char *envr = SDL_getenv("SDL_AUDIODRIVER");
-
-	SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND);
-
-	/* We can't use XBIOS in interrupt with Magic, don't know about thread */
-	if (Getcookie(C_MagX, &dummy) == C_FOUND) {
-		return(0);
-	}
-
-	/* Check if user asked a different audio driver */
-	if ((envr) && (SDL_strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) {
-		DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n"));
-		return(0);
-	}
-
-	/* Cookie _MCH present ? if not, assume ST machine */
-	if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) {
-		cookie_mch = MCH_ST;
-	}
-
-	/* Cookie _SND present ? if not, assume ST machine */
-	if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
-		cookie_snd = SND_PSG;
-	}
-
-	/* Check if we have 16 bits audio */
-	if ((cookie_snd & SND_16BIT)==0) {
-		DEBUG_PRINT((DEBUG_NAME "no 16 bits sound\n"));
-	    return(0);
-	}
-
-	/* Cookie MCSN present ? */
-	if (Getcookie(C_McSn, &dummy) != C_FOUND) {
-		DEBUG_PRINT((DEBUG_NAME "no MCSN audio\n"));
-		return(0);
-	}
-	cookie_mcsn = (cookie_mcsn_t *) dummy;
-
-	/* Check if interrupt at end of replay */
-	if (cookie_mcsn->pint == 0) {
-		DEBUG_PRINT((DEBUG_NAME "no interrupt at end of replay\n"));
-		return(0);
-	}
-
-	/* Check if audio is lockable */
-	if (Locksnd()!=1) {
-		DEBUG_PRINT((DEBUG_NAME "audio locked by other application\n"));
-		return(0);
-	}
-
-	Unlocksnd();
-
-	DEBUG_PRINT((DEBUG_NAME "MCSN audio available!\n"));
-	return(1);
-}
-
-static void Audio_DeleteDevice(SDL_AudioDevice *device)
-{
-    SDL_free(device->hidden);
-    SDL_free(device);
-}
-
-static SDL_AudioDevice *Audio_CreateDevice(int devindex)
-{
-	SDL_AudioDevice *this;
-
-	/* Initialize all variables that we clean on shutdown */
-	this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
-    if ( this ) {
-        SDL_memset(this, 0, (sizeof *this));
-        this->hidden = (struct SDL_PrivateAudioData *)
-                SDL_malloc((sizeof *this->hidden));
-    }
-    if ( (this == NULL) || (this->hidden == NULL) ) {
-        SDL_OutOfMemory();
-        if ( this ) {
-            SDL_free(this);
-        }
-        return(0);
-    }
-    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
-
-    /* Set the function pointers */
-    this->OpenAudio   = Mint_OpenAudio;
-    this->CloseAudio  = Mint_CloseAudio;
-    this->LockAudio   = Mint_LockAudio;
-    this->UnlockAudio = Mint_UnlockAudio;
-    this->free        = Audio_DeleteDevice;
-
-    return this;
-}
-
-AudioBo

(Patch may be truncated, please check the link at the top of this post.)