Add error messages for failure cases
authorSam Lantinga <slouken@libsdl.org>
Wed, 25 Nov 2009 06:00:00 +0000
changeset 3491 1192adfc6d52
parent 3490 42e33f89a167
child 3492 7a606cfa5c2d
Add error messages for failure cases
src/audio/SDL_audiocvt.c
--- a/src/audio/SDL_audiocvt.c	Wed Nov 25 04:41:09 2009 +0000
+++ b/src/audio/SDL_audiocvt.c	Wed Nov 25 06:00:00 2009 +0000
@@ -837,7 +837,8 @@
             }
 
             if (filter == NULL) {
-                return -1;      /* Still no matching converter?! */
+                SDL_SetError("No conversion available for these formats");
+                return -1;
             }
         }
 
@@ -930,7 +931,8 @@
             }
 
             if (filter == NULL) {
-                return -1;      /* Still no matching converter?! */
+                SDL_SetError("No conversion available for these rates");
+                return -1;
             }
         }
 
@@ -969,16 +971,19 @@
      * !!! FIXME: good in practice as it sounds in theory, though.
      */
 
-    /* there are no unsigned types over 16 bits, so catch this upfront. */
+    /* there are no unsigned types over 16 bits, so catch this up front. */
     if ((SDL_AUDIO_BITSIZE(src_fmt) > 16) && (!SDL_AUDIO_ISSIGNED(src_fmt))) {
+        SDL_SetError("Invalid source format");
         return -1;
     }
     if ((SDL_AUDIO_BITSIZE(dst_fmt) > 16) && (!SDL_AUDIO_ISSIGNED(dst_fmt))) {
+        SDL_SetError("Invalid destination format");
         return -1;
     }
 
     /* prevent possible divisions by zero, etc. */
     if ((src_rate == 0) || (dst_rate == 0)) {
+        SDL_SetError("Source or destination rate is zero");
         return -1;
     }
 #ifdef DEBUG_CONVERT