changeset 387:fb519e6028e3

Changed all the Sound_SetError() calls to __Sound_SetError (or BAIL*_MACRO)
author Ryan C. Gordon <icculus@icculus.org>
date Fri, 05 Jul 2002 23:11:51 +0000
parents 8c8ecd1008c9
children 43249ebb82e3
files CHANGELOG SDL_sound.c SDL_sound_internal.h alt_audio_convert.h audio_convert.c decoders/aiff.c decoders/au.c decoders/flac.c decoders/modplug.c decoders/mpglib/interface.c decoders/mpglib/layer3.c decoders/mpglib/mpglib_common.c decoders/raw.c decoders/shn.c decoders/skeleton.c decoders/smpeg.c decoders/voc.c decoders/wav.c
diffstat 18 files changed, 91 insertions(+), 156 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGELOG	Fri Jul 05 22:34:55 2002 +0000
+++ b/CHANGELOG	Fri Jul 05 23:11:51 2002 +0000
@@ -3,7 +3,9 @@
  */
 
 07052002 - Cleaned up some stuff in playsound.c, removing some FIXMEs.
-           Commandline validation is improved, too.
+           Commandline validation is improved, too. FIXME removal in 
+           voc.c; should report i/o errors correctly now. Changed DECLSPEC
+           to SNDDECLSPEC to prevent SDL conflict, and added SDLCALL support.
 07022002 - Added WinCE support pack to website, updated INSTALL with CE info.
            More altcvt fixes from Frank Ranostaj.
 07012002 - Fixed configure.in to work around bug in older autoconfs. Started
--- a/SDL_sound.c	Fri Jul 05 22:34:55 2002 +0000
+++ b/SDL_sound.c	Fri Jul 05 23:11:51 2002 +0000
@@ -358,7 +358,7 @@
     if (str == NULL)
         return;
 
-    SNDDBG(("Sound_SetError(\"%s\");%s\n", str,
+    SNDDBG(("__Sound_SetError(\"%s\");%s\n", str,
               (initialized) ? "" : " [NOT INITIALIZED!]"));
 
     if (!initialized)
@@ -444,7 +444,7 @@
     Sound_SampleInternal *internal = malloc(sizeof (Sound_SampleInternal));
     if ((retval == NULL) || (internal == NULL))
     {
-        Sound_SetError(ERR_OUT_OF_MEMORY);
+        __Sound_SetError(ERR_OUT_OF_MEMORY);
         if (retval)
             free(retval);
         if (internal)
@@ -460,7 +460,7 @@
     retval->buffer = malloc(bufferSize);  /* pure ugly. */
     if (!retval->buffer)
     {
-        Sound_SetError(ERR_OUT_OF_MEMORY);
+        __Sound_SetError(ERR_OUT_OF_MEMORY);
         free(internal);
         free(retval);
         return(NULL);
@@ -549,7 +549,7 @@
                             desired.rate,
                             sample->buffer_size) == -1)
     {
-        Sound_SetError(SDL_GetError());
+        __Sound_SetError(SDL_GetError());
         funcs->close(sample);
         SDL_RWseek(internal->rw, pos, SEEK_SET);  /* set for next try... */
         return(0);
@@ -668,7 +668,7 @@
         free(retval->buffer);
     free(retval);
     SDL_RWclose(rw);
-    Sound_SetError(ERR_UNSUPPORTED_FORMAT);
+    __Sound_SetError(ERR_UNSUPPORTED_FORMAT);
     return(NULL);
 } /* Sound_NewSample */
 
@@ -700,13 +700,13 @@
 
     if (!initialized)
     {
-        Sound_SetError(ERR_NOT_INITIALIZED);
+        __Sound_SetError(ERR_NOT_INITIALIZED);
         return;
     } /* if */
 
     if (sample == NULL)
     {
-        Sound_SetError(ERR_INVALID_ARGUMENT);
+        __Sound_SetError(ERR_INVALID_ARGUMENT);
         return;
     } /* if */
 
@@ -827,7 +827,7 @@
         if (ptr == NULL)
         {
             sample->flags |= SOUND_SAMPLEFLAG_ERROR;
-            Sound_SetError(ERR_OUT_OF_MEMORY);
+            __Sound_SetError(ERR_OUT_OF_MEMORY);
         } /* if */
         else
         {
--- a/SDL_sound_internal.h	Fri Jul 05 22:34:55 2002 +0000
+++ b/SDL_sound_internal.h	Fri Jul 05 23:11:51 2002 +0000
@@ -163,13 +163,13 @@
          *      sample->flags |= SOUND_SAMPLEFLAG_EOF;
          *
          *   If there's an unrecoverable error, then do:
-         *      Sound_SetError(ERR_EXPLAIN_WHAT_WENT_WRONG);
+         *      __Sound_SetError(ERR_EXPLAIN_WHAT_WENT_WRONG);
          *      sample->flags |= SOUND_SAMPLEFLAG_ERROR;
          *
          *   If there's more data, but you'd have to block for considerable
          *    amounts of time to get at it, or there's a recoverable error,
          *    then do:
-         *      Sound_SetError(ERR_EXPLAIN_WHAT_WENT_WRONG);
+         *      __Sound_SetError(ERR_EXPLAIN_WHAT_WENT_WRONG);
          *      sample->flags |= SOUND_SAMPLEFLAG_EAGAIN;
          *
          * SDL_sound will not call your read() method for any samples with
@@ -273,9 +273,6 @@
  */
 void __Sound_SetError(const char *err);
 
-/* !!! FIXME: Clean up elsewhere and get rid of this. */
-#define Sound_SetError __Sound_SetError
-
 /*
  * Call this to convert milliseconds to an actual byte position, based on
  *  audio data characteristics.
--- a/alt_audio_convert.h	Fri Jul 05 22:34:55 2002 +0000
+++ b/alt_audio_convert.h	Fri Jul 05 23:11:51 2002 +0000
@@ -32,6 +32,8 @@
 #define Sound_AI_Loop 0x2
 #define _fsize 32
 
+#include "SDL_sound.h"
+
 typedef struct{
     Sint16 numerator;
     Sint16 denominator;
@@ -72,9 +74,9 @@
 
 #define SDL_SOUND_Loop 0x10
 
-extern DECLSPEC int Sound_ConvertAudio( Sound_AudioCVT *Data );
+extern SNDDECLSPEC int Sound_ConvertAudio( Sound_AudioCVT *Data );
 
-extern DECLSPEC int Sound_BuildAudioCVT( Sound_AudioCVT *Data,
+extern SNDDECLSPEC int Sound_BuildAudioCVT( Sound_AudioCVT *Data,
    Uint16 src_format, Uint8 src_channels, int src_rate,
    Uint16 dst_format, Uint8 dst_channels, int dst_rate, Uint32 dst_size );
 
--- a/audio_convert.c	Fri Jul 05 22:34:55 2002 +0000
+++ b/audio_convert.c	Fri Jul 05 23:11:51 2002 +0000
@@ -551,7 +551,7 @@
         /* Make sure there's data to convert */
     if (cvt->buf == NULL)
     {
-        Sound_SetError("No buffer allocated for conversion");
+        __Sound_SetError("No buffer allocated for conversion");
         return(-1);
     } /* if */
 
--- a/decoders/aiff.c	Fri Jul 05 22:34:55 2002 +0000
+++ b/decoders/aiff.c	Fri Jul 05 23:11:51 2002 +0000
@@ -441,8 +441,7 @@
         default:
             SNDDBG(("AIFF: Format %lu is unknown.\n",
                     (unsigned int) fmt->type));
-            Sound_SetError("AIFF: Unsupported format");
-            return(0);  /* not supported whatsoever. */
+            BAIL_MACRO("AIFF: Unsupported format", 0);
     } /* switch */
 
     assert(0);  /* shouldn't hit this point. */
@@ -508,16 +507,14 @@
 
     if (!find_chunk(rw, ssndID))
     {
-        Sound_SetError("AIFF: No sound data chunk.");
         free(a);
-        return(0);
+        BAIL_MACRO("AIFF: No sound data chunk.", 0);
     } /* if */
 
     if (!read_ssnd_chunk(rw, &s))
     {
-        Sound_SetError("AIFF: Can't read sound data chunk.");
         free(a);
-        return(0);
+        BAIL_MACRO("AIFF: Can't read sound data chunk.", 0);
     } /* if */
 
     a->fmt.total_bytes = a->bytesLeft = bytes_per_sample * c.numSampleFrames;
--- a/decoders/au.c	Fri Jul 05 22:34:55 2002 +0000
+++ b/decoders/au.c	Fri Jul 05 23:11:51 2002 +0000
@@ -171,11 +171,8 @@
     struct audec *dec;
     char c;
 
-    if (!read_au_header(rw, &hdr)) /* does byte order swapping. */
-    {
-        Sound_SetError("AU: Not an .au file (bad header)");
-        return(0);
-    } /* if */
+    /* read_au_header() will do byte order swapping. */
+    BAIL_IF_MACRO(!read_au_header(rw, &hdr), "AU: bad header", 0);
 
     dec = malloc(sizeof *dec);
     BAIL_IF_MACRO(dec == NULL, ERR_OUT_OF_MEMORY, 0);
@@ -203,9 +200,8 @@
                 break;
 
             default:
-                Sound_SetError("AU: Unsupported .au encoding");
                 free(dec);
-                return 0;
+                BAIL_MACRO("AU: Unsupported .au encoding", 0);
         } /* switch */
 
         sample->actual.rate = hdr.sample_rate;
@@ -244,9 +240,8 @@
 
     else
     {
-        Sound_SetError("AU: Not an .AU stream.");
         free(dec);
-        return(0);
+        BAIL_MACRO("AU: Not an .AU stream.", 0);
     } /* else */
 
     sample->flags = SOUND_SAMPLEFLAG_CANSEEK;
--- a/decoders/flac.c	Fri Jul 05 22:34:55 2002 +0000
+++ b/decoders/flac.c	Fri Jul 05 23:11:51 2002 +0000
@@ -308,8 +308,7 @@
 {
     flac_t *f = (flac_t *) client_data;
 
-        /* !!! FIXME: Is every error really fatal? I don't know... */
-    Sound_SetError(d_error_status_string[status]);
+    __Sound_SetError(d_error_status_string[status]);
     f->sample->flags |= SOUND_SAMPLEFLAG_ERROR;
 } /* error_callback */
 
@@ -449,9 +448,8 @@
     decoder = d_new();
     if (decoder == NULL)
     {
-        Sound_SetError(ERR_OUT_OF_MEMORY);
         free(f);
-        return(0);
+        BAIL_MACRO(ERR_OUT_OF_MEMORY, 0);
     } /* if */       
 
     d_set_read_callback(decoder, read_callback);
@@ -515,9 +513,8 @@
         /* Still not FLAC? Give up. */
         if (!f->is_flac)
         {
-            Sound_SetError("FLAC: No metadata found. Not a FLAC stream?");
             free_flac(f);
-            return(0);
+            BAIL_MACRO("FLAC: No metadata found. Not a FLAC stream?", 0);
         } /* if */
     } /* if */
 
@@ -543,9 +540,8 @@
 
     if (!d_process_one_frame(f->decoder))
     {
-        Sound_SetError("FLAC: Couldn't decode frame.");
         sample->flags |= SOUND_SAMPLEFLAG_ERROR;
-        return(0);
+        BAIL_MACRO("FLAC: Couldn't decode frame.", 0);
     } /* if */
 
     if (d_get_state(f->decoder) == D_END_OF_STREAM)
--- a/decoders/modplug.c	Fri Jul 05 22:34:55 2002 +0000
+++ b/decoders/modplug.c	Fri Jul 05 23:11:51 2002 +0000
@@ -189,8 +189,7 @@
     if (!has_extension)
     {
         SNDDBG(("MODPLUG: Unrecognized file type: %s\n", ext));
-        Sound_SetError("MODPLUG: Not a module file.");
-        return(0);
+        BAIL_MACRO("MODPLUG: Not a module file.", 0);
     } /* if */
     
         /*
--- a/decoders/mpglib/interface.c	Fri Jul 05 22:34:55 2002 +0000
+++ b/decoders/mpglib/interface.c	Fri Jul 05 23:11:51 2002 +0000
@@ -53,14 +53,12 @@
 	struct buf *nbuf;
 
 	nbuf = malloc( sizeof(struct buf) );
-	if(!nbuf) {
-		Sound_SetError("MPGLIB: Out of memory!");
-		return NULL;
-	}
+	BAIL_IF_MACRO(!nbuf, ERR_OUT_OF_MEMORY, NULL);
+
 	nbuf->pnt = malloc(size);
 	if(!nbuf->pnt) {
 		free(nbuf);
-		return NULL;
+		BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL);
 	}
 	nbuf->size = size;
 	memcpy(nbuf->pnt,buf,size);
@@ -106,8 +104,7 @@
 		remove_buf(mp);
 		pos = mp->tail->pos;
 		if(!mp->tail) {
-			Sound_SetError("MPGLIB: Fatal error! Short read in read_buf_byte()!");
-			return 0;
+			BAIL_MACRO("MPGLIB: Short read in read_buf_byte()!", 0);
 		}
 	}
 
@@ -155,10 +152,7 @@
 {
 	int len;
 
-	if(osize < 4608) {
-		Sound_SetError("MPGLIB: Not enough output space for decoding!");
-		return MP3_ERR;
-	}
+	BAIL_IF_MACRO(osize < 4608, "MPGLIB: Output buffer too small", MP3_ERR);
 
 	if(in) {
 		if(addbuf(mp,in,isize) == NULL) {
@@ -232,8 +226,8 @@
 {
   unsigned char *bsbufold;
   if(mp->fsizeold < 0 && backstep > 0) {
-    Sound_SetError("MPGLIB: Can't step back!"); /* FIXME: need formatting: %ld!\n",backstep); */
-    return MP3_ERR;
+    /* FIXME: need formatting: %ld!\n",backstep); */
+    BAIL_MACRO("MPGLIB: Can't step back!", MP3_ERR);
   }
   bsbufold = mp->bsspace[mp->bsnum] + 512;
   wordpointer -= backstep;
--- a/decoders/mpglib/layer3.c	Fri Jul 05 22:34:55 2002 +0000
+++ b/decoders/mpglib/layer3.c	Fri Jul 05 23:11:51 2002 +0000
@@ -347,8 +347,7 @@
            gr_info->full_gain[i] = gr_info->pow2gain + (getbits_fast(3)<<3);
 
          if(gr_info->block_type == 0) {
-           Sound_SetError("MPGLIB: Blocktype == 0 and window-switching == 1 not allowed.");
-           return 0;
+           BAIL_MACRO("MPGLIB: Blocktype == 0 and window-switching == 1 not allowed.", 0);
          }
          /* region_count/start parameters are implicit in this case. */       
          gr_info->region1start = 36>>1;
@@ -421,8 +420,7 @@
            gr_info->full_gain[i] = gr_info->pow2gain + (getbits_fast(3)<<3);
 
          if(gr_info->block_type == 0) {
-           Sound_SetError("MPGLIB: Blocktype == 0 and window-switching == 1 not allowed.");
-           return 0;
+           BAIL_MACRO("MPGLIB: Blocktype == 0 and window-switching == 1 not allowed.", 0);
          }
          /* region_count/start parameters are implicit in this case. */       
 /* check this again! */
@@ -956,8 +954,8 @@
   if(part2remain > 0)
     getbits(part2remain);
   else if(part2remain < 0) {
-    Sound_SetError("MPGLIB: Can't rewind stream!"); /* !!! FIXME: Need formatting: by %d bits!\n",-part2remain);*/
-    return 1; /* -> error */
+    /* !!! FIXME: Need formatting: by %d bits!\n",-part2remain);*/
+    BAIL_MACRO("MPGLIB: Can't rewind stream!", 1); /* -> error */
   }
   return 0;
 }
@@ -1367,8 +1365,8 @@
   if(part2remain > 0 )
     getbits(part2remain);
   else if(part2remain < 0) {
-    Sound_SetError("MPGLIB: Can't rewind stream!"); /* !!! FIXME: Need formatting: by %d bits!\n",-part2remain); */
-    return 1; /* -> error */
+    /* !!! FIXME: Need formatting: by %d bits!\n",-part2remain);*/
+    BAIL_MACRO("MPGLIB: Can't rewind stream!", 1); /* -> error */
   }
   return 0;
 }
@@ -1906,7 +1904,7 @@
     if(!III_get_side_info_1(&sideinfo,stereo,ms_stereo,sfreq,single))
       return -1;
 #else
-    Sound_SetError("MPGLIB: Not supported!");
+    __Sound_SetError("MPGLIB: Not supported!");
 #endif
   }
 
@@ -1927,7 +1925,7 @@
 #ifdef MPEG1
         part2bits = III_get_scale_factors_1(scalefacs[0],gr_info);
 #else
-        Sound_SetError("MPGLIB: Not supported!");
+        __Sound_SetError("MPGLIB: Not supported!");
 #endif
       }
       if(III_dequantize_sample(hybridIn[0], scalefacs[0],gr_info,sfreq,part2bits))
@@ -1942,7 +1940,7 @@
 #ifdef MPEG1
         part2bits = III_get_scale_factors_1(scalefacs[1],gr_info);
 #else
-        Sound_SetError("MPGLIB: Not supported!");
+        __Sound_SetError("MPGLIB: Not supported!");
 #endif
       }
 
--- a/decoders/mpglib/mpglib_common.c	Fri Jul 05 22:34:55 2002 +0000
+++ b/decoders/mpglib/mpglib_common.c	Fri Jul 05 23:11:51 2002 +0000
@@ -70,8 +70,7 @@
     
     fr->lay = 4-((newhead>>17)&3);
     if( ((newhead>>10)&0x3) == 0x3) {
-      Sound_SetError("MPGLIB: Corrupted header");
-      return 0;
+      BAIL_MACRO("MPGLIB: Corrupted header", 0);
     }
     if(fr->mpeg25) {
       fr->sampling_frequency = 6 + ((newhead>>10)&0x3);
@@ -96,8 +95,7 @@
 
     if(!fr->bitrate_index)
     {
-      Sound_SetError("MPGLIB: Free format not supported.");
-      return (0);
+      BAIL_MACRO("MPGLIB: Free format not supported.", 0);
     }
 
     switch(fr->lay)
@@ -112,7 +110,7 @@
         fr->framesize /= mpglib_freqs[fr->sampling_frequency];
         fr->framesize  = ((fr->framesize+fr->padding)<<2)-4;
 #else
-        Sound_SetError("MPGLIB: Not supported!");
+        __Sound_SetError("MPGLIB: Not supported!");
 #endif
         break;
       case 2:
@@ -125,7 +123,7 @@
         fr->framesize /= mpglib_freqs[fr->sampling_frequency];
         fr->framesize += fr->padding - 4;
 #else
-        Sound_SetError("MPGLIB: Not supported!");
+        __Sound_SetError("MPGLIB: Not supported!");
 #endif
         break;
       case 3:
@@ -146,8 +144,7 @@
           fr->framesize = fr->framesize + fr->padding - 4;
         break; 
       default:
-        Sound_SetError("MPGLIB: Unknown layer type.");
-        return (0);
+        BAIL_MACRO("MPGLIB: Unknown layer type.", 0);
     }
     return 1;
 }
--- a/decoders/raw.c	Fri Jul 05 22:34:55 2002 +0000
+++ b/decoders/raw.c	Fri Jul 05 23:11:51 2002 +0000
@@ -100,10 +100,7 @@
          *  determine whether we should handle this data or not.
          */
     if (__Sound_strcasecmp(ext, "RAW") != 0)
-    {
-        Sound_SetError("RAW: extension isn't explicitly \"RAW\".");
-        return(0);
-    } /* if */
+        BAIL_MACRO("RAW: extension isn't explicitly \"RAW\".", 0);
 
         /*
          * You must also specify a desired format, so we know how to
@@ -114,8 +111,7 @@
          (sample->desired.rate == 0)     ||
          (sample->desired.format == 0) )
     {
-        Sound_SetError("RAW: invalid desired format.");
-        return(0);
+        BAIL_MACRO("RAW: invalid desired format.", 0);
     } /* if */
 
     SNDDBG(("RAW: Accepting data stream.\n"));
--- a/decoders/shn.c	Fri Jul 05 22:34:55 2002 +0000
+++ b/decoders/shn.c	Fri Jul 05 23:11:51 2002 +0000
@@ -420,7 +420,7 @@
             mean = 0x8000;
             break;
         default:
-            Sound_SetError("SHN: unknown file type");
+            __Sound_SetError("SHN: unknown file type");
             return;
     } /* switch */
 
@@ -640,7 +640,7 @@
         shn->qlpc = (int *) malloc((Uint32) (shn->maxnlpc * sizeof (Sint32)));
         if (shn->qlpc == NULL)
         {
-            Sound_SetError(ERR_OUT_OF_MEMORY);
+            __Sound_SetError(ERR_OUT_OF_MEMORY);
             goto shn_open_puke;
         } /* if */
     } /* if */
@@ -655,8 +655,8 @@
          (cmd != SHN_FN_VERBATIM) ||
          (!parse_riff_header(shn, sample)) )
     {
-        if (cmd != SHN_FN_VERBATIM)
-            Sound_SetError("SHN: Expected VERBATIM function");
+        if (cmd != SHN_FN_VERBATIM) /* the other conditions set error state */
+            __Sound_SetError("SHN: Expected VERBATIM function");
 
         goto shn_open_puke;
         return(0);
@@ -667,7 +667,7 @@
     shn = (shn_t *) malloc(sizeof (shn_t));
     if (shn == NULL)
     {
-        Sound_SetError(ERR_OUT_OF_MEMORY);
+        __Sound_SetError(ERR_OUT_OF_MEMORY);
         goto shn_open_puke;
     } /* if */
 
@@ -1290,9 +1290,8 @@
 
             case SHN_FN_VERBATIM:
             default:
-                Sound_SetError("SHN: Unhandled function.");
                 sample->flags |= SOUND_SAMPLEFLAG_ERROR;
-                return(retval);
+                BAIL_MACRO("SHN: Unhandled function.", retval);
         } /* switch */
     } /* while */
 
--- a/decoders/skeleton.c	Fri Jul 05 22:34:55 2002 +0000
+++ b/decoders/skeleton.c	Fri Jul 05 23:11:51 2002 +0000
@@ -100,10 +100,7 @@
     SDL_RWops *rw = internal->rw;
 
     if (can NOT accept the data)
-    {
-        Sound_SetError("FMT: expected X, got Y.");
-        return(0);
-    } /* if */
+        BAIL_MACRO("FMT: expected X, got Y.", 0);
 
     SNDDBG(("FMT: Accepting data stream.\n"));
     set up sample->actual;
--- a/decoders/smpeg.c	Fri Jul 05 22:34:55 2002 +0000
+++ b/decoders/smpeg.c	Fri Jul 05 23:11:51 2002 +0000
@@ -173,16 +173,14 @@
 
     if (SMPEG_error(smpeg))
     {
-        Sound_SetError(SMPEG_error(smpeg));
         SMPEG_delete(smpeg);
-        return(0);
+        BAIL_MACRO(SMPEG_error(smpeg), 0);
     } /* if */
 
     if (!smpeg_info.has_audio)
     {
-        Sound_SetError("SMPEG: No audio stream found in data.");
         SMPEG_delete(smpeg);
-        return(0);
+        BAIL_MACRO("SMPEG: No audio stream found in data.", 0);
     } /* if */
 
     SNDDBG(("SMPEG: Accepting data stream.\n"));
@@ -247,7 +245,7 @@
             sample->flags |= SOUND_SAMPLEFLAG_EOF;
         else
         {
-            Sound_SetError(errMsg);
+            __Sound_SetError(errMsg);
             sample->flags |= SOUND_SAMPLEFLAG_ERROR;
         } /* else */
     } /* if */
--- a/decoders/voc.c	Fri Jul 05 22:34:55 2002 +0000
+++ b/decoders/voc.c	Fri Jul 05 23:11:51 2002 +0000
@@ -146,9 +146,8 @@
 {
     if (SDL_RWread(src, p, size, 1) != 1)
     {
-        Sound_SetError("VOC: i/o error");
         v->error = 1;
-        return 0;
+        BAIL_MACRO("VOC: i/o error", 0);
     } /* if */
 
     return(1);
@@ -167,8 +166,7 @@
 
     if (memcmp(signature, "Creative Voice File\032", sizeof (signature)) != 0)
     {
-        Sound_SetError("VOC: Wrong signature; not a VOC file.");
-        return(0);
+        BAIL_MACRO("VOC: Wrong signature; not a VOC file.", 0);
     } /* if */
 
         /* get the offset where the first datablock is located */
@@ -179,8 +177,7 @@
 
     if (SDL_RWseek(src, datablockofs, SEEK_SET) != datablockofs)
     {
-        Sound_SetError("VOC: Failed to seek to data block.");
-        return(0);
+        BAIL_MACRO("VOC: Failed to seek to data block.", 0);
     } /* if */
 
     return(1);  /* success! */
@@ -227,17 +224,10 @@
                 /* block, the DATA blocks rate value is invalid */
                 if (!v->extended)
                 {
-                    if (uc == 0)
-                    {
-                        Sound_SetError("VOC Sample rate is zero?");
-                        return 0;
-                    } /* if */
+                    BAIL_IF_MACRO(uc == 0, "VOC: Sample rate is zero?", 0);
 
                     if ((v->rate != -1) && (uc != v->rate))
-                    {
-                        Sound_SetError("VOC sample rate codes differ");
-                        return 0;
-                    } /* if */
+                        BAIL_MACRO("VOC sample rate codes differ", 0);
 
                     v->rate = uc;
                     sample->actual.rate = 1000000.0/(256 - v->rate);
@@ -245,13 +235,9 @@
                 } /* if */
 
                 if (!voc_readbytes(src, v, &uc, sizeof (uc)))
-                    return 0;
+                    return(0);
 
-                if (uc != 0)
-                {
-                    Sound_SetError("VOC decoder only interprets 8-bit data");
-                    return 0;
-                } /* if */
+                BAIL_IF_MACRO(uc != 0, "VOC: only supports 8-bit data", 0);
 
                 v->extended = 0;
                 v->rest = sblen - 2;
@@ -263,16 +249,11 @@
                     return 0;
 
                 new_rate_long = SDL_SwapLE32(new_rate_long);
-                if (new_rate_long == 0)
-                {
-                    Sound_SetError("VOC Sample rate is zero?");
-                    return 0;
-                } /* if */
+                BAIL_IF_MACRO(!new_rate_long, "VOC: Sample rate is zero?", 0);
+
                 if ((v->rate != -1) && (new_rate_long != v->rate))
-                {
-                    Sound_SetError("VOC sample rate codes differ");
-                    return 0;
-                } /* if */
+                    BAIL_MACRO("VOC: sample rate codes differ", 0);
+
                 v->rate = new_rate_long;
                 sample->actual.rate = new_rate_long;
 
@@ -284,8 +265,7 @@
                     case 8:  v->size = ST_SIZE_BYTE; break;
                     case 16: v->size = ST_SIZE_WORD; break;
                     default:
-                        Sound_SetError("VOC with unknown data size");
-                        return 0;
+                        BAIL_MACRO("VOC: unknown data size", 0);
                 } /* switch */
 
                 if (!voc_readbytes(src, v, &v->channels, sizeof (Uint8)))
@@ -310,11 +290,7 @@
                 if (!voc_readbytes(src, v, &uc, sizeof (uc)))
                     return 0;
 
-                if (uc == 0)
-                {
-                    Sound_SetError("VOC silence sample rate is zero");
-                    return 0;
-                } /* if */
+                BAIL_IF_MACRO(uc == 0, "VOC: silence sample rate is zero", 0);
 
                 /*
                  * Some silence-packed files have gratuitously
@@ -333,7 +309,7 @@
             case VOC_LOOPEND:
                 for(i = 0; i < sblen; i++)   /* skip repeat loops. */
                 {
-                    if (!voc_readbytes(src, v, trash, sizeof (Uint8)))
+                   if (!voc_readbytes(src, v, trash, sizeof (Uint8)))
                         return 0;
                 } /* for */
                 break;
@@ -348,26 +324,17 @@
                     return 0;
 
                 new_rate_short = SDL_SwapLE16(new_rate_short);
-                if (new_rate_short == 0)
-                {
-                   Sound_SetError("VOC sample rate is zero");
-                   return 0;
-                } /* if */
+                BAIL_IF_MACRO(!new_rate_short, "VOC: sample rate is zero", 0);
+
                 if ((v->rate != -1) && (new_rate_short != v->rate))
-                {
-                   Sound_SetError("VOC sample rate codes differ");
-                   return 0;
-                } /* if */
+                   BAIL_MACRO("VOC: sample rate codes differ", 0);
+
                 v->rate = new_rate_short;
 
                 if (!voc_readbytes(src, v, &uc, sizeof (uc)))
                     return 0;
 
-                if (uc != 0)
-                {
-                    Sound_SetError("VOC decoder only interprets 8-bit data");
-                    return 0;
-                } /* if */
+                BAIL_IF_MACRO(uc != 0, "VOC: only supports 8-bit data", 0);
 
                 if (!voc_readbytes(src, v, &uc, sizeof (uc)))
                     return 0;
@@ -391,8 +358,11 @@
                 /* Falling! Falling! */
 
             default:  /* text block or other krapola. */
-                if (!voc_readbytes(src, v, &trash, sizeof (Uint8) * sblen))
-                    return 0;
+                for(i = 0; i < sblen; i++)   /* skip repeat loops. */
+                {
+                   if (!voc_readbytes(src, v, trash, sizeof (Uint8)))
+                        return 0;
+                } /* for */
 
                 if (block == VOC_TEXT)
                     continue;    /* get next block */
@@ -443,7 +413,7 @@
             done = SDL_RWread(src, buf + v->bufpos, 1, max);
             if (done < max)
             {
-                Sound_SetError("VOC: i/o error");
+                __Sound_SetError("VOC: i/o error");
                 sample->flags |= SOUND_SAMPLEFLAG_ERROR;
             } /* if */
         } /* if */
@@ -459,7 +429,7 @@
                     done = rc - cur;
                 else
                 {
-                    Sound_SetError("VOC: seek error");
+                    __Sound_SetError("VOC: seek error");
                     sample->flags |= SOUND_SAMPLEFLAG_ERROR;
                 } /* else */
             } /* if */
@@ -496,9 +466,8 @@
 
     if (v->rate == -1)
     {
-        Sound_SetError("VOC data had no sound!");
         free(v);
-        return(0);
+        BAIL_MACRO("VOC: data had no sound!", 0);
     } /* if */
 
     SNDDBG(("VOC: Accepting data stream.\n"));
--- a/decoders/wav.c	Fri Jul 05 22:34:55 2002 +0000
+++ b/decoders/wav.c	Fri Jul 05 23:11:51 2002 +0000
@@ -647,8 +647,7 @@
         default:
             SNDDBG(("WAV: Format 0x%X is unknown.\n",
                     (unsigned int) fmt->wFormatTag));
-            Sound_SetError("WAV: Unsupported format");
-            return(0);  /* not supported whatsoever. */
+            BAIL_MACRO("WAV: Unsupported format", 0);
     } /* switch */
 
     assert(0);  /* shouldn't hit this point. */