Changed audio subsystem's OpenDevice interface to return -1 on error.
authorRyan C. Gordon <icculus@icculus.org>
Sun, 31 Mar 2013 13:05:40 -0400
changeset 7038 7f22b9ba218f
parent 7037 3fedf1f25b94
child 7039 f69b305b053d
Changed audio subsystem's OpenDevice interface to return -1 on error. This lets us 'return SDL_SetError("whatever");' on one line. Fixes Bugzilla #1778.
src/audio/SDL_audio.c
src/audio/alsa/SDL_alsa_audio.c
src/audio/android/SDL_androidaudio.c
src/audio/arts/SDL_artsaudio.c
src/audio/baudio/SDL_beaudio.cc
src/audio/bsd/SDL_bsdaudio.c
src/audio/coreaudio/SDL_coreaudio.c
src/audio/directsound/SDL_directsound.c
src/audio/disk/SDL_diskaudio.c
src/audio/dsp/SDL_dspaudio.c
src/audio/dummy/SDL_dummyaudio.c
src/audio/esd/SDL_esdaudio.c
src/audio/fusionsound/SDL_fsaudio.c
src/audio/nas/SDL_nasaudio.c
src/audio/paudio/SDL_paudio.c
src/audio/psp/SDL_pspaudio.c
src/audio/pulseaudio/SDL_pulseaudio.c
src/audio/qsa/SDL_qsa_audio.c
src/audio/sun/SDL_sunaudio.c
src/audio/winmm/SDL_winmm.c
src/audio/xaudio2/SDL_xaudio2.c
--- a/src/audio/SDL_audio.c	Sun Mar 31 12:48:50 2013 -0400
+++ b/src/audio/SDL_audio.c	Sun Mar 31 13:05:40 2013 -0400
@@ -191,7 +191,7 @@
 static int
 SDL_AudioOpenDevice_Default(_THIS, const char *devname, int iscapture)
 {
-    return 0;
+    return -1;
 }
 
 static void
@@ -940,7 +940,7 @@
          ((!iscapture) && (current_audio.outputDevices == NULL)) )
         SDL_GetNumAudioDevices(iscapture);
 
-    if (!current_audio.impl.OpenDevice(device, devname, iscapture)) {
+    if (current_audio.impl.OpenDevice(device, devname, iscapture) < 0) {
         close_audio_device(device);
         return 0;
     }
--- a/src/audio/alsa/SDL_alsa_audio.c	Sun Mar 31 12:48:50 2013 -0400
+++ b/src/audio/alsa/SDL_alsa_audio.c	Sun Mar 31 13:05:40 2013 -0400
@@ -482,8 +482,7 @@
     this->hidden = (struct SDL_PrivateAudioData *)
         SDL_malloc((sizeof *this->hidden));
     if (this->hidden == NULL) {
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     SDL_memset(this->hidden, 0, (sizeof *this->hidden));
 
@@ -495,9 +494,8 @@
 
     if (status < 0) {
         ALSA_CloseDevice(this);
-        SDL_SetError("ALSA: Couldn't open audio device: %s",
-                     ALSA_snd_strerror(status));
-        return 0;
+        return SDL_SetError("ALSA: Couldn't open audio device: %s",
+                            ALSA_snd_strerror(status));
     }
 
     this->hidden->pcm_handle = pcm_handle;
@@ -507,9 +505,8 @@
     status = ALSA_snd_pcm_hw_params_any(pcm_handle, hwparams);
     if (status < 0) {
         ALSA_CloseDevice(this);
-        SDL_SetError("ALSA: Couldn't get hardware config: %s",
-                     ALSA_snd_strerror(status));
-        return 0;
+        return SDL_SetError("ALSA: Couldn't get hardware config: %s",
+                            ALSA_snd_strerror(status));
     }
 
     /* SDL only uses interleaved sample output */
@@ -517,9 +514,8 @@
                                                SND_PCM_ACCESS_RW_INTERLEAVED);
     if (status < 0) {
         ALSA_CloseDevice(this);
-        SDL_SetError("ALSA: Couldn't set interleaved access: %s",
+        return SDL_SetError("ALSA: Couldn't set interleaved access: %s",
                      ALSA_snd_strerror(status));
-        return 0;
     }
 
     /* Try for a closest match on audio format */
@@ -572,8 +568,7 @@
     }
     if (status < 0) {
         ALSA_CloseDevice(this);
-        SDL_SetError("ALSA: Couldn't find any hardware audio formats");
-        return 0;
+        return SDL_SetError("ALSA: Couldn't find any hardware audio formats");
     }
     this->spec.format = test_format;
 
@@ -585,8 +580,7 @@
         status = ALSA_snd_pcm_hw_params_get_channels(hwparams, &channels);
         if (status < 0) {
             ALSA_CloseDevice(this);
-            SDL_SetError("ALSA: Couldn't set audio channels");
-            return 0;
+            return SDL_SetError("ALSA: Couldn't set audio channels");
         }
         this->spec.channels = channels;
     }
@@ -597,9 +591,8 @@
                                                   &rate, NULL);
     if (status < 0) {
         ALSA_CloseDevice(this);
-        SDL_SetError("ALSA: Couldn't set audio frequency: %s",
-                     ALSA_snd_strerror(status));
-        return 0;
+        return SDL_SetError("ALSA: Couldn't set audio frequency: %s",
+                            ALSA_snd_strerror(status));
     }
     this->spec.freq = rate;
 
@@ -609,8 +602,7 @@
         /* Failed to set desired buffer size, do the best you can... */
         if ( ALSA_set_period_size(this, hwparams, 1) < 0 ) {
             ALSA_CloseDevice(this);
-            SDL_SetError("Couldn't set hardware audio parameters: %s", ALSA_snd_strerror(status));
-            return(-1);
+            return SDL_SetError("Couldn't set hardware audio parameters: %s", ALSA_snd_strerror(status));
         }
     }
     /* Set the software parameters */
@@ -618,31 +610,27 @@
     status = ALSA_snd_pcm_sw_params_current(pcm_handle, swparams);
     if (status < 0) {
         ALSA_CloseDevice(this);
-        SDL_SetError("ALSA: Couldn't get software config: %s",
-                     ALSA_snd_strerror(status));
-        return 0;
+        return SDL_SetError("ALSA: Couldn't get software config: %s",
+                            ALSA_snd_strerror(status));
     }
     status = ALSA_snd_pcm_sw_params_set_avail_min(pcm_handle, swparams, this->spec.samples);
     if (status < 0) {
         ALSA_CloseDevice(this);
-        SDL_SetError("Couldn't set minimum available samples: %s",
-                     ALSA_snd_strerror(status));
-        return 0;
+        return SDL_SetError("Couldn't set minimum available samples: %s",
+                            ALSA_snd_strerror(status));
     }
     status =
         ALSA_snd_pcm_sw_params_set_start_threshold(pcm_handle, swparams, 1);
     if (status < 0) {
         ALSA_CloseDevice(this);
-        SDL_SetError("ALSA: Couldn't set start threshold: %s",
-                     ALSA_snd_strerror(status));
-        return 0;
+        return SDL_SetError("ALSA: Couldn't set start threshold: %s",
+                            ALSA_snd_strerror(status));
     }
     status = ALSA_snd_pcm_sw_params(pcm_handle, swparams);
     if (status < 0) {
         ALSA_CloseDevice(this);
-        SDL_SetError("Couldn't set software audio parameters: %s",
-                     ALSA_snd_strerror(status));
-        return 0;
+        return SDL_SetError("Couldn't set software audio parameters: %s",
+                            ALSA_snd_strerror(status));
     }
 
     /* Calculate the final parameters for this audio specification */
@@ -653,8 +641,7 @@
     this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen);
     if (this->hidden->mixbuf == NULL) {
         ALSA_CloseDevice(this);
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
 
@@ -662,7 +649,7 @@
     ALSA_snd_pcm_nonblock(pcm_handle, 0);
 
     /* We're ready to rock and roll. :-) */
-    return 1;
+    return 0;
 }
 
 static void
--- a/src/audio/android/SDL_androidaudio.c	Sun Mar 31 12:48:50 2013 -0400
+++ b/src/audio/android/SDL_androidaudio.c	Sun Mar 31 13:05:40 2013 -0400
@@ -42,21 +42,18 @@
     
     if (iscapture) {
     	//TODO: implement capture
-    	SDL_SetError("Capture not supported on Android");
-    	return 0;
+    	return SDL_SetError("Capture not supported on Android");
     }
 
     if (audioDevice != NULL) {
-    	SDL_SetError("Only one audio device at a time please!");
-    	return 0;
+    	return SDL_SetError("Only one audio device at a time please!");
     }
 
     audioDevice = this;
 
     this->hidden = SDL_malloc(sizeof(*(this->hidden)));
     if (!this->hidden) {
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     SDL_memset(this->hidden, 0, (sizeof *this->hidden));
 
@@ -71,8 +68,7 @@
     
     if (test_format == 0) {
     	// Didn't find a compatible format :(
-    	SDL_SetError("No compatible audio format!");
-    	return 0;
+    	return SDL_SetError("No compatible audio format!");
     }
 
     if (this->spec.channels > 1) {
@@ -94,11 +90,10 @@
 
     if (this->spec.samples == 0) {
     	// Init failed?
-    	SDL_SetError("Java-side initialization failed!");
-    	return 0;
+    	return SDL_SetError("Java-side initialization failed!");
     }
 
-    return 1;
+    return 0;
 }
 
 static void
--- a/src/audio/arts/SDL_artsaudio.c	Sun Mar 31 12:48:50 2013 -0400
+++ b/src/audio/arts/SDL_artsaudio.c	Sun Mar 31 13:05:40 2013 -0400
@@ -241,8 +241,7 @@
     this->hidden = (struct SDL_PrivateAudioData *)
         SDL_malloc((sizeof *this->hidden));
     if (this->hidden == NULL) {
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     SDL_memset(this->hidden, 0, (sizeof *this->hidden));
 
@@ -271,22 +270,19 @@
     }
     if (format == 0) {
         ARTS_CloseDevice(this);
-        SDL_SetError("Couldn't find any hardware audio formats");
-        return 0;
+        return SDL_SetError("Couldn't find any hardware audio formats");
     }
     this->spec.format = test_format;
 
     if ((rc = SDL_NAME(arts_init) ()) != 0) {
         ARTS_CloseDevice(this);
-        SDL_SetError("Unable to initialize ARTS: %s",
-                     SDL_NAME(arts_error_text) (rc));
-        return 0;
+        return SDL_SetError("Unable to initialize ARTS: %s",
+                            SDL_NAME(arts_error_text) (rc));
     }
 
     if (!ARTS_Suspend()) {
         ARTS_CloseDevice(this);
-        SDL_SetError("ARTS can not open audio device");
-        return 0;
+        return SDL_SetError("ARTS can not open audio device");
     }
 
     this->hidden->stream = SDL_NAME(arts_play_stream) (this->spec.freq,
@@ -304,8 +300,7 @@
     for (frag_spec = 0; (0x01 << frag_spec) < this->spec.size; ++frag_spec);
     if ((0x01 << frag_spec) != this->spec.size) {
         ARTS_CloseDevice(this);
-        SDL_SetError("Fragment size must be a power of two");
-        return 0;
+        return SDL_SetError("Fragment size must be a power of two");
     }
     frag_spec |= 0x00020000;    /* two fragments, for low latency */
 
@@ -326,8 +321,7 @@
     this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen);
     if (this->hidden->mixbuf == NULL) {
         ARTS_CloseDevice(this);
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
 
@@ -335,7 +329,7 @@
     this->hidden->parent = getpid();
 
     /* We're ready to rock and roll. :-) */
-    return 1;
+    return 0;
 }
 
 
--- a/src/audio/baudio/SDL_beaudio.cc	Sun Mar 31 12:48:50 2013 -0400
+++ b/src/audio/baudio/SDL_beaudio.cc	Sun Mar 31 13:05:40 2013 -0400
@@ -95,8 +95,7 @@
     /* Initialize all variables that we clean on shutdown */
     _this->hidden = new SDL_PrivateAudioData;
     if (_this->hidden == NULL) {
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     SDL_memset(_this->hidden, 0, (sizeof *_this->hidden));
 
@@ -153,8 +152,7 @@
 
     if (!valid_datatype) {      /* shouldn't happen, but just in case... */
         BEOSAUDIO_CloseDevice(_this);
-        SDL_SetError("Unsupported audio format");
-        return 0;
+        return SDL_SetError("Unsupported audio format");
     }
 
     /* Calculate the final parameters for this audio specification */
@@ -173,12 +171,11 @@
         _this->hidden->audio_obj->SetHasData(true);
     } else {
         BEOSAUDIO_CloseDevice(_this);
-        SDL_SetError("Unable to start Be audio");
-        return 0;
+        return SDL_SetError("Unable to start Be audio");
     }
 
     /* We're running! */
-    return 1;
+    return 0;
 }
 
 static void
--- a/src/audio/bsd/SDL_bsdaudio.c	Sun Mar 31 12:48:50 2013 -0400
+++ b/src/audio/bsd/SDL_bsdaudio.c	Sun Mar 31 13:05:40 2013 -0400
@@ -239,8 +239,7 @@
     if (devname == NULL) {
         devname = SDL_GetAudioDeviceName(0, iscapture);
         if (devname == NULL) {
-            SDL_SetError("No such audio device");
-            return 0;
+            return SDL_SetError("No such audio device");
         }
     }
 
@@ -248,16 +247,14 @@
     this->hidden = (struct SDL_PrivateAudioData *)
         SDL_malloc((sizeof *this->hidden));
     if (this->hidden == NULL) {
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     SDL_memset(this->hidden, 0, (sizeof *this->hidden));
 
     /* Open the audio device */
     this->hidden->audio_fd = open(devname, flags, 0);
     if (this->hidden->audio_fd < 0) {
-        SDL_SetError("Couldn't open %s: %s", devname, strerror(errno));
-        return 0;
+        return SDL_SetError("Couldn't open %s: %s", devname, strerror(errno));
     }
 
     AUDIO_INITINFO(&info);
@@ -269,8 +266,7 @@
     info.mode = AUMODE_PLAY;
     if (ioctl(this->hidden->audio_fd, AUDIO_SETINFO, &info) < 0) {
         BSDAUDIO_CloseDevice(this);
-        SDL_SetError("Couldn't put device into play mode");
-        return 0;
+        return SDL_SetError("Couldn't put device into play mode");
     }
 
     AUDIO_INITINFO(&info);
@@ -312,8 +308,7 @@
 
     if (!format) {
         BSDAUDIO_CloseDevice(this);
-        SDL_SetError("No supported encoding for 0x%x", this->spec.format);
-        return 0;
+        return SDL_SetError("No supported encoding for 0x%x", this->spec.format);
     }
 
     this->spec.format = format;
@@ -336,15 +331,14 @@
     this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen);
     if (this->hidden->mixbuf == NULL) {
         BSDAUDIO_CloseDevice(this);
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
 
     BSDAUDIO_Status(this);
 
     /* We're ready to rock and roll. :-) */
-    return (0);
+    return 0;
 }
 
 static int
--- a/src/audio/coreaudio/SDL_coreaudio.c	Sun Mar 31 12:48:50 2013 -0400
+++ b/src/audio/coreaudio/SDL_coreaudio.c	Sun Mar 31 13:05:40 2013 -0400
@@ -469,8 +469,7 @@
     this->hidden = (struct SDL_PrivateAudioData *)
         SDL_malloc((sizeof *this->hidden));
     if (this->hidden == NULL) {
-        SDL_OutOfMemory();
-        return (0);
+        return SDL_OutOfMemory();
     }
     SDL_memset(this->hidden, 0, (sizeof *this->hidden));
 
@@ -511,8 +510,7 @@
 
     if (!valid_datatype) {      /* shouldn't happen, but just in case... */
         COREAUDIO_CloseDevice(this);
-        SDL_SetError("Unsupported audio format");
-        return 0;
+        return SDL_SetError("Unsupported audio format");
     }
 
     strdesc.mBytesPerFrame =
@@ -522,10 +520,10 @@
 
     if (!prepare_audiounit(this, devname, iscapture, &strdesc)) {
         COREAUDIO_CloseDevice(this);
-        return 0;               /* prepare_audiounit() will call SDL_SetError()... */
+        return -1;      /* prepare_audiounit() will call SDL_SetError()... */
     }
 
-    return 1;                   /* good to go. */
+    return 0;   /* good to go. */
 }
 
 static int
--- a/src/audio/directsound/SDL_directsound.c	Sun Mar 31 12:48:50 2013 -0400
+++ b/src/audio/directsound/SDL_directsound.c	Sun Mar 31 13:05:40 2013 -0400
@@ -363,8 +363,7 @@
                                                   DSSCL_NORMAL);
     }
     if (result != DS_OK) {
-        SetDSerror("DirectSound SetCooperativeLevel", result);
-        return (-1);
+        return SetDSerror("DirectSound SetCooperativeLevel", result);
     }
 
     /* Try to create the secondary buffer */
@@ -449,8 +448,7 @@
             pDirectSoundEnumerateW(FindDevGUID, &devguid);
 
         if (!devguid.found) {
-            SDL_SetError("DirectSound: Requested device not found");
-            return 0;
+            return SDL_SetError("DirectSound: Requested device not found");
         }
         guid = &devguid.guid;
     }
@@ -459,8 +457,7 @@
     this->hidden = (struct SDL_PrivateAudioData *)
         SDL_malloc((sizeof *this->hidden));
     if (this->hidden == NULL) {
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     SDL_memset(this->hidden, 0, (sizeof *this->hidden));
 
@@ -478,8 +475,7 @@
 
     if (!valid_format) {
         DSOUND_CloseDevice(this);
-        SDL_SetError("DirectSound: Unsupported audio format");
-        return 0;
+        return SDL_SetError("DirectSound: Unsupported audio format");
     }
 
     SDL_memset(&waveformat, 0, sizeof(waveformat));
@@ -499,21 +495,20 @@
     result = pDirectSoundCreate8(guid, &this->hidden->sound, NULL);
     if (result != DS_OK) {
         DSOUND_CloseDevice(this);
-        SetDSerror("DirectSoundCreate", result);
-        return 0;
+        return SetDSerror("DirectSoundCreate", result);
     }
 
     /* Create the audio buffer to which we write */
     this->hidden->num_buffers = CreateSecondary(this, NULL, &waveformat);
     if (this->hidden->num_buffers < 0) {
         DSOUND_CloseDevice(this);
-        return 0;
+        return -1;
     }
 
     /* The buffer will auto-start playing in DSOUND_WaitDevice() */
     this->hidden->mixlen = this->spec.size;
 
-    return 1;                   /* good to go. */
+    return 0;                   /* good to go. */
 }
 
 
--- a/src/audio/disk/SDL_diskaudio.c	Sun Mar 31 12:48:50 2013 -0400
+++ b/src/audio/disk/SDL_diskaudio.c	Sun Mar 31 13:05:40 2013 -0400
@@ -110,8 +110,7 @@
     this->hidden = (struct SDL_PrivateAudioData *)
         SDL_malloc(sizeof(*this->hidden));
     if (this->hidden == NULL) {
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     SDL_memset(this->hidden, 0, sizeof(*this->hidden));
 
@@ -119,14 +118,14 @@
     this->hidden->output = SDL_RWFromFile(fname, "wb");
     if (this->hidden->output == NULL) {
         DISKAUD_CloseDevice(this);
-        return 0;
+        return -1;
     }
 
     /* Allocate mixing buffer */
     this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen);
     if (this->hidden->mixbuf == NULL) {
         DISKAUD_CloseDevice(this);
-        return 0;
+        return -1;
     }
     SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
 
@@ -141,7 +140,7 @@
 #endif
 
     /* We're ready to rock and roll. :-) */
-    return 1;
+    return 0;
 }
 
 static int
--- a/src/audio/dsp/SDL_dspaudio.c	Sun Mar 31 12:48:50 2013 -0400
+++ b/src/audio/dsp/SDL_dspaudio.c	Sun Mar 31 13:05:40 2013 -0400
@@ -89,8 +89,7 @@
     if (devname == NULL) {
         devname = SDL_GetAudioDeviceName(0, iscapture);
         if (devname == NULL) {
-            SDL_SetError("No such audio device");
-            return 0;
+            return SDL_SetError("No such audio device");
         }
     }
 
@@ -107,8 +106,7 @@
     this->hidden = (struct SDL_PrivateAudioData *)
         SDL_malloc((sizeof *this->hidden));
     if (this->hidden == NULL) {
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     SDL_memset(this->hidden, 0, (sizeof *this->hidden));
 
@@ -116,8 +114,7 @@
     this->hidden->audio_fd = open(devname, flags, 0);
     if (this->hidden->audio_fd < 0) {
         DSP_CloseDevice(this);
-        SDL_SetError("Couldn't open %s: %s", devname, strerror(errno));
-        return 0;
+        return SDL_SetError("Couldn't open %s: %s", devname, strerror(errno));
     }
     this->hidden->mixbuf = NULL;
 
@@ -128,8 +125,7 @@
         ctlflags &= ~O_NONBLOCK;
         if (fcntl(this->hidden->audio_fd, F_SETFL, ctlflags) < 0) {
             DSP_CloseDevice(this);
-            SDL_SetError("Couldn't set audio blocking mode");
-            return 0;
+            return SDL_SetError("Couldn't set audio blocking mode");
         }
     }
 
@@ -137,8 +133,7 @@
     if (ioctl(this->hidden->audio_fd, SNDCTL_DSP_GETFMTS, &value) < 0) {
         perror("SNDCTL_DSP_GETFMTS");
         DSP_CloseDevice(this);
-        SDL_SetError("Couldn't get audio format list");
-        return 0;
+        return SDL_SetError("Couldn't get audio format list");
     }
 
     /* Try for a closest match on audio format */
@@ -195,8 +190,7 @@
     }
     if (format == 0) {
         DSP_CloseDevice(this);
-        SDL_SetError("Couldn't find any hardware audio formats");
-        return 0;
+        return SDL_SetError("Couldn't find any hardware audio formats");
     }
     this->spec.format = test_format;
 
@@ -206,8 +200,7 @@
         (value != format)) {
         perror("SNDCTL_DSP_SETFMT");
         DSP_CloseDevice(this);
-        SDL_SetError("Couldn't set audio format");
-        return 0;
+        return SDL_SetError("Couldn't set audio format");
     }
 
     /* Set the number of channels of output */
@@ -215,8 +208,7 @@
     if (ioctl(this->hidden->audio_fd, SNDCTL_DSP_CHANNELS, &value) < 0) {
         perror("SNDCTL_DSP_CHANNELS");
         DSP_CloseDevice(this);
-        SDL_SetError("Cannot set the number of channels");
-        return 0;
+        return SDL_SetError("Cannot set the number of channels");
     }
     this->spec.channels = value;
 
@@ -225,8 +217,7 @@
     if (ioctl(this->hidden->audio_fd, SNDCTL_DSP_SPEED, &value) < 0) {
         perror("SNDCTL_DSP_SPEED");
         DSP_CloseDevice(this);
-        SDL_SetError("Couldn't set audio frequency");
-        return 0;
+        return SDL_SetError("Couldn't set audio frequency");
     }
     this->spec.freq = value;
 
@@ -237,8 +228,7 @@
     for (frag_spec = 0; (0x01U << frag_spec) < this->spec.size; ++frag_spec);
     if ((0x01U << frag_spec) != this->spec.size) {
         DSP_CloseDevice(this);
-        SDL_SetError("Fragment size must be a power of two");
-        return 0;
+        return SDL_SetError("Fragment size must be a power of two");
     }
     frag_spec |= 0x00020000;    /* two fragments, for low latency */
 
@@ -266,13 +256,12 @@
     this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen);
     if (this->hidden->mixbuf == NULL) {
         DSP_CloseDevice(this);
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
 
     /* We're ready to rock and roll. :-) */
-    return 1;
+    return 0;
 }
 
 
--- a/src/audio/dummy/SDL_dummyaudio.c	Sun Mar 31 12:48:50 2013 -0400
+++ b/src/audio/dummy/SDL_dummyaudio.c	Sun Mar 31 13:05:40 2013 -0400
@@ -29,7 +29,7 @@
 static int
 DUMMYAUD_OpenDevice(_THIS, const char *devname, int iscapture)
 {
-    return 1;                   /* always succeeds. */
+    return 0;                   /* always succeeds. */
 }
 
 static int
--- a/src/audio/esd/SDL_esdaudio.c	Sun Mar 31 12:48:50 2013 -0400
+++ b/src/audio/esd/SDL_esdaudio.c	Sun Mar 31 13:05:40 2013 -0400
@@ -228,8 +228,7 @@
     this->hidden = (struct SDL_PrivateAudioData *)
         SDL_malloc((sizeof *this->hidden));
     if (this->hidden == NULL) {
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     SDL_memset(this->hidden, 0, (sizeof *this->hidden));
     this->hidden->audio_fd = -1;
@@ -257,8 +256,7 @@
 
     if (!found) {
         ESD_CloseDevice(this);
-        SDL_SetError("Couldn't find any hardware audio formats");
-        return 0;
+        return SDL_SetError("Couldn't find any hardware audio formats");
     }
 
     if (this->spec.channels == 1) {
@@ -277,8 +275,7 @@
 
     if (this->hidden->audio_fd < 0) {
         ESD_CloseDevice(this);
-        SDL_SetError("Couldn't open ESD connection");
-        return 0;
+        return SDL_SetError("Couldn't open ESD connection");
     }
 
     /* Calculate the final parameters for this audio specification */
@@ -292,8 +289,7 @@
     this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen);
     if (this->hidden->mixbuf == NULL) {
         ESD_CloseDevice(this);
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
 
@@ -301,7 +297,7 @@
     this->hidden->parent = getpid();
 
     /* We're ready to rock and roll. :-) */
-    return 1;
+    return 0;
 }
 
 static void
--- a/src/audio/fusionsound/SDL_fsaudio.c	Sun Mar 31 12:48:50 2013 -0400
+++ b/src/audio/fusionsound/SDL_fsaudio.c	Sun Mar 31 13:05:40 2013 -0400
@@ -200,8 +200,7 @@
     this->hidden = (struct SDL_PrivateAudioData *)
         SDL_malloc((sizeof *this->hidden));
     if (this->hidden == NULL) {
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     SDL_memset(this->hidden, 0, (sizeof *this->hidden));
 
@@ -243,8 +242,7 @@
 
     if (format == 0) {
         SDL_FS_CloseDevice(this);
-        SDL_SetError("Couldn't find any hardware audio formats");
-        return 0;
+        return SDL_SetError("Couldn't find any hardware audio formats");
     }
     this->spec.format = test_format;
 
@@ -252,8 +250,7 @@
     ret = SDL_NAME(FusionSoundCreate) (&this->hidden->fs);
     if (ret) {
         SDL_FS_CloseDevice(this);
-        SDL_SetError("Unable to initialize FusionSound: %d", ret);
-        return 0;
+        return SDL_SetError("Unable to initialize FusionSound: %d", ret);
     }
 
     this->hidden->mixsamples = this->spec.size / bytes / this->spec.channels;
@@ -272,8 +269,7 @@
                                        &this->hidden->stream);
     if (ret) {
         SDL_FS_CloseDevice(this);
-        SDL_SetError("Unable to create FusionSoundStream: %d", ret);
-        return 0;
+        return SDL_SetError("Unable to create FusionSoundStream: %d", ret);
     }
 
     /* See what we got */
@@ -294,13 +290,12 @@
     this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen);
     if (this->hidden->mixbuf == NULL) {
         SDL_FS_CloseDevice(this);
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
 
     /* We're ready to rock and roll. :-) */
-    return 1;
+    return 0;
 }
 
 
--- a/src/audio/nas/SDL_nasaudio.c	Sun Mar 31 12:48:50 2013 -0400
+++ b/src/audio/nas/SDL_nasaudio.c	Sun Mar 31 13:05:40 2013 -0400
@@ -288,8 +288,7 @@
     this->hidden = (struct SDL_PrivateAudioData *)
         SDL_malloc((sizeof *this->hidden));
     if (this->hidden == NULL) {
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     SDL_memset(this->hidden, 0, (sizeof *this->hidden));
 
@@ -304,24 +303,21 @@
     }
     if (format == 0) {
         NAS_CloseDevice(this);
-        SDL_SetError("NAS: Couldn't find any hardware audio formats");
-        return 0;
+        return SDL_SetError("NAS: Couldn't find any hardware audio formats");
     }
     this->spec.format = test_format;
 
     this->hidden->aud = NAS_AuOpenServer("", 0, NULL, 0, NULL, NULL);
     if (this->hidden->aud == 0) {
         NAS_CloseDevice(this);
-        SDL_SetError("NAS: Couldn't open connection to NAS server");
-        return 0;
+        return SDL_SetError("NAS: Couldn't open connection to NAS server");
     }
 
     this->hidden->dev = find_device(this, this->spec.channels);
     if ((this->hidden->dev == AuNone)
         || (!(this->hidden->flow = NAS_AuCreateFlow(this->hidden->aud, 0)))) {
         NAS_CloseDevice(this);
-        SDL_SetError("NAS: Couldn't find a fitting device on NAS server");
-        return 0;
+        return SDL_SetError("NAS: Couldn't find a fitting device on NAS server");
     }
 
     buffer_size = this->spec.freq;
@@ -354,13 +350,12 @@
     this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen);
     if (this->hidden->mixbuf == NULL) {
         NAS_CloseDevice(this);
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
 
     /* We're ready to rock and roll. :-) */
-    return 1;
+    return 0;
 }
 
 static void
--- a/src/audio/paudio/SDL_paudio.c	Sun Mar 31 12:48:50 2013 -0400
+++ b/src/audio/paudio/SDL_paudio.c	Sun Mar 31 13:05:40 2013 -0400
@@ -264,8 +264,7 @@
     this->hidden = (struct SDL_PrivateAudioData *)
         SDL_malloc((sizeof *this->hidden));
     if (this->hidden == NULL) {
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     SDL_memset(this->hidden, 0, (sizeof *this->hidden));
 
@@ -274,8 +273,7 @@
     this->hidden->audio_fd = fd;
     if (fd < 0) {
         PAUDIO_CloseDevice(this);
-        SDL_SetError("Couldn't open %s: %s", audiodev, strerror(errno));
-        return 0;
+        return SDL_SetError("Couldn't open %s: %s", audiodev, strerror(errno));
     }
 
     /*
@@ -284,8 +282,7 @@
      */
     if (ioctl(fd, AUDIO_BUFFER, &paud_bufinfo) < 0) {
         PAUDIO_CloseDevice(this);
-        SDL_SetError("Couldn't get audio buffer information");
-        return 0;
+        return SDL_SetError("Couldn't get audio buffer information");
     }
 
     if (this->spec.channels > 1)
@@ -399,8 +396,7 @@
         fprintf(stderr, "Couldn't find any hardware audio formats\n");
 #endif
         PAUDIO_CloseDevice(this);
-        SDL_SetError("Couldn't find any hardware audio formats");
-        return 0;
+        return SDL_SetError("Couldn't find any hardware audio formats");
     }
     this->spec.format = test_format;
 
@@ -458,8 +454,7 @@
 
     if (err != NULL) {
         PAUDIO_CloseDevice(this);
-        SDL_SetError("Paudio: %s", err);
-        return 0;
+        return SDL_SetError("Paudio: %s", err);
     }
 
     /* Allocate mixing buffer */
@@ -467,8 +462,7 @@
     this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen);
     if (this->hidden->mixbuf == NULL) {
         PAUDIO_CloseDevice(this);
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
 
@@ -506,8 +500,7 @@
 #ifdef DEBUG_AUDIO
         fprintf(stderr, "Can't start audio play\n");
 #endif
-        SDL_SetError("Can't start audio play");
-        return 0;
+        return SDL_SetError("Can't start audio play");
     }
 
     /* Check to see if we need to use select() workaround */
@@ -518,7 +511,7 @@
     }
 
     /* We're ready to rock and roll. :-) */
-    return 1;
+    return 0;
 }
 
 static int
--- a/src/audio/psp/SDL_pspaudio.c	Sun Mar 31 12:48:50 2013 -0400
+++ b/src/audio/psp/SDL_pspaudio.c	Sun Mar 31 13:05:40 2013 -0400
@@ -46,8 +46,7 @@
     this->hidden = (struct SDL_PrivateAudioData *)
         SDL_malloc(sizeof(*this->hidden));
     if (this->hidden == NULL) {
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     SDL_memset(this->hidden, 0, sizeof(*this->hidden));
 	switch (this->spec.format & 0xff) {
@@ -56,8 +55,7 @@
 			this->spec.format = AUDIO_S16LSB;
 			break;
 		default:
-			SDL_SetError("Unsupported audio format");
-			return 0;
+			return SDL_SetError("Unsupported audio format");
 	}
 
 	/* The sample count must be a multiple of 64. */
@@ -86,8 +84,7 @@
 	mixlen = this->spec.size * NUM_BUFFERS;
 	this->hidden->rawbuf = (Uint8 *) memalign(64, mixlen);
 	if (this->hidden->rawbuf == NULL) {
-		SDL_SetError("Couldn't allocate mixing buffer");
-		return 0;
+		return SDL_SetError("Couldn't allocate mixing buffer");
 	}
 
 	/* Setup the hardware channel. */
@@ -98,10 +95,9 @@
 	}
 	this->hidden->channel = sceAudioChReserve(PSP_AUDIO_NEXT_CHANNEL, this->spec.samples, format);
 	if (this->hidden->channel < 0) {
-		SDL_SetError("Couldn't reserve hardware channel");
 		free(this->hidden->rawbuf);
 		this->hidden->rawbuf = NULL;
-		return 0;
+		return SDL_SetError("Couldn't reserve hardware channel");
 	}
 
 	memset(this->hidden->rawbuf, 0, mixlen);
@@ -110,7 +106,7 @@
 	}
 
 	this->hidden->next_buffer = 0;
-	return 1;
+	return 0;
 }
 
 static void PSPAUD_PlayDevice(_THIS)
--- a/src/audio/pulseaudio/SDL_pulseaudio.c	Sun Mar 31 12:48:50 2013 -0400
+++ b/src/audio/pulseaudio/SDL_pulseaudio.c	Sun Mar 31 13:05:40 2013 -0400
@@ -337,8 +337,7 @@
     this->hidden = (struct SDL_PrivateAudioData *)
         SDL_malloc((sizeof *this->hidden));
     if (this->hidden == NULL) {
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     SDL_memset(this->hidden, 0, (sizeof *this->hidden));
     h = this->hidden;
@@ -371,8 +370,7 @@
     }
     if (paspec.format == PA_SAMPLE_INVALID) {
         PULSEAUDIO_CloseDevice(this);
-        SDL_SetError("Couldn't find any hardware audio formats");
-        return 0;
+        return SDL_SetError("Couldn't find any hardware audio formats");
     }
     this->spec.format = test_format;
 
@@ -387,8 +385,7 @@
     h->mixbuf = (Uint8 *) SDL_AllocAudioMem(h->mixlen);
     if (h->mixbuf == NULL) {
         PULSEAUDIO_CloseDevice(this);
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     SDL_memset(h->mixbuf, this->spec.silence, this->spec.size);
 
@@ -419,36 +416,31 @@
     /* Set up a new main loop */
     if (!(h->mainloop = PULSEAUDIO_pa_mainloop_new())) {
         PULSEAUDIO_CloseDevice(this);
-        SDL_SetError("pa_mainloop_new() failed");
-        return 0;
+        return SDL_SetError("pa_mainloop_new() failed");
     }
 
     h->mainloop_api = PULSEAUDIO_pa_mainloop_get_api(h->mainloop);
     h->context = PULSEAUDIO_pa_context_new(h->mainloop_api, NULL);
     if (!h->context) {
         PULSEAUDIO_CloseDevice(this);
-        SDL_SetError("pa_context_new() failed");
-        return 0;
+        return SDL_SetError("pa_context_new() failed");
     }
 
     /* Connect to the PulseAudio server */
     if (PULSEAUDIO_pa_context_connect(h->context, NULL, 0, NULL) < 0) {
         PULSEAUDIO_CloseDevice(this);
-        SDL_SetError("Could not setup connection to PulseAudio");
-        return 0;
+        return SDL_SetError("Could not setup connection to PulseAudio");
     }
 
     do {
         if (PULSEAUDIO_pa_mainloop_iterate(h->mainloop, 1, NULL) < 0) {
             PULSEAUDIO_CloseDevice(this);
-            SDL_SetError("pa_mainloop_iterate() failed");
-            return 0;
+            return SDL_SetError("pa_mainloop_iterate() failed");
         }
         state = PULSEAUDIO_pa_context_get_state(h->context);
         if (!PA_CONTEXT_IS_GOOD(state)) {
             PULSEAUDIO_CloseDevice(this);
-            SDL_SetError("Could not connect to PulseAudio");
-            return 0;
+            return SDL_SetError("Could not connect to PulseAudio");
         }
     } while (state != PA_CONTEXT_READY);
 
@@ -461,33 +453,29 @@
 
     if (h->stream == NULL) {
         PULSEAUDIO_CloseDevice(this);
-        SDL_SetError("Could not set up PulseAudio stream");
-        return 0;
+        return SDL_SetError("Could not set up PulseAudio stream");
     }
 
     if (PULSEAUDIO_pa_stream_connect_playback(h->stream, NULL, &paattr, flags,
             NULL, NULL) < 0) {
         PULSEAUDIO_CloseDevice(this);
-        SDL_SetError("Could not connect PulseAudio stream");
-        return 0;
+        return SDL_SetError("Could not connect PulseAudio stream");
     }
 
     do {
         if (PULSEAUDIO_pa_mainloop_iterate(h->mainloop, 1, NULL) < 0) {
             PULSEAUDIO_CloseDevice(this);
-            SDL_SetError("pa_mainloop_iterate() failed");
-            return 0;
+            return SDL_SetError("pa_mainloop_iterate() failed");
         }
         state = PULSEAUDIO_pa_stream_get_state(h->stream);
         if (!PA_STREAM_IS_GOOD(state)) {
             PULSEAUDIO_CloseDevice(this);
-            SDL_SetError("Could not create to PulseAudio stream");
-            return 0;
+            return SDL_SetError("Could not create to PulseAudio stream");
         }
     } while (state != PA_STREAM_READY);
 
     /* We're ready to rock and roll. :-) */
-    return 1;
+    return 0;
 }
 
 
--- a/src/audio/qsa/SDL_qsa_audio.c	Sun Mar 31 12:48:50 2013 -0400
+++ b/src/audio/qsa/SDL_qsa_audio.c	Sun Mar 31 13:05:40 2013 -0400
@@ -83,10 +83,10 @@
 QSA_Device qsa_capture_device[QSA_MAX_DEVICES];
 uint32_t qsa_capture_devices;
 
-static inline void
+static inline int
 QSA_SetError(const char *fn, int status)
 {
-    SDL_SetError("QSA: %s() failed: %s", fn, snd_strerror(status));
+    return SDL_SetError("QSA: %s() failed: %s", fn, snd_strerror(status));
 }
 
 /* card names check to apply the workarounds */
@@ -183,13 +183,13 @@
         switch (selectret) {
         case -1:
             {
-                SDL_SetError("QSA: select() failed: %s\n", strerror(errno));
+                SDL_SetError("QSA: select() failed: %s", strerror(errno));
                 return;
             }
             break;
         case 0:
             {
-                SDL_SetError("QSA: timeout on buffer waiting occured\n");
+                SDL_SetError("QSA: timeout on buffer waiting occured");
                 this->hidden->timeout_on_wait = 1;
                 return;
             }
@@ -237,7 +237,7 @@
             /* the audio device driver */
             if ((errno == EAGAIN) && (written == 0)) {
                 if (this->hidden->timeout_on_wait != 0) {
-                    SDL_SetError("QSA: buffer playback timeout\n");
+                    SDL_SetError("QSA: buffer playback timeout");
                     return;
                 }
             }
@@ -355,8 +355,7 @@
                                                     (struct
                                                      SDL_PrivateAudioData)));
     if (this->hidden == NULL) {
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     SDL_memset(this->hidden, 0, sizeof(struct SDL_PrivateAudioData));
 
@@ -384,8 +383,7 @@
             device++;
             if (device >= qsa_playback_devices) {
                 QSA_CloseDevice(this);
-                SDL_SetError("No such playback device");
-                return 0;
+                return SDL_SetError("No such playback device");
             }
         } while (1);
     }
@@ -409,8 +407,7 @@
             device++;
             if (device >= qsa_capture_devices) {
                 QSA_CloseDevice(this);
-                SDL_SetError("No such capture device");
-                return 0;
+                return SDL_SetError("No such capture device");
             }
         } while (1);
     }
@@ -448,8 +445,7 @@
     if (status < 0) {
         this->hidden->audio_handle = NULL;
         QSA_CloseDevice(this);
-        QSA_SetError("snd_pcm_open", status);
-        return 0;
+        return QSA_SetError("snd_pcm_open", status);
     }
 
     if (!QSA_CheckBuggyCards(this, QSA_MMAP_WORKAROUND)) {
@@ -459,8 +455,7 @@
                                        PLUGIN_DISABLE_MMAP);
         if (status < 0) {
             QSA_CloseDevice(this);
-            QSA_SetError("snd_pcm_plugin_set_disable", status);
-            return 0;
+            return QSA_SetError("snd_pcm_plugin_set_disable", status);
         }
     }
 
@@ -546,8 +541,7 @@
     /* assumes test_format not 0 on success */
     if (test_format == 0) {
         QSA_CloseDevice(this);
-        SDL_SetError("QSA: Couldn't find any hardware audio formats");
-        return 0;
+        return SDL_SetError("QSA: Couldn't find any hardware audio formats");
     }
 
     this->spec.format = test_format;
@@ -565,8 +559,7 @@
     status = snd_pcm_plugin_params(this->hidden->audio_handle, &cparams);
     if (status < 0) {
         QSA_CloseDevice(this);
-        QSA_SetError("snd_pcm_channel_params", status);
-        return 0;
+        return QSA_SetError("snd_pcm_channel_params", status);
     }
 
     /* Make sure channel is setup right one last time */
@@ -580,8 +573,7 @@
     /* Setup an audio channel */
     if (snd_pcm_plugin_setup(this->hidden->audio_handle, &csetup) < 0) {
         QSA_CloseDevice(this);
-        SDL_SetError("QSA: Unable to setup channel\n");
-        return 0;
+        return SDL_SetError("QSA: Unable to setup channel");
     }
 
     /* Calculate the final parameters for this audio specification */
@@ -604,8 +596,7 @@
         (Uint8 *) SDL_AllocAudioMem(this->hidden->pcm_len);
     if (this->hidden->pcm_buf == NULL) {
         QSA_CloseDevice(this);
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     SDL_memset(this->hidden->pcm_buf, this->spec.silence,
                this->hidden->pcm_len);
@@ -623,8 +614,7 @@
 
     if (this->hidden->audio_fd < 0) {
         QSA_CloseDevice(this);
-        QSA_SetError("snd_pcm_file_descriptor", status);
-        return 0;
+        return QSA_SetError("snd_pcm_file_descriptor", status);
     }
 
     /* Prepare an audio channel */
@@ -642,12 +632,11 @@
 
     if (status < 0) {
         QSA_CloseDevice(this);
-        QSA_SetError("snd_pcm_plugin_prepare", status);
-        return 0;
+        return QSA_SetError("snd_pcm_plugin_prepare", status);
     }
 
     /* We're really ready to rock and roll. :-) */
-    return 1;
+    return 0;
 }
 
 static void
--- a/src/audio/sun/SDL_sunaudio.c	Sun Mar 31 12:48:50 2013 -0400
+++ b/src/audio/sun/SDL_sunaudio.c	Sun Mar 31 13:05:40 2013 -0400
@@ -213,8 +213,7 @@
     if (devname == NULL) {
         devname = SDL_GetAudioDeviceName(0, iscapture);
         if (devname == NULL) {
-            SDL_SetError("No such audio device");
-            return 0;
+            return SDL_SetError("No such audio device");
         }
     }
 
@@ -222,16 +221,14 @@
     this->hidden = (struct SDL_PrivateAudioData *)
         SDL_malloc((sizeof *this->hidden));
     if (this->hidden == NULL) {
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     SDL_memset(this->hidden, 0, (sizeof *this->hidden));
 
     /* Open the audio device */
     this->hidden->audio_fd = open(devname, flags, 0);
     if (this->hidden->audio_fd < 0) {
-        SDL_SetError("Couldn't open %s: %s", devname, strerror(errno));
-        return 0;
+        return SDL_SetError("Couldn't open %s: %s", devname, strerror(errno));
     }
 
 #ifdef AUDIO_SETINFO
@@ -263,8 +260,7 @@
     default:
         {
             /* !!! FIXME: fallback to conversion on unsupported types! */
-            SDL_SetError("Unsupported audio format");
-            return (-1);
+            return SDL_SetError("Unsupported audio format");
         }
     }
     this->hidden->audio_fmt = this->spec.format;
@@ -285,9 +281,8 @@
 
             /* Check to be sure we got what we wanted */
             if (ioctl(this->hidden->audio_fd, AUDIO_GETINFO, &info) < 0) {
-                SDL_SetError("Error getting audio parameters: %s",
-                             strerror(errno));
-                return -1;
+                return SDL_SetError("Error getting audio parameters: %s",
+                                    strerror(errno));
             }
             if (info.play.encoding == enc
                 && info.play.precision == (this->spec.format & 0xff)
@@ -316,9 +311,8 @@
 
         default:
             /* oh well... */
-            SDL_SetError("Error setting audio parameters: %s",
-                         strerror(errno));
-            return -1;
+            return SDL_SetError("Error setting audio parameters: %s",
+                                strerror(errno));
         }
     }
 #endif /* AUDIO_SETINFO */
@@ -357,7 +351,7 @@
     SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
 
     /* We're ready to rock and roll. :-) */
-    return (1);
+    return 0;
 }
 
 /************************************************************************/
--- a/src/audio/winmm/SDL_winmm.c	Sun Mar 31 12:48:50 2013 -0400
+++ b/src/audio/winmm/SDL_winmm.c	Sun Mar 31 13:05:40 2013 -0400
@@ -91,7 +91,7 @@
     ReleaseSemaphore(this->hidden->audio_sem, 1, NULL);
 }
 
-static void
+static int
 SetMMerror(char *function, MMRESULT code)
 {
     size_t len;
@@ -105,7 +105,7 @@
     WideCharToMultiByte(CP_ACP, 0, werrbuf, -1, errbuf + len,
                         MAXERRORLENGTH - len, NULL, NULL);
 
-    SDL_SetError("%s", errbuf);
+    return SDL_SetError("%s", errbuf);
 }
 
 static void
@@ -234,8 +234,7 @@
         }
 
         if (devId == WAVE_MAPPER) {
-            SDL_SetError("Requested device not found");
-            return 0;
+            return SDL_SetError("Requested device not found");
         }
     }
 
@@ -243,8 +242,7 @@
     this->hidden = (struct SDL_PrivateAudioData *)
         SDL_malloc((sizeof *this->hidden));
     if (this->hidden == NULL) {
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     SDL_memset(this->hidden, 0, (sizeof *this->hidden));
 
@@ -270,8 +268,7 @@
 
     if (!valid_datatype) {
         WINMM_CloseDevice(this);
-        SDL_SetError("Unsupported audio format");
-        return 0;
+        return SDL_SetError("Unsupported audio format");
     }
 
     /* Set basic WAVE format parameters */
@@ -309,8 +306,7 @@
 
     if (result != MMSYSERR_NOERROR) {
         WINMM_CloseDevice(this);
-        SetMMerror("waveOutOpen()", result);
-        return 0;
+        return SetMMerror("waveOutOpen()", result);
     }
 #ifdef SOUND_DEBUG
     /* Check the sound device we retrieved */
@@ -321,8 +317,7 @@
                                    &caps, sizeof(caps));
         if (result != MMSYSERR_NOERROR) {
             WINMM_CloseDevice(this);
-            SetMMerror("waveOutGetDevCaps()", result);
-            return 0;
+            return SetMMerror("waveOutGetDevCaps()", result);
         }
         printf("Audio device: %s\n", caps.szPname);
     }
@@ -333,8 +328,7 @@
         CreateSemaphore(NULL, NUM_BUFFERS - 1, NUM_BUFFERS, NULL);
     if (this->hidden->audio_sem == NULL) {
         WINMM_CloseDevice(this);
-        SDL_SetError("Couldn't create semaphore");
-        return 0;
+        return SDL_SetError("Couldn't create semaphore");
     }
 
     /* Create the sound buffers */
@@ -342,8 +336,7 @@
         (Uint8 *) SDL_malloc(NUM_BUFFERS * this->spec.size);
     if (this->hidden->mixbuf == NULL) {
         WINMM_CloseDevice(this);
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     for (i = 0; i < NUM_BUFFERS; ++i) {
         SDL_memset(&this->hidden->wavebuf[i], 0,
@@ -357,12 +350,11 @@
                                       sizeof(this->hidden->wavebuf[i]));
         if (result != MMSYSERR_NOERROR) {
             WINMM_CloseDevice(this);
-            SetMMerror("waveOutPrepareHeader()", result);
-            return 0;
+            return SetMMerror("waveOutPrepareHeader()", result);
         }
     }
 
-    return 1;                   /* Ready to go! */
+    return 0;                   /* Ready to go! */
 }
 
 
--- a/src/audio/xaudio2/SDL_xaudio2.c	Sun Mar 31 12:48:50 2013 -0400
+++ b/src/audio/xaudio2/SDL_xaudio2.c	Sun Mar 31 13:05:40 2013 -0400
@@ -245,11 +245,9 @@
 	static IXAudio2VoiceCallback callbacks = { &callbacks_vtable };
 
     if (iscapture) {
-        SDL_SetError("XAudio2: capture devices unsupported.");
-        return 0;
+        return SDL_SetError("XAudio2: capture devices unsupported.");
     } else if (XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR) != S_OK) {
-        SDL_SetError("XAudio2: XAudio2Create() failed.");
-        return 0;
+        return SDL_SetError("XAudio2: XAudio2Create() failed.");
     }
 
     if (devname != NULL) {
@@ -258,8 +256,7 @@
 
         if (IXAudio2_GetDeviceCount(ixa2, &devcount) != S_OK) {
             IXAudio2_Release(ixa2);
-            SDL_SetError("XAudio2: IXAudio2_GetDeviceCount() failed.");
-            return 0;
+            return SDL_SetError("XAudio2: IXAudio2_GetDeviceCount() failed.");
         }
         for (i = 0; i < devcount; i++) {
             XAUDIO2_DEVICE_DETAILS details;
@@ -278,8 +275,7 @@
 
         if (i == devcount) {
             IXAudio2_Release(ixa2);
-            SDL_SetError("XAudio2: Requested device not found.");
-            return 0;
+            return SDL_SetError("XAudio2: Requested device not found.");
         }
     }
 
@@ -288,8 +284,7 @@
         SDL_malloc((sizeof *this->hidden));
     if (this->hidden == NULL) {
         IXAudio2_Release(ixa2);
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     SDL_memset(this->hidden, 0, (sizeof *this->hidden));
 
@@ -297,8 +292,7 @@
     this->hidden->semaphore = CreateSemaphore(NULL, 1, 2, NULL);
     if (this->hidden->semaphore == NULL) {
         XAUDIO2_CloseDevice(this);
-        SDL_SetError("XAudio2: CreateSemaphore() failed!");
-        return 0;
+        return SDL_SetError("XAudio2: CreateSemaphore() failed!");
     }
 
     while ((!valid_format) && (test_format)) {
@@ -316,8 +310,7 @@
 
     if (!valid_format) {
         XAUDIO2_CloseDevice(this);
-        SDL_SetError("XAudio2: Unsupported audio format");
-        return 0;
+        return SDL_SetError("XAudio2: Unsupported audio format");
     }
 
     /* Update the fragment size as size in bytes */
@@ -328,8 +321,7 @@
     this->hidden->mixbuf = (Uint8 *) SDL_malloc(2 * this->hidden->mixlen);
     if (this->hidden->mixbuf == NULL) {
         XAUDIO2_CloseDevice(this);
-        SDL_OutOfMemory();
-        return 0;
+        return SDL_OutOfMemory();
     }
     this->hidden->nextbuf = this->hidden->mixbuf;
     SDL_memset(this->hidden->mixbuf, 0, 2 * this->hidden->mixlen);
@@ -345,8 +337,7 @@
                                            this->spec.freq, 0, devId, NULL);
     if (result != S_OK) {
         XAUDIO2_CloseDevice(this);
-        SDL_SetError("XAudio2: Couldn't create mastering voice");
-        return 0;
+        return SDL_SetError("XAudio2: Couldn't create mastering voice");
     }
 
     SDL_zero(waveformat);
@@ -369,8 +360,7 @@
                                         1.0f, &callbacks, NULL, NULL);
     if (result != S_OK) {
         XAUDIO2_CloseDevice(this);
-        SDL_SetError("XAudio2: Couldn't create source voice");
-        return 0;
+        return SDL_SetError("XAudio2: Couldn't create source voice");
     }
     this->hidden->source = source;
 
@@ -378,18 +368,16 @@
     result = IXAudio2_StartEngine(ixa2);
     if (result != S_OK) {
         XAUDIO2_CloseDevice(this);
-        SDL_SetError("XAudio2: Couldn't start engine");
-        return 0;
+        return SDL_SetError("XAudio2: Couldn't start engine");
     }
 
     result = IXAudio2SourceVoice_Start(source, 0, XAUDIO2_COMMIT_NOW);
     if (result != S_OK) {
         XAUDIO2_CloseDevice(this);
-        SDL_SetError("XAudio2: Couldn't start source voice");
-        return 0;
+        return SDL_SetError("XAudio2: Couldn't start source voice");
     }
 
-    return 1; /* good to go. */
+    return 0; /* good to go. */
 }
 
 static void