SDL_mixer: error returns and Mix_SetError clean-up. (9eae9)

From 9eae94f4de6008853ee0f081d79dd801e133f30a Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Mon, 15 Jan 2024 20:40:04 +0300
Subject: [PATCH] error returns and Mix_SetError clean-up.

(cherry picked from commit 491bb53d2cb8792f6d888f84ea736c6e4b945412)
---
 src/codecs/load_voc.c         | 26 +++++++++++++-------------
 src/codecs/music_cmd.c        |  3 +--
 src/codecs/music_drflac.c     |  3 +--
 src/codecs/music_flac.c       | 31 ++++++++++++++-----------------
 src/codecs/music_fluidsynth.c |  3 +--
 src/codecs/music_gme.c        | 14 ++++----------
 src/codecs/music_mpg123.c     |  9 +++------
 src/codecs/music_ogg.c        | 17 +++++++----------
 src/codecs/music_ogg_stb.c    | 12 +++++-------
 src/codecs/music_opus.c       | 11 ++++-------
 src/mixer.c                   |  9 +++------
 src/music.c                   |  6 ++----
 12 files changed, 58 insertions(+), 86 deletions(-)

diff --git a/src/codecs/load_voc.c b/src/codecs/load_voc.c
index 82f21cd8..50ae5f88 100644
--- a/src/codecs/load_voc.c
+++ b/src/codecs/load_voc.c
@@ -93,7 +93,7 @@ static int voc_check_header(SDL_RWops *src)
     }
 
     if (SDL_memcmp(signature, "Creative Voice File\032", sizeof(signature)) != 0) {
-        SDL_SetError("Unrecognized file type (not VOC)");
+        Mix_SetError("Unrecognized file type (not VOC)");
         return 0;
     }
 
@@ -151,12 +151,12 @@ static int voc_get_block(SDL_RWops *src, vs_t *v, SDL_AudioSpec *spec)
                 /* block, the DATA blocks rate value is invalid */
                 if (!v->has_extended) {
                     if (uc == 0) {
-                        SDL_SetError("VOC Sample rate is zero?");
+                        Mix_SetError("VOC Sample rate is zero?");
                         return 0;
                     }
 
                     if ((v->rate != VOC_BAD_RATE) && (uc != v->rate)) {
-                        SDL_SetError("VOC sample rate codes differ");
+                        Mix_SetError("VOC sample rate codes differ");
                         return 0;
                     }
 
@@ -170,7 +170,7 @@ static int voc_get_block(SDL_RWops *src, vs_t *v, SDL_AudioSpec *spec)
                 }
 
                 if (uc != 0) {
-                    SDL_SetError("VOC decoder only interprets 8-bit data");
+                    Mix_SetError("VOC decoder only interprets 8-bit data");
                     return 0;
                 }
 
@@ -185,11 +185,11 @@ static int voc_get_block(SDL_RWops *src, vs_t *v, SDL_AudioSpec *spec)
                 }
                 new_rate_long = SDL_SwapLE32(new_rate_long);
                 if (new_rate_long == 0) {
-                    SDL_SetError("VOC Sample rate is zero?");
+                    Mix_SetError("VOC Sample rate is zero?");
                     return 0;
                 }
                 if ((v->rate != VOC_BAD_RATE) && (new_rate_long != v->rate)) {
-                    SDL_SetError("VOC sample rate codes differ");
+                    Mix_SetError("VOC sample rate codes differ");
                     return 0;
                 }
                 v->rate = new_rate_long;
@@ -203,7 +203,7 @@ static int voc_get_block(SDL_RWops *src, vs_t *v, SDL_AudioSpec *spec)
                     case 8:  v->size = ST_SIZE_BYTE; break;
                     case 16: v->size = ST_SIZE_WORD; break;
                     default:
-                        SDL_SetError("VOC with unknown data size");
+                        Mix_SetError("VOC with unknown data size");
                         return 0;
                 }
 
@@ -232,7 +232,7 @@ static int voc_get_block(SDL_RWops *src, vs_t *v, SDL_AudioSpec *spec)
                     return 0;
                 }
                 if (uc == 0) {
-                    SDL_SetError("VOC silence sample rate is zero");
+                    Mix_SetError("VOC silence sample rate is zero");
                     return 0;
                 }
 
@@ -269,11 +269,11 @@ static int voc_get_block(SDL_RWops *src, vs_t *v, SDL_AudioSpec *spec)
                 }
                 new_rate_short = SDL_SwapLE16(new_rate_short);
                 if (new_rate_short == 0) {
-                   SDL_SetError("VOC sample rate is zero");
+                   Mix_SetError("VOC sample rate is zero");
                    return 0;
                 }
                 if ((v->rate != VOC_BAD_RATE) && (new_rate_short != v->rate)) {
-                   SDL_SetError("VOC sample rate codes differ");
+                   Mix_SetError("VOC sample rate codes differ");
                    return 0;
                 }
                 v->rate = new_rate_short;
@@ -283,7 +283,7 @@ static int voc_get_block(SDL_RWops *src, vs_t *v, SDL_AudioSpec *spec)
                 }
 
                 if (uc != 0) {
-                    SDL_SetError("VOC decoder only interprets 8-bit data");
+                    Mix_SetError("VOC decoder only interprets 8-bit data");
                     return 0;
                 }
 
@@ -419,12 +419,12 @@ SDL_AudioSpec *Mix_LoadVOC_RW (SDL_RWops *src, SDL_bool freesrc,
     }
 
     if (v.rate == VOC_BAD_RATE) {
-        SDL_SetError("VOC data had no sound!");
+        Mix_SetError("VOC data had no sound!");
         goto done;
     }
 
     if (v.size == 0) {
-        SDL_SetError("VOC data had invalid word size!");
+        Mix_SetError("VOC data had invalid word size!");
         goto done;
     }
 
diff --git a/src/codecs/music_cmd.c b/src/codecs/music_cmd.c
index 10441be4..9a274f87 100644
--- a/src/codecs/music_cmd.c
+++ b/src/codecs/music_cmd.c
@@ -168,8 +168,7 @@ static int MusicCMD_Play(void *context, int play_count)
     switch(music->pid) {
     /* Failed fork() system call */
     case -1:
-        Mix_SetError("fork() failed");
-        return -1;
+        return Mix_SetError("fork() failed");
 
     /* Child process - executes here */
     case 0: {
diff --git a/src/codecs/music_drflac.c b/src/codecs/music_drflac.c
index 85f2517f..eed68c47 100644
--- a/src/codecs/music_drflac.c
+++ b/src/codecs/music_drflac.c
@@ -264,8 +264,7 @@ static int DRFLAC_GetSome(void *context, void *data, int bytes, SDL_bool *done)
 
     if (music->loop_flag) {
         if (!drflac_seek_to_pcm_frame(music->dec, music->loop_start)) {
-            SDL_SetError("drflac_seek_to_pcm_frame() failed");
-            return -1;
+            return Mix_SetError("drflac_seek_to_pcm_frame() failed");
         } else {
             int play_count = -1;
             if (music->play_count > 0) {
diff --git a/src/codecs/music_flac.c b/src/codecs/music_flac.c
index 60ab6eb4..5c2c3f8c 100644
--- a/src/codecs/music_flac.c
+++ b/src/codecs/music_flac.c
@@ -318,7 +318,7 @@ static FLAC__StreamDecoderWriteStatus flac_write_music_cb(
         shift_amount = 8;
         break;
     default:
-        SDL_SetError("FLAC decoder doesn't support %d bits_per_sample", music->bits_per_sample);
+        Mix_SetError("FLAC decoder doesn't support %d bits_per_sample", music->bits_per_sample);
         return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
     }
 
@@ -331,7 +331,7 @@ static FLAC__StreamDecoderWriteStatus flac_write_music_cb(
 
     data = SDL_stack_alloc(Sint16, (frame->header.blocksize * channels));
     if (!data) {
-        SDL_SetError("Couldn't allocate %d bytes stack memory", (int)(frame->header.blocksize * channels * sizeof(*data)));
+        Mix_SetError("Couldn't allocate %d bytes stack memory", (int)(frame->header.blocksize * channels * sizeof(*data)));
         return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
     }
     if (music->channels == 3) {
@@ -491,19 +491,19 @@ static void flac_error_music_cb(
     /* print an SDL error based on the error status */
     switch (status) {
     case FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC:
-        SDL_SetError("Error processing the FLAC file [LOST_SYNC].");
+        Mix_SetError("Error processing the FLAC file [LOST_SYNC].");
         break;
     case FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER:
-        SDL_SetError("Error processing the FLAC file [BAD_HEADER].");
+        Mix_SetError("Error processing the FLAC file [BAD_HEADER].");
         break;
     case FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH:
-        SDL_SetError("Error processing the FLAC file [CRC_MISMATCH].");
+        Mix_SetError("Error processing the FLAC file [CRC_MISMATCH].");
         break;
     case FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM:
-        SDL_SetError("Error processing the FLAC file [UNPARSEABLE].");
+        Mix_SetError("Error processing the FLAC file [UNPARSEABLE].");
         break;
     default:
-        SDL_SetError("Error processing the FLAC file [UNKNOWN].");
+        Mix_SetError("Error processing the FLAC file [UNKNOWN].");
         break;
     }
 }
@@ -518,7 +518,7 @@ static void *FLAC_CreateFromRW(SDL_RWops *src, SDL_bool freesrc)
     int is_ogg_flac;
     Uint8 magic[4];
     if (SDL_RWread(src, magic, 4) != 4) {
-        SDL_SetError("Couldn't read first 4 bytes of audio data");
+        Mix_SetError("Couldn't read first 4 bytes of audio data");
         return NULL;
     }
     SDL_RWseek(src, -4, SDL_RW_SEEK_CUR);
@@ -562,13 +562,13 @@ static void *FLAC_CreateFromRW(SDL_RWops *src, SDL_bool freesrc)
             if (flac.FLAC__stream_decoder_process_until_end_of_metadata(music->flac_decoder)) {
                 was_error = 0;
             } else {
-                SDL_SetError("FLAC__stream_decoder_process_until_end_of_metadata() failed");
+                Mix_SetError("FLAC__stream_decoder_process_until_end_of_metadata() failed");
             }
         } else {
-            SDL_SetError("FLAC__stream_decoder_init_stream() failed");
+            Mix_SetError("FLAC__stream_decoder_init_stream() failed");
         }
     } else {
-        SDL_SetError("FLAC__stream_decoder_new() failed");
+        Mix_SetError("FLAC__stream_decoder_new() failed");
     }
 
     if (was_error) {
@@ -651,17 +651,15 @@ static int FLAC_GetSome(void *context, void *data, int bytes, SDL_bool *done)
     }
 
     if (!flac.FLAC__stream_decoder_process_single(music->flac_decoder)) {
-        SDL_SetError("FLAC__stream_decoder_process_single() failed");
-        return -1;
+        return Mix_SetError("FLAC__stream_decoder_process_single() failed");
     }
 
     if (music->loop_flag) {
         music->pcm_pos = music->loop_start;
         if (flac.FLAC__stream_decoder_seek_absolute(music->flac_decoder, (FLAC__uint64)music->loop_start) ==
                 FLAC__STREAM_DECODER_SEEK_ERROR) {
-            SDL_SetError("FLAC__stream_decoder_seek_absolute() failed");
             flac.FLAC__stream_decoder_flush(music->flac_decoder);
-            return -1;
+            return Mix_SetError("FLAC__stream_decoder_seek_absolute() failed");
         } else {
             int play_count = -1;
             if (music->play_count > 0) {
@@ -710,8 +708,7 @@ static int FLAC_Seek(void *context, double position)
             flac.FLAC__stream_decoder_flush(music->flac_decoder);
         }
 
-        SDL_SetError("Seeking of FLAC stream failed: libFLAC seek failed.");
-        return -1;
+        return Mix_SetError("Seeking of FLAC stream failed: libFLAC seek failed.");
     }
     return 0;
 }
diff --git a/src/codecs/music_fluidsynth.c b/src/codecs/music_fluidsynth.c
index c3800a2a..aeb6e784 100644
--- a/src/codecs/music_fluidsynth.c
+++ b/src/codecs/music_fluidsynth.c
@@ -300,8 +300,7 @@ static int FLUIDSYNTH_GetSome(void *context, void *data, int bytes, SDL_bool *do
     }
 
     if (music->synth_write(music->synth, 4096/*music_spec.samples*/, music->buffer, 0, 2, music->buffer, 1, 2) != FLUID_OK) {
-        Mix_SetError("Error generating FluidSynth audio");
-        return -1;
+        return Mix_SetError("Error generating FluidSynth audio");
     }
     if (SDL_PutAudioStreamData(music->stream, music->buffer, music->buffer_size) < 0) {
         return -1;
diff --git a/src/codecs/music_gme.c b/src/codecs/music_gme.c
index c0e939e6..43b1921c 100644
--- a/src/codecs/music_gme.c
+++ b/src/codecs/music_gme.c
@@ -161,8 +161,7 @@ static int initialize_from_track_info(GME_Music *music, int track)
 
     err = gme.gme_track_info(music->game_emu, &musInfo, track);
     if (err != 0) {
-        Mix_SetError("GME: %s", err);
-        return -1;
+        return Mix_SetError("GME: %s", err);
     }
 
     music->track_length = musInfo->length;
@@ -269,7 +268,7 @@ static void *GME_CreateFromRW(struct SDL_RWops *src, SDL_bool freesrc)
     music->volume = MIX_MAX_VOLUME;
 
     meta_tags_init(&music->tags);
-    if (initialize_from_track_info(music, 0) == -1) {
+    if (initialize_from_track_info(music, 0) < 0) {
         GME_Delete(music);
         return NULL;
     }
@@ -399,17 +398,12 @@ static int GME_StartTrack(void *music_p, int track)
 
     err = gme.gme_start_track(music->game_emu, track);
     if (err != 0) {
-        Mix_SetError("GME: %s", err);
-        return -1;
+        return Mix_SetError("GME: %s", err);
     }
 
     GME_Play(music, music->play_count);
 
-    if (initialize_from_track_info(music, track) == -1) {
-        return -1;
-    }
-
-    return 0;
+    return initialize_from_track_info(music, track);
 }
 
 
diff --git a/src/codecs/music_mpg123.c b/src/codecs/music_mpg123.c
index cbf6a0de..36437e41 100644
--- a/src/codecs/music_mpg123.c
+++ b/src/codecs/music_mpg123.c
@@ -225,8 +225,7 @@ static int MPG123_Open(const SDL_AudioSpec *spec)
 {
     (void)spec;
     if (mpg123.mpg123_init() != MPG123_OK) {
-        Mix_SetError("mpg123_init() failed");
-        return -1;
+        return Mix_SetError("mpg123_init() failed");
     }
     return 0;
 }
@@ -399,8 +398,7 @@ static int MPG123_GetSome(void *context, void *data, int bytes, SDL_bool *done)
     case MPG123_NEW_FORMAT:
         result = mpg123.mpg123_getformat(music->handle, &rate, &channels, &encoding);
         if (result != MPG123_OK) {
-            Mix_SetError("mpg123_getformat: %s", mpg_err(music->handle, result));
-            return -1;
+            return Mix_SetError("mpg123_getformat: %s", mpg_err(music->handle, result));
         }
 #ifdef DEBUG_MPG123
         printf("MPG123 format: %s, channels: %d, rate: %ld\n",
@@ -445,8 +443,7 @@ static int MPG123_GetSome(void *context, void *data, int bytes, SDL_bool *done)
         }
         break;
     default:
-        Mix_SetError("mpg123_read: %s", mpg_err(music->handle, result));
-        return -1;
+        return Mix_SetError("mpg123_read: %s", mpg_err(music->handle, result));
     }
     return 0;
 }
diff --git a/src/codecs/music_ogg.c b/src/codecs/music_ogg.c
index b5465a40..f496e219 100644
--- a/src/codecs/music_ogg.c
+++ b/src/codecs/music_ogg.c
@@ -202,8 +202,7 @@ static int OGG_UpdateSection(OGG_music *music)
 
     vi = vorbis.ov_info(&music->vf, -1);
     if (!vi) {
-        Mix_SetError("ov_info returned NULL");
-        return -1;
+        return Mix_SetError("ov_info returned NULL");
     }
 
     if (vi->channels == music->vi.channels && vi->rate == music->vi.rate) {
@@ -263,7 +262,7 @@ static void *OGG_CreateFromRW(SDL_RWops *src, SDL_bool freesrc)
     callbacks.tell_func = sdl_tell_func;
 
     if (vorbis.ov_open_callbacks(src, &music->vf, NULL, 0, callbacks) < 0) {
-        SDL_SetError("Not an Ogg Vorbis audio stream");
+        Mix_SetError("Not an Ogg Vorbis audio stream");
         SDL_free(music);
         return NULL;
     }
@@ -397,8 +396,7 @@ static int OGG_GetSome(void *context, void *data, int bytes, SDL_bool *done)
     amount = (int)vorbis.ov_read(&music->vf, music->buffer, music->buffer_size, SDL_BYTEORDER == SDL_BIG_ENDIAN, 2, 1, &section);
 #endif
     if (amount < 0) {
-        set_ov_error("ov_read", amount);
-        return -1;
+        return set_ov_error("ov_read", amount);
     }
 
     if (section != music->section) {
@@ -413,8 +411,7 @@ static int OGG_GetSome(void *context, void *data, int bytes, SDL_bool *done)
         amount -= (int)((pcmPos - music->loop_end) * music->vi.channels) * (int)sizeof(Sint16);
         result = vorbis.ov_pcm_seek(&music->vf, music->loop_start);
         if (result < 0) {
-            set_ov_error("ov_pcm_seek", result);
-            return -1;
+            return set_ov_error("ov_pcm_seek", result);
         } else {
             int play_count = -1;
             if (music->play_count > 0) {
@@ -488,7 +485,7 @@ static double OGG_Duration(void *context)
 #endif
 }
 
-static double   OGG_LoopStart(void *music_p)
+static double OGG_LoopStart(void *music_p)
 {
     OGG_music *music = (OGG_music *)music_p;
     if (music->loop > 0) {
@@ -497,7 +494,7 @@ static double   OGG_LoopStart(void *music_p)
     return -1.0;
 }
 
-static double   OGG_LoopEnd(void *music_p)
+static double OGG_LoopEnd(void *music_p)
 {
     OGG_music *music = (OGG_music *)music_p;
     if (music->loop > 0) {
@@ -506,7 +503,7 @@ static double   OGG_LoopEnd(void *music_p)
     return -1.0;
 }
 
-static double   OGG_LoopLength(void *music_p)
+static double OGG_LoopLength(void *music_p)
 {
     OGG_music *music = (OGG_music *)music_p;
     if (music->loop > 0) {
diff --git a/src/codecs/music_ogg_stb.c b/src/codecs/music_ogg_stb.c
index 8b11b89a..60245b6d 100644
--- a/src/codecs/music_ogg_stb.c
+++ b/src/codecs/music_ogg_stb.c
@@ -346,8 +346,7 @@ static int OGG_GetSome(void *context, void *data, int bytes, SDL_bool *done)
         amount -= (int)((pcmPos - music->loop_end) * music->vi.channels) * (int)sizeof(float);
         result = stb_vorbis_seek(music->vf, (Uint32)music->loop_start);
         if (!result) {
-            set_ov_error("stb_vorbis_seek", stb_vorbis_get_error(music->vf));
-            return -1;
+            return set_ov_error("stb_vorbis_seek", stb_vorbis_get_error(music->vf));
         } else {
             int play_count = -1;
             if (music->play_count > 0) {
@@ -392,8 +391,7 @@ static int OGG_Seek(void *context, double time)
 
     result = stb_vorbis_seek(music->vf, (unsigned int)(time * music->vi.sample_rate));
     if (!result) {
-        set_ov_error("stb_vorbis_seek", stb_vorbis_get_error(music->vf));
-        return -1;
+        return set_ov_error("stb_vorbis_seek", stb_vorbis_get_error(music->vf));
     }
     return 0;
 }
@@ -411,7 +409,7 @@ static double OGG_Duration(void *context)
     return (double)music->full_length / music->vi.sample_rate;
 }
 
-static double   OGG_LoopStart(void *music_p)
+static double OGG_LoopStart(void *music_p)
 {
     OGG_music *music = (OGG_music *)music_p;
     if (music->loop > 0) {
@@ -420,7 +418,7 @@ static double   OGG_LoopStart(void *music_p)
     return -1.0;
 }
 
-static double   OGG_LoopEnd(void *music_p)
+static double OGG_LoopEnd(void *music_p)
 {
     OGG_music *music = (OGG_music *)music_p;
     if (music->loop > 0) {
@@ -429,7 +427,7 @@ static double   OGG_LoopEnd(void *music_p)
     return -1.0;
 }
 
-static double   OGG_LoopLength(void *music_p)
+static double OGG_LoopLength(void *music_p)
 {
     OGG_music *music = (OGG_music *)music_p;
     if (music->loop > 0) {
diff --git a/src/codecs/music_opus.c b/src/codecs/music_opus.c
index 01f9df9c..8eeae4ba 100644
--- a/src/codecs/music_opus.c
+++ b/src/codecs/music_opus.c
@@ -173,8 +173,7 @@ static int OPUS_UpdateSection(OPUS_music *music)
 
     op_info = opus.op_head(music->of, -1);
     if (!op_info) {
-        Mix_SetError("op_head returned NULL");
-        return -1;
+        return Mix_SetError("op_head returned NULL");
     }
 
     if (music->op_info && op_info->channel_count == music->op_info->channel_count) {
@@ -235,7 +234,7 @@ static void *OPUS_CreateFromRW(SDL_RWops *src, SDL_bool freesrc)
     music->of = opus.op_open_callbacks(src, &callbacks, NULL, 0, &err);
     if (music->of == NULL) {
     /*  set_op_error("op_open_callbacks", err);*/
-        SDL_SetError("Not an Opus audio stream");
+        Mix_SetError("Not an Opus audio stream");
         SDL_free(music);
         return NULL;
     }
@@ -372,8 +371,7 @@ static int OPUS_GetSome(void *context, void *data, int bytes, SDL_bool *done)
     section = music->section;
     samples = opus.op_read(music->of, (opus_int16 *)music->buffer, music->buffer_size / (int)sizeof(opus_int16), &section);
     if (samples < 0) {
-        set_op_error("op_read", samples);
-        return -1;
+        return set_op_error("op_read", samples);
     }
 
     if (section != music->section) {
@@ -388,8 +386,7 @@ static int OPUS_GetSome(void *context, void *data, int bytes, SDL_bool *done)
         samples -= (int)((pcmPos - music->loop_end) * music->op_info->channel_count) * (int)sizeof(Sint16);
         result = opus.op_pcm_seek(music->of, music->loop_start);
         if (result < 0) {
-            set_op_error("ov_pcm_seek", result);
-            return -1;
+            return set_op_error("ov_pcm_seek", result);
         } else {
             int play_count = -1;
             if (music->play_count > 0) {
diff --git a/src/mixer.c b/src/mixer.c
index 843e796e..340731f8 100644
--- a/src/mixer.c
+++ b/src/mixer.c
@@ -1062,12 +1062,10 @@ int Mix_PlayChannelTimed(int which, Mix_Chunk *chunk, int loops, int ticks)
 
     /* Don't play null pointers :-) */
     if (chunk == NULL) {
-        Mix_SetError("Tried to play a NULL chunk");
-        return -1;
+        return Mix_SetError("Tried to play a NULL chunk");
     }
     if (!checkchunkintegral(chunk)) {
-        Mix_SetError("Tried to play a chunk with a bad frame");
-        return -1;
+        return Mix_SetError("Tried to play a chunk with a bad frame");
     }
 
     /* Lock the mixer while modifying the playing channels */
@@ -1143,8 +1141,7 @@ int Mix_FadeInChannelTimed(int which, Mix_Chunk *chunk, int loops, int ms, int t
         return -1;
     }
     if (!checkchunkintegral(chunk)) {
-        Mix_SetError("Tried to play a chunk with a bad frame");
-        return -1;
+        return Mix_SetError("Tried to play a chunk with a bad frame");
     }
 
     /* Lock the mixer while modifying the playing channels */
diff --git a/src/music.c b/src/music.c
index 51712e4f..fd0a2d37 100644
--- a/src/music.c
+++ b/src/music.c
@@ -947,14 +947,12 @@ int Mix_FadeInMusicPos(Mix_Music *music, int loops, int ms, double position)
     int retval;
 
     if (ms_per_step == 0) {
-        Mix_SetError("Audio device hasn't been opened");
-        return -1;
+        return Mix_SetError("Audio device hasn't been opened");
     }
 
     /* Don't play null pointers :-) */
     if (music == NULL) {
-        Mix_SetError("music parameter was NULL");
-        return -1;
+        return Mix_SetError("music parameter was NULL");
     }
 
     /* Setup the data */