diff src/audio/mint/SDL_mintaudio_xbios.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 649e9ac39f74
line wrap: on
line diff
--- a/src/audio/mint/SDL_mintaudio_xbios.c	Fri Sep 01 06:01:03 2006 +0000
+++ b/src/audio/mint/SDL_mintaudio_xbios.c	Fri Sep 01 06:32:54 2006 +0000
@@ -359,16 +359,21 @@
     int i;
     Uint32 extclock;
 
-    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));
 
-    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 */
+
+    /* clamp out int32/float32 */
+    if (SDL_AUDIO_BITSIZE(spec->format) >= 16) {
+        spec->format = AUDIO_S16MSB; /* Audio is always big endian */
         spec->channels = 2;     /* 16 bits always stereo */
+    } else if (spec->channels > 2) {
+        spec->channels = 2;  /* no more than stereo! */
     }
 
     MINTAUDIO_freqcount = 0;
@@ -400,9 +405,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));
 
@@ -427,7 +433,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;