diff src/audio/mint/SDL_mintaudio_mcsn.c @ 2005:45af7d69f8eb

MiNT audio driver cleanups for clamping types and channels to supported values. int32 support now available in one instance.
author Ryan C. Gordon <icculus@icculus.org>
date Fri, 01 Sep 2006 06:32:54 +0000
parents c121d94672cb
children d48ead2d2ba5
line wrap: on
line diff
--- a/src/audio/mint/SDL_mintaudio_mcsn.c	Fri Sep 01 06:01:03 2006 +0000
+++ b/src/audio/mint/SDL_mintaudio_mcsn.c	Fri Sep 01 06:32:54 2006 +0000
@@ -225,18 +225,23 @@
     int i;
     unsigned long masterclock, masterprediv;
 
-    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((DEBUG_NAME "asked: %d bits, ", SDL_AUDIO_BITSIZE(spec->format)));
+    DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(spec->format)));
+    DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(spec->format)));
+    DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(spec->format)));
     DEBUG_PRINT(("channels=%d, ", spec->channels));
     DEBUG_PRINT(("freq=%d\n", spec->freq));
 
+    if (spec->channels > 2) {
+        spec->channels = 2;  /* no more than stereo! */
+    }
+
     /* Check formats available */
     MINTAUDIO_freqcount = 0;
     switch (cookie_mcsn->play) {
     case MCSN_ST:
         spec->channels = 1;
-        spec->format = 8;       /* FIXME: is it signed or unsigned ? */
+        spec->format = AUDIO_S8;     /* FIXME: is it signed or unsigned ? */
         SDL_MintAudio_AddFrequency(this, 12500, 0, 0, -1);
         break;
     case MCSN_TT:              /* Also STE, Mega STE */
@@ -274,9 +279,9 @@
                                            (1 << i) - 1, -1);
             }
         }
-        spec->format |= 0x8000; /* Audio is always signed */
-        if ((spec->format & 0x00ff) == 16) {
-            spec->format |= 0x1000;     /* Audio is always big endian */
+        spec->format |= SDL_AUDIO_MASK_SIGNED; /* Audio is always signed */
+        if ((SDL_AUDIO_BITSIZE(spec->format)) == 16) {
+            spec->format |= SDL_AUDIO_MASK_ENDIAN;   /* Audio is always big endian */
             spec->channels = 2; /* 16 bits always stereo */
         }
         break;
@@ -294,9 +299,10 @@
     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((DEBUG_NAME "obtained: %d bits, ", SDL_AUDIO_BITSIZE(spec->format)));
+    DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(spec->format)));
+    DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(spec->format)));
+    DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(spec->format)));
     DEBUG_PRINT(("channels=%d, ", spec->channels));
     DEBUG_PRINT(("freq=%d\n", spec->freq));
 
@@ -321,7 +327,7 @@
 
     /* Select replay format */
     channels_mode = STEREO16;
-    switch (spec->format & 0xff) {
+    switch (SDL_AUDIO_BITSIZE(spec->format)) {
     case 8:
         if (spec->channels == 2) {
             channels_mode = STEREO8;