SDL_mixer: error returns and Mix_SetError clean-up.

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

---
 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 ed9263f0..b32af8ae 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;
                 }
 
@@ -401,12 +401,12 @@ SDL_AudioSpec *Mix_LoadVOC_RW (SDL_RWops *src, int 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 37e46954..f663050e 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 be253a1a..f7e3fd7a 100644
--- a/src/codecs/music_drflac.c
+++ b/src/codecs/music_drflac.c
@@ -265,8 +265,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 2ef6cb52..347611ef 100644
--- a/src/codecs/music_flac.c
+++ b/src/codecs/music_flac.c
@@ -316,7 +316,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;
     }
 
@@ -329,7 +329,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) {
@@ -485,19 +485,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;
     }
 }
@@ -512,7 +512,7 @@ static void *FLAC_CreateFromRW(SDL_RWops *src, int freesrc)
     int is_ogg_flac;
     Uint8 magic[4];
     if (SDL_RWread(src, magic, 1, 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, RW_SEEK_CUR);
@@ -556,13 +556,13 @@ static void *FLAC_CreateFromRW(SDL_RWops *src, int 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) {
@@ -645,17 +645,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) {
@@ -704,8 +702,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 d397bd14..7960cbaf 100644
--- a/src/codecs/music_fluidsynth.c
+++ b/src/codecs/music_fluidsynth.c
@@ -297,8 +297,7 @@ static int FLUIDSYNTH_GetSome(void *context, void *data, int bytes, SDL_bool *do
     }
 
     if (music->synth_write(music->synth, 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_AudioStreamPut(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 8bbf2a36..27696e8a 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;
@@ -266,7 +265,7 @@ static void *GME_CreateFromRW(struct SDL_RWops *src, int 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;
     }
@@ -396,17 +395,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 a1b483df..e7fade71 100644
--- a/src/codecs/music_mpg123.c
+++ b/src/codecs/music_mpg123.c
@@ -221,8 +221,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;
 }
@@ -392,8 +391,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",
@@ -436,8 +434,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 3c0c8ca3..e4d9e085 100644
--- a/src/codecs/music_ogg.c
+++ b/src/codecs/music_ogg.c
@@ -198,8 +198,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) {
@@ -257,7 +256,7 @@ static void *OGG_CreateFromRW(SDL_RWops *src, int 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;
     }
@@ -391,8 +390,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) {
@@ -407,8 +405,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) {
@@ -482,7 +479,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) {
@@ -491,7 +488,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) {
@@ -500,7 +497,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 5fef31de..ac96517e 100644
--- a/src/codecs/music_ogg_stb.c
+++ b/src/codecs/music_ogg_stb.c
@@ -343,8 +343,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) {
@@ -389,8 +388,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;
 }
@@ -408,7 +406,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) {
@@ -417,7 +415,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) {
@@ -426,7 +424,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 ec583680..8d53401d 100644
--- a/src/codecs/music_opus.c
+++ b/src/codecs/music_opus.c
@@ -172,8 +172,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) {
@@ -232,7 +231,7 @@ static void *OPUS_CreateFromRW(SDL_RWops *src, int 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;
     }
@@ -369,8 +368,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) {
@@ -385,8 +383,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 6386ee7e..9d038d71 100644
--- a/src/mixer.c
+++ b/src/mixer.c
@@ -1081,12 +1081,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 */
@@ -1162,8 +1160,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 57174308..620c4e08 100644
--- a/src/music.c
+++ b/src/music.c
@@ -946,14 +946,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 */