changeset 178:bdbe09014724

Minor tweaks and such.
author Ryan C. Gordon <icculus@icculus.org>
date Wed, 05 Dec 2001 22:24:28 +0000
parents 028a6691fbf9
children bded4e43ae73
files decoders/wav.c
diffstat 1 files changed, 30 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/decoders/wav.c	Wed Dec 05 22:24:07 2001 +0000
+++ b/decoders/wav.c	Wed Dec 05 22:24:28 2001 +0000
@@ -67,18 +67,6 @@
     WAV_read        /*  read() method */
 };
 
-static int WAV_init(void)
-{
-    return(1);  /* always succeeds. */
-} /* WAV_init */
-
-
-static void WAV_quit(void)
-{
-    /* it's a no-op. */
-} /* WAV_quit */
-
-
 
     /* Chunk management code... */
 
@@ -100,7 +88,7 @@
     Uint16 iCoef2;
 } ADPCMCOEFSET;
 
-typedef struct S_FMT_T
+typedef struct S_WAV_FMT_T
 {
     Uint32 chunkID;
     Sint32 chunkSize;
@@ -110,8 +98,8 @@
     Uint32 dwAvgBytesPerSec;
     Uint16 wBlockAlign;
     Uint16 wBitsPerSample;
-    
-    void (*free)(struct S_FMT_T *fmt);
+
+    void (*free)(struct S_WAV_FMT_T *fmt);
     Uint32(*read_sample)(Sound_Sample *sample);
 
     union
@@ -123,6 +111,8 @@
             Uint16 wNumCoef;
             ADPCMCOEFSET *aCoeff;
         } adpcm;
+
+        /* put other format-specific data here... */
     } fmt;
 } fmt_t;
 
@@ -265,6 +255,7 @@
 
 static int read_fmt_normal(SDL_RWops *rw, fmt_t *fmt)
 {
+    /* (don't need to read more from the RWops...) */
     fmt->free = free_fmt_normal;
     fmt->read_sample = read_sample_fmt_normal;
     return(1);
@@ -348,10 +339,22 @@
 } /* read_fmt_adpcm */
 
 
+
 /*****************************************************************************
  * Everything else...                                                        *
  *****************************************************************************/
 
+static int WAV_init(void)
+{
+    return(1);  /* always succeeds. */
+} /* WAV_init */
+
+
+static void WAV_quit(void)
+{
+    /* it's a no-op. */
+} /* WAV_quit */
+
 
 static int read_fmt(SDL_RWops *rw, fmt_t *fmt)
 {
@@ -359,15 +362,24 @@
     switch (fmt->wFormatTag)
     {
         case FMT_NORMAL:
+            SNDDBG(("WAV: Appears to be uncompressed audio.\n"));
             return(read_fmt_normal(rw, fmt));
 
         case FMT_ADPCM:
+            SNDDBG(("WAV: Appears to be ADPCM compressed audio.\n"));
             return(read_fmt_adpcm(rw, fmt));
+
+        /* add other types here. */
+
+        default:
+            SNDDBG(("WAV: Format %lu is unknown.\n",
+                    (unsigned int) fmt->wFormatTag));
+            Sound_SetError("WAV: Unsupported format");
+            return(0);  /* not supported whatsoever. */
     } /* switch */
 
-    SNDDBG(("WAV: Format %d is unknown.\n", (int) fmt->wFormatTag));
-    Sound_SetError("WAV: Unsupported format");
-    return(0);  /* not supported whatsoever. */
+    assert(0);  /* shouldn't hit this point. */
+    return(0);
 } /* read_fmt */