diff SDL_sound.c @ 149:1df5c106504e

Decoders can now list multiple file extensions.
author Ryan C. Gordon <icculus@icculus.org>
date Thu, 01 Nov 2001 19:13:17 +0000
parents 3e60862fbd76
children fa3e593b6a5e
line wrap: on
line diff
--- a/SDL_sound.c	Thu Nov 01 19:12:36 2001 +0000
+++ b/SDL_sound.c	Thu Nov 01 19:13:17 2001 +0000
@@ -444,8 +444,8 @@
 Sound_Sample *Sound_NewSample(SDL_RWops *rw, const char *ext,
                               Sound_AudioInfo *desired, Uint32 bSize)
 {
-    size_t i;
     Sound_Sample *retval;
+    decoder_element *decoder;
 
     /* sanity checks. */
     BAIL_IF_MACRO(!initialized, ERR_NOT_INITIALIZED, NULL);
@@ -457,26 +457,30 @@
 
     if (ext != NULL)
     {
-        for (i = 0; decoders[i].funcs != NULL; i++)
+        for (decoder = &decoders[0]; decoder->funcs != NULL; decoder++)
         {
-            if (decoders[i].available)
+            if (decoder->available)
             {
-                const char *decoderExt = decoders[i].funcs->info.extension;
-                if (__Sound_strcasecmp(decoderExt, ext) == 0)
+                const char **decoderExt = decoder->funcs->info.extensions;
+                while (*decoderExt)
                 {
-                    if (init_sample(decoders[i].funcs, retval, ext, desired))
-                        return(retval);
-                } /* if */
+                    if (__Sound_strcasecmp(*decoderExt, ext) == 0)
+                    {
+                        if (init_sample(decoder->funcs, retval, ext, desired))
+                            return(retval);
+                    } /* if */
+                    decoderExt++;
+                } /* while */
             } /* if */
         } /* for */
     } /* if */
 
     /* no direct extension match? Try everything we've got... */
-    for (i = 0; decoders[i].funcs != NULL; i++)
+    for (decoder = &decoders[0]; decoder->funcs != NULL; decoder++)
     {
-        if (decoders[i].available)
+        if (decoder->available)
         {
-            if (init_sample(decoders[i].funcs, retval, ext, desired))
+            if (init_sample(decoder->funcs, retval, ext, desired))
                 return(retval);
         } /* if */
     } /* for */