src/audio/SDL_wave.c
changeset 1994 6abc7e6f9817
parent 1895 c121d94672cb
child 2012 575d5c9d4db8
--- a/src/audio/SDL_wave.c	Thu Aug 31 20:59:42 2006 +0000
+++ b/src/audio/SDL_wave.c	Thu Aug 31 21:00:10 2006 +0000
@@ -413,7 +413,7 @@
     int was_error;
     Chunk chunk;
     int lenread;
-    int MS_ADPCM_encoded, IMA_ADPCM_encoded;
+    int IEEE_float_encoded, MS_ADPCM_encoded, IMA_ADPCM_encoded;
     int samplesize;
 
     /* WAV magic header */
@@ -472,11 +472,15 @@
         was_error = 1;
         goto done;
     }
-    MS_ADPCM_encoded = IMA_ADPCM_encoded = 0;
+    IEEE_float_encoded = MS_ADPCM_encoded = IMA_ADPCM_encoded = 0;
     switch (SDL_SwapLE16(format->encoding)) {
     case PCM_CODE:
         /* We can understand this */
         break;
+    case IEEE_FLOAT_CODE:
+        IEEE_float_encoded = 1;
+        /* We can understand this */
+        break;
     case MS_ADPCM_CODE:
         /* Try to understand this */
         if (InitMS_ADPCM(format) < 0) {
@@ -506,24 +510,37 @@
     }
     SDL_memset(spec, 0, (sizeof *spec));
     spec->freq = SDL_SwapLE32(format->frequency);
-    switch (SDL_SwapLE16(format->bitspersample)) {
-    case 4:
-        if (MS_ADPCM_encoded || IMA_ADPCM_encoded) {
-            spec->format = AUDIO_S16;
+
+    if (IEEE_float_encoded) {
+        if ((SDL_SwapLE16(format->bitspersample)) != 32) {
+            was_error = 1;
         } else {
-            was_error = 1;
+            spec->format = AUDIO_F32;
         }
-        break;
-    case 8:
-        spec->format = AUDIO_U8;
-        break;
-    case 16:
-        spec->format = AUDIO_S16;
-        break;
-    default:
-        was_error = 1;
-        break;
+    } else {
+        switch (SDL_SwapLE16(format->bitspersample)) {
+        case 4:
+            if (MS_ADPCM_encoded || IMA_ADPCM_encoded) {
+                spec->format = AUDIO_S16;
+            } else {
+                was_error = 1;
+            }
+            break;
+        case 8:
+            spec->format = AUDIO_U8;
+            break;
+        case 16:
+            spec->format = AUDIO_S16;
+            break;
+        case 32:
+            spec->format = AUDIO_S32;
+            break;
+        default:
+            was_error = 1;
+            break;
+        }
     }
+
     if (was_error) {
         SDL_SetError("Unknown %d-bit PCM data format",
                      SDL_SwapLE16(format->bitspersample));