SDL_mixer: style clean-up.

From e23a8d3f51a41b7c4ce6138bb832252e4d76ad64 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Mon, 15 Jan 2024 17:00:20 +0300
Subject: [PATCH] style clean-up.

---
 playmus.c                                   |  31 +--
 playwave.c                                  |  21 +-
 src/codecs/load_aiff.c                      |  13 +-
 src/codecs/load_voc.c                       | 185 ++++++++---------
 src/codecs/music_cmd.c                      |   6 +-
 src/codecs/music_flac.c                     |   2 +-
 src/codecs/native_midi/native_midi_common.c | 152 +++++++-------
 src/effect_position.c                       | 130 ++++++------
 src/effect_stereoreverse.c                  |  16 +-
 src/effects_internal.c                      |   6 +-
 src/mixer.c                                 | 212 ++++++++++----------
 src/music.c                                 |  36 ++--
 12 files changed, 402 insertions(+), 408 deletions(-)

diff --git a/playmus.c b/playmus.c
index 17456ac8..bd59e5c8 100644
--- a/playmus.c
+++ b/playmus.c
@@ -75,7 +75,7 @@ void Menu(void)
     printf("Available commands: (p)ause (r)esume (h)alt volume(v#) > ");
     fflush(stdin);
     if (scanf("%s",buf) == 1) {
-        switch(buf[0]){
+        switch(buf[0]) {
 #if defined(SEEK_TEST)
         case '0': Mix_SetMusicPosition(0); break;
         case '1': Mix_SetMusicPosition(10);break;
@@ -105,9 +105,9 @@ void Menu(void)
 void IntHandler(int sig)
 {
     switch (sig) {
-            case SIGINT:
-            next_track++;
-            break;
+    case SIGINT:
+        next_track++;
+        break;
     }
 }
 #endif
@@ -139,7 +139,7 @@ int main(int argc, char *argv[])
     audio_buffers = 4096;
 
     /* Check command line usage */
-    for (i=1; argv[i] && (*argv[i] == '-'); ++i) {
+    for (i = 1; argv[i] && (*argv[i] == '-'); ++i) {
         if ((strcmp(argv[i], "-r") == 0) && argv[i+1]) {
             ++i;
             audio_rate = atoi(argv[i]);
@@ -175,18 +175,18 @@ int main(int argc, char *argv[])
             rwops = 1;
         } else {
             Usage(argv[0]);
-            return(1);
+            return 1;
         }
     }
-    if (! argv[i]) {
+    if (!argv[i]) {
         Usage(argv[0]);
-        return(1);
+        return 1;
     }
 
     /* Initialize the SDL library */
     if (SDL_Init(SDL_INIT_AUDIO) < 0) {
         SDL_Log("Couldn't initialize SDL: %s\n",SDL_GetError());
-        return(255);
+        return 255;
     }
 
 #ifdef HAVE_SIGNAL_H
@@ -197,7 +197,7 @@ int main(int argc, char *argv[])
     /* Open the audio device */
     if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) < 0) {
         SDL_Log("Couldn't open audio: %s\n", SDL_GetError());
-        return(2);
+        return 2;
     } else {
         Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
         SDL_Log("Opened audio at %d Hz %d bit%s %s %d bytes audio buffer\n", audio_rate,
@@ -224,8 +224,7 @@ int main(int argc, char *argv[])
             music = Mix_LoadMUS(argv[i]);
         }
         if (music == NULL) {
-            SDL_Log("Couldn't load %s: %s\n",
-                argv[i], SDL_GetError());
+            SDL_Log("Couldn't load %s: %s\n", argv[i], SDL_GetError());
             CleanUp(2);
         }
 
@@ -297,9 +296,9 @@ int main(int argc, char *argv[])
         }
         Mix_FadeInMusic(music,looping,2000);
         while (!next_track && (Mix_PlayingMusic() || Mix_PausedMusic())) {
-            if(interactive)
+            if (interactive) {
                 Menu();
-            else {
+            } else {
                 current_position = Mix_GetMusicPosition(music);
                 if (current_position >= 0.0) {
                     printf("Position: %g seconds             \r", current_position);
@@ -313,7 +312,9 @@ int main(int argc, char *argv[])
 
         /* If the user presses Ctrl-C more than once, exit. */
         SDL_Delay(500);
-        if (next_track > 1) break;
+        if (next_track > 1) {
+            break;
+        }
 
         i++;
     }
diff --git a/playwave.c b/playwave.c
index 4b88b00a..8cb5574f 100644
--- a/playwave.c
+++ b/playwave.c
@@ -148,9 +148,9 @@ static void SDLCALL channel_complete_callback (int chan)
 static int still_playing(void)
 {
 #ifdef TEST_MIX_CHANNELFINISHED
-    return(!channel_is_done);
+    return !channel_is_done;
 #else
-    return(Mix_Playing(0));
+    return Mix_Playing(0);
 #endif
 }
 
@@ -165,7 +165,7 @@ static void do_panning_update(void)
     static int panningok = 1;
     static Uint32 next_panning_update = 0;
 
-    if ((panningok) && (SDL_GetTicks() >= next_panning_update)) {
+    if (panningok && (SDL_GetTicks() >= next_panning_update)) {
         panningok = Mix_SetPanning(0, leftvol, rightvol);
         if (!panningok) {
             SDL_Log("Mix_SetPanning(0, %d, %d) failed!\n",
@@ -236,7 +236,7 @@ static void do_position_update(void)
     static int positionok = 1;
     static Uint32 next_position_update = 0;
 
-    if ((positionok) && (SDL_GetTicks() >= next_position_update)) {
+    if (positionok && (SDL_GetTicks() >= next_position_update)) {
         positionok = Mix_SetPosition(0, angle, (Uint8)distance);
         if (!positionok) {
             SDL_Log("Mix_SetPosition(0, %d, %d) failed!\n",
@@ -380,7 +380,7 @@ int main(int argc, char *argv[])
     audio_channels = MIX_DEFAULT_CHANNELS;
 
     /* Check command line usage */
-    for (i=1; argv[i] && (*argv[i] == '-'); ++i) {
+    for (i = 1; argv[i] && (*argv[i] == '-'); ++i) {
         if ((strcmp(argv[i], "-r") == 0) && argv[i+1]) {
             ++i;
             audio_rate = atoi(argv[i]);
@@ -408,18 +408,18 @@ int main(int argc, char *argv[])
             reverse_sample = 1;
         } else {
             Usage(argv[0]);
-            return(1);
+            return 1;
         }
     }
-    if (! argv[i]) {
+    if (!argv[i]) {
         Usage(argv[0]);
-        return(1);
+        return 1;
     }
 
     /* Initialize the SDL library */
     if (SDL_Init(SDL_INIT_AUDIO) < 0) {
         SDL_Log("Couldn't initialize SDL: %s\n",SDL_GetError());
-        return(255);
+        return 255;
     }
 #ifdef HAVE_SIGNAL_H
     signal(SIGINT, CleanUp);
@@ -456,8 +456,7 @@ int main(int argc, char *argv[])
     /* Load the requested wave file */
     wave = Mix_LoadWAV(argv[i]);
     if (wave == NULL) {
-        SDL_Log("Couldn't load %s: %s\n",
-                        argv[i], SDL_GetError());
+        SDL_Log("Couldn't load %s: %s\n", argv[i], SDL_GetError());
         CleanUp(2);
     }
 
diff --git a/src/codecs/load_aiff.c b/src/codecs/load_aiff.c
index 4b91685a..4bb624e5 100644
--- a/src/codecs/load_aiff.c
+++ b/src/codecs/load_aiff.c
@@ -65,11 +65,11 @@ static Uint32 SANE_to_Uint32 (Uint8 *sanebuf)
 SDL_AudioSpec *Mix_LoadAIFF_RW (SDL_RWops *src, int freesrc,
     SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
 {
-    int was_error;
     int found_SSND;
     int found_COMM;
     int found_VHDR;
     int found_BODY;
+    int was_error = 0;
     Sint64 start = 0;
 
     Uint32 chunk_type;
@@ -92,7 +92,6 @@ SDL_AudioSpec *Mix_LoadAIFF_RW (SDL_RWops *src, int freesrc,
     Uint32 frequency = 0;
 
     /* Make sure we are passed a valid data source */
-    was_error = 0;
     if (src == NULL) {
         was_error = 1;
         goto done;
@@ -124,9 +123,11 @@ SDL_AudioSpec *Mix_LoadAIFF_RW (SDL_RWops *src, int freesrc,
         chunk_type  = SDL_ReadLE32(src);
         chunk_length = SDL_ReadBE32(src);
         next_chunk  = SDL_RWtell(src) + chunk_length;
+
         /* Paranoia to avoid infinite loops */
-        if (chunk_length == 0)
+        if (chunk_length == 0) {
             break;
+        }
 
         switch (chunk_type) {
             case SSND:
@@ -223,12 +224,12 @@ SDL_AudioSpec *Mix_LoadAIFF_RW (SDL_RWops *src, int freesrc,
     *audio_buf = (Uint8 *)SDL_malloc(*audio_len);
     if (*audio_buf == NULL) {
         Mix_OutOfMemory();
-        return(NULL);
+        return NULL;
     }
     SDL_RWseek(src, start, RW_SEEK_SET);
     if (SDL_RWread(src, *audio_buf, *audio_len, 1) != 1) {
         Mix_SetError("Unable to read audio data");
-        return(NULL);
+        return NULL;
     }
 
     /* Don't return a buffer that isn't a multiple of samplesize */
@@ -241,7 +242,7 @@ SDL_AudioSpec *Mix_LoadAIFF_RW (SDL_RWops *src, int freesrc,
     if (was_error) {
         spec = NULL;
     }
-    return(spec);
+    return spec;
 }
 
 /* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/codecs/load_voc.c b/src/codecs/load_voc.c
index 6f3674ac..ed9263f0 100644
--- a/src/codecs/load_voc.c
+++ b/src/codecs/load_voc.c
@@ -88,24 +88,27 @@ static int voc_check_header(SDL_RWops *src)
 
     SDL_RWseek(src, 0, RW_SEEK_SET);
 
-    if (SDL_RWread(src, signature, sizeof (signature), 1) != 1)
-        return(0);
+    if (SDL_RWread(src, signature, sizeof(signature), 1) != 1) {
+        return 0;
+    }
 
-    if (SDL_memcmp(signature, "Creative Voice File\032", sizeof (signature)) != 0) {
+    if (SDL_memcmp(signature, "Creative Voice File\032", sizeof(signature)) != 0) {
         SDL_SetError("Unrecognized file type (not VOC)");
-        return(0);
+        return 0;
     }
 
-        /* get the offset where the first datablock is located */
-    if (SDL_RWread(src, &datablockofs, sizeof (Uint16), 1) != 1)
-        return(0);
+    /* get the offset where the first datablock is located */
+    if (SDL_RWread(src, &datablockofs, sizeof(Uint16), 1) != 1) {
+        return 0;
+    }
 
     datablockofs = SDL_SwapLE16(datablockofs);
 
-    if (SDL_RWseek(src, datablockofs, RW_SEEK_SET) != datablockofs)
-        return(0);
+    if (SDL_RWseek(src, datablockofs, RW_SEEK_SET) != datablockofs) {
+        return 0;
+    }
 
-    return(1);  /* success! */
+    return 1;  /* success! */
 } /* voc_check_header */
 
 
@@ -122,38 +125,37 @@ static int voc_get_block(SDL_RWops *src, vs_t *v, SDL_AudioSpec *spec)
     unsigned int i;
 
     v->silent = 0;
-    while (v->rest == 0)
-    {
-        if (SDL_RWread(src, &block, sizeof (block), 1) != 1)
+    while (v->rest == 0) {
+        if (SDL_RWread(src, &block, sizeof(block), 1) != 1) {
             return 1;  /* assume that's the end of the file. */
+        }
 
-        if (block == VOC_TERM)
+        if (block == VOC_TERM) {
             return 1;
+        }
 
-        if (SDL_RWread(src, bits24, sizeof (bits24), 1) != 1)
+        if (SDL_RWread(src, bits24, sizeof(bits24), 1) != 1) {
             return 1;  /* assume that's the end of the file. */
+        }
 
         /* Size is an 24-bit value. Ugh. */
         sblen = (Uint32)((bits24[0]) | (bits24[1] << 8) | (bits24[2] << 16));
 
-        switch(block)
-        {
+        switch(block) {
             case VOC_DATA:
-                if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1)
+                if (SDL_RWread(src, &uc, sizeof(uc), 1) != 1) {
                     return 0;
+                }
 
                 /* When DATA block preceeded by an EXTENDED     */
                 /* block, the DATA blocks rate value is invalid */
-                if (!v->has_extended)
-                {
-                    if (uc == 0)
-                    {
+                if (!v->has_extended) {
+                    if (uc == 0) {
                         SDL_SetError("VOC Sample rate is zero?");
                         return 0;
                     }
 
-                    if ((v->rate != VOC_BAD_RATE) && (uc != v->rate))
-                    {
+                    if ((v->rate != VOC_BAD_RATE) && (uc != v->rate)) {
                         SDL_SetError("VOC sample rate codes differ");
                         return 0;
                     }
@@ -163,11 +165,11 @@ static int voc_get_block(SDL_RWops *src, vs_t *v, SDL_AudioSpec *spec)
                     v->channels = 1;
                 }
 
-                if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1)
+                if (SDL_RWread(src, &uc, sizeof(uc), 1) != 1) {
                     return 0;
+                }
 
-                if (uc != 0)
-                {
+                if (uc != 0) {
                     SDL_SetError("VOC decoder only interprets 8-bit data");
                     return 0;
                 }
@@ -178,27 +180,26 @@ static int voc_get_block(SDL_RWops *src, vs_t *v, SDL_AudioSpec *spec)
                 return 1;
 
             case VOC_DATA_16:
-                if (SDL_RWread(src, &new_rate_long, sizeof (new_rate_long), 1) != 1)
+                if (SDL_RWread(src, &new_rate_long, sizeof(new_rate_long), 1) != 1) {
                     return 0;
+                }
                 new_rate_long = SDL_SwapLE32(new_rate_long);
-                if (new_rate_long == 0)
-                {
+                if (new_rate_long == 0) {
                     SDL_SetError("VOC Sample rate is zero?");
                     return 0;
                 }
-                if ((v->rate != VOC_BAD_RATE) && (new_rate_long != v->rate))
-                {
+                if ((v->rate != VOC_BAD_RATE) && (new_rate_long != v->rate)) {
                     SDL_SetError("VOC sample rate codes differ");
                     return 0;
                 }
                 v->rate = new_rate_long;
                 spec->freq = (int)new_rate_long;
 
-                if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1)
+                if (SDL_RWread(src, &uc, sizeof(uc), 1) != 1) {
                     return 0;
+                }
 
-                switch (uc)
-                {
+                switch (uc) {
                     case 8:  v->size = ST_SIZE_BYTE; break;
                     case 16: v->size = ST_SIZE_WORD; break;
                     default:
@@ -206,11 +207,13 @@ static int voc_get_block(SDL_RWops *src, vs_t *v, SDL_AudioSpec *spec)
                         return 0;
                 }
 
-                if (SDL_RWread(src, &v->channels, sizeof (Uint8), 1) != 1)
+                if (SDL_RWread(src, &v->channels, sizeof(Uint8), 1) != 1) {
                     return 0;
+                }
 
-                if (SDL_RWread(src, trash, sizeof (Uint8), 6) != 6)
+                if (SDL_RWread(src, trash, sizeof(Uint8), 6) != 6) {
                     return 0;
+                }
 
                 v->rest = sblen - 12;
                 return 1;
@@ -220,14 +223,15 @@ static int voc_get_block(SDL_RWops *src, vs_t *v, SDL_AudioSpec *spec)
                 return 1;
 
             case VOC_SILENCE:
-                if (SDL_RWread(src, &period, sizeof (period), 1) != 1)
+                if (SDL_RWread(src, &period, sizeof(period), 1) != 1) {
                     return 0;
+                }
                 period = SDL_SwapLE16(period);
 
-                if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1)
+                if (SDL_RWread(src, &uc, sizeof(uc), 1) != 1) {
                     return 0;
-                if (uc == 0)
-                {
+                }
+                if (uc == 0) {
                     SDL_SetError("VOC silence sample rate is zero");
                     return 0;
                 }
@@ -247,10 +251,10 @@ static int voc_get_block(SDL_RWops *src, vs_t *v, SDL_AudioSpec *spec)
 
             case VOC_LOOP:
             case VOC_LOOPEND:
-                for(i = 0; i < sblen; i++)   /* skip repeat loops. */
-                {
-                    if (SDL_RWread(src, trash, sizeof (Uint8), 1) != 1)
+                for (i = 0; i < sblen; i++) { /* skip repeat loops. */
+                    if (SDL_RWread(src, trash, sizeof(Uint8), 1) != 1) {
                         return 0;
+                    }
                 }
                 break;
 
@@ -260,60 +264,61 @@ static int voc_get_block(SDL_RWops *src, vs_t *v, SDL_AudioSpec *spec)
                 /* value from the extended block and not the     */
                 /* data block.                     */
                 v->has_extended = 1;
-                if (SDL_RWread(src, &new_rate_short, sizeof (new_rate_short), 1) != 1)
+                if (SDL_RWread(src, &new_rate_short, sizeof(new_rate_short), 1) != 1) {
                     return 0;
+                }
                 new_rate_short = SDL_SwapLE16(new_rate_short);
-                if (new_rate_short == 0)
-                {
+                if (new_rate_short == 0) {
                    SDL_SetError("VOC sample rate is zero");
                    return 0;
                 }
-                if ((v->rate != VOC_BAD_RATE) && (new_rate_short != v->rate))
-                {
+                if ((v->rate != VOC_BAD_RATE) && (new_rate_short != v->rate)) {
                    SDL_SetError("VOC sample rate codes differ");
                    return 0;
                 }
                 v->rate = new_rate_short;
 
-                if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1)
+                if (SDL_RWread(src, &uc, sizeof(uc), 1) != 1) {
                     return 0;
+                }
 
-                if (uc != 0)
-                {
+                if (uc != 0) {
                     SDL_SetError("VOC decoder only interprets 8-bit data");
                     return 0;
                 }
 
-                if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1)
+                if (SDL_RWread(src, &uc, sizeof(uc), 1) != 1) {
                     return 0;
+                }
 
-                if (uc)
-                    spec->channels = 2;  /* Stereo */
+                if (uc) /* Stereo */
+                     spec->channels = 2;
                 /* VOC_EXTENDED may be read before spec->channels inited: */
                 else spec->channels = 1;
                 /* Needed number of channels before finishing
                    compute for rate */
-                spec->freq = (256000000L/(65536L - v->rate))/spec->channels;
+                spec->freq = (256000000L / (65536L - v->rate)) / spec->channels;
                 /* An extended block must be followed by a data */
                 /* block to be valid so loop back to top so it  */
                 /* can be grabed.                */
                 continue;
 
             case VOC_MARKER:
-                if (SDL_RWread(src, trash, sizeof (Uint8), 2) != 2)
+                if (SDL_RWread(src, trash, sizeof(Uint8), 2) != 2) {
                     return 0;
-
+                }
                 /* fallthrough */
 
             default:  /* text block or other krapola. */
-                for(i = 0; i < sblen; i++)
-                {
-                    if (SDL_RWread(src, trash, sizeof (Uint8), 1) != 1)
+                for (i = 0; i < sblen; i++) {
+                    if (SDL_RWread(src, trash, sizeof(Uint8), 1) != 1) {
                         return 0;
+                    }
                 }
 
-                if (block == VOC_TEXT)
+                if (block == VOC_TEXT) {
                     continue;    /* get next block */
+                }
         }
     }
 
@@ -326,36 +331,33 @@ static Uint32 voc_read(SDL_RWops *src, vs_t *v, Uint8 *buf, SDL_AudioSpec *spec)
     Uint32 done = 0;
     Uint8 silence = 0x80;
 
-    if (v->rest == 0)
-    {
-        if (!voc_get_block(src, v, spec))
+    if (v->rest == 0) {
+        if (!voc_get_block(src, v, spec)) {
             return 0;
+        }
     }
 
-    if (v->rest == 0)
+    if (v->rest == 0) {
         return 0;
+    }
 
-    if (v->silent)
-    {
-        if (v->size == ST_SIZE_WORD)
+    if (v->silent) {
+        if (v->size == ST_SIZE_WORD) {
             silence = 0x00;
+        }
 
         /* Fill in silence */
         SDL_memset(buf, silence, v->rest);
         done = v->rest;
         v->rest = 0;
     }
-
-    else
-    {
+    else {
         done = (Uint32)SDL_RWread(src, buf, 1, v->rest);
         v->rest -= done;
-        if (v->size == ST_SIZE_WORD)
-        {
+        if (v->size == ST_SIZE_WORD) {
             #if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
             Uint16 *samples = (Uint16 *)buf;
-            for (; v->rest > 0; v->rest -= 2)
-            {
+            for (; v->rest > 0; v->rest -= 2) {
                 *samples = SDL_SwapLE16(*samples);
                 samples++;
             }
@@ -378,22 +380,25 @@ SDL_AudioSpec *Mix_LoadVOC_RW (SDL_RWops *src, int freesrc,
     Uint8 *fillptr;
     void *ptr;
 
-    if ((!src) || (!audio_buf) || (!audio_len))   /* sanity checks. */
+    if (!src || !audio_buf || !audio_len) { /* sanity checks. */
         goto done;
+    }
 
-    if (!voc_check_header(src))
+    if (!voc_check_header(src)) {
         goto done;
+    }
 
-    SDL_memset(&v, 0, sizeof (vs_t));
+    SDL_memset(&v, 0, sizeof(vs_t));
     v.rate = VOC_BAD_RATE;
     v.rest = 0;
     v.has_extended = 0;
     *audio_buf = NULL;
     *audio_len = 0;
-    SDL_memset(spec, '\0', sizeof (SDL_AudioSpec));
+    SDL_memset(spec, '\0', sizeof(SDL_AudioSpec));
 
-    if (!voc_get_block(src, &v, spec))
+    if (!voc_get_block(src, &v, spec)) {
         goto done;
+    }
 
     if (v.rate == VOC_BAD_RATE) {
         SDL_SetError("VOC data had no sound!");
@@ -406,25 +411,26 @@ SDL_AudioSpec *Mix_LoadVOC_RW (SDL_RWops *src, int freesrc,
     }
 
     spec->format = ((v.size == ST_SIZE_WORD) ? AUDIO_S16 : AUDIO_U8);
-    if (spec->channels == 0)
+    if (spec->channels == 0) {
         spec->channels = v.channels;
+    }
 
     *audio_len = v.rest;
     *audio_buf = (v.rest == 0) ? NULL : SDL_malloc(v.rest);
-    if (*audio_buf == NULL)
+    if (*audio_buf == NULL) {
         goto done;
+    }
 
     fillptr = *audio_buf;
 
-    while (voc_read(src, &v, fillptr, spec))
-    {
-        if (!voc_get_block(src, &v, spec))
+    while (voc_read(src, &v, fillptr, spec)) {
+        if (!voc_get_block(src, &v, spec)) {
             goto done;
+        }
 
         *audio_len += v.rest;
         ptr = SDL_realloc(*audio_buf, *audio_len);
-        if (ptr == NULL)
-        {
+        if (ptr == NULL) {
             SDL_free(*audio_buf);
             *audio_buf = NULL;
             *audio_len = 0;
@@ -447,12 +453,11 @@ SDL_AudioSpec *Mix_LoadVOC_RW (SDL_RWops *src, int freesrc,
     if (freesrc && src) {
         SDL_RWclose(src);
     }
-
     if (was_error) {
         spec = NULL;
     }
+    return spec;
 
-    return(spec);
 } /* Mix_LoadVOC_RW */
 
 /* end of load_voc.c ... */
diff --git a/src/codecs/music_cmd.c b/src/codecs/music_cmd.c
index 38751467..37e46954 100644
--- a/src/codecs/music_cmd.c
+++ b/src/codecs/music_cmd.c
@@ -123,7 +123,7 @@ static int ParseCommandLine(char *cmdline, char **argv)
     if (argv) {
         argv[argc] = NULL;
     }
-    return(argc);
+    return argc;
 }
 
 static char **parse_args(char *command, char *last_arg)
@@ -138,7 +138,7 @@ static char **parse_args(char *command, char *last_arg)
     }
     argv = (char **)SDL_malloc((argc+1)*(sizeof *argv));
     if (argv == NULL) {
-        return(NULL);
+        return NULL;
     }
     argc = ParseCommandLine(command, argv);
 
@@ -149,7 +149,7 @@ static char **parse_args(char *command, char *last_arg)
     argv[argc] = NULL;
 
     /* We're ready! */
-    return(argv);
+    return argv;
 }
 
 /* Start playback of a given music stream */
diff --git a/src/codecs/music_flac.c b/src/codecs/music_flac.c
index 5aedb066..2ef6cb52 100644
--- a/src/codecs/music_flac.c
+++ b/src/codecs/music_flac.c
@@ -197,7 +197,7 @@ static FLAC__StreamDecoderReadStatus flac_read_music_cb(
 
     /* make sure there is something to be reading */
     if (*bytes > 0) {
-        *bytes = SDL_RWread (data->src, buffer, sizeof (FLAC__byte), *bytes);
+        *bytes = SDL_RWread (data->src, buffer, sizeof(FLAC__byte), *bytes);
 
         if (*bytes == 0) { /* error or no data was read (EOF) */
             return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
diff --git a/src/codecs/native_midi/native_midi_common.c b/src/codecs/native_midi/native_midi_common.c
index 4e247269..c7996d92 100644
--- a/src/codecs/native_midi/native_midi_common.c
+++ b/src/codecs/native_midi/native_midi_common.c
@@ -58,19 +58,18 @@ typedef struct
 #endif
 
 
-
 /* Get Variable Length Quantity */
 static int GetVLQ(MIDITrack *track, int *currentPos)
 {
     int l = 0;
     Uint8 c;
-    while(1)
-    {
+    while (1) {
         c = track->data[*currentPos];
         (*currentPos)++;
         l += (c & 0x7f);
-        if (!(c & 0x80))
+        if (!(c & 0x80)) {
             return l;
+        }
         l <<= 7;
     }
 }
@@ -82,15 +81,14 @@ static MIDIEvent *CreateEvent(Uint32 time, Uint8 event, Uint8 a, Uint8 b)
 
     newEvent = SDL_calloc(1, sizeof(MIDIEvent));
 
-    if (newEvent)
-    {
+    if (newEvent) {
         newEvent->time = time;
         newEvent->status = event;
         newEvent->data[0] = a;
         newEvent->data[1] = b;
-    }
-    else
+    } else {
         Mix_OutOfMemory();
+    }
 
     return newEvent;
 }
@@ -108,23 +106,20 @@ static MIDIEvent *MIDITracktoStream(MIDITrack *track)
     MIDIEvent *head = CreateEvent(0,0,0,0); /* dummy event to make handling the list easier */
     MIDIEvent *currentEvent = head;
 
-    while (!end)
-    {
-        if (currentPos >= track->len)
+    while (!end) {
+        if (currentPos >= track->len) {
             break; /* End of data stream reached */
+        }
 
         atime += GetVLQ(track, &currentPos);
         event = track->data[currentPos++];
 
         /* Handle SysEx seperatly */
-        if (((event>>4) & 0x0F) == MIDI_STATUS_SYSEX)
-        {
-            if (event == 0xFF)
-            {
+        if (((event>>4) & 0x0F) == MIDI_STATUS_SYSEX) {
+            if (event == 0xFF) {
                 type = track->data[currentPos];
                 currentPos++;
-                switch(type)
-                {
+                switch(type) {
                     case 0x2f: /* End of data marker */
                         end = 1;
                     case 0x51: /* Tempo change */
@@ -136,33 +131,28 @@ static MIDIEvent *MIDITracktoStream(MIDITrack *track)
                         */
                         break;
                 }
-            }
-            else
+            } else {
                 type = 0;
+            }
 
             len = GetVLQ(track, &currentPos);
 
             /* Create an event and attach the extra data, if any */
             currentEvent->next = CreateEvent(atime, event, type, 0);
             currentEvent = currentEvent->next;
-            if (NULL == currentEvent)
-            {
+            if (NULL == currentEvent) {
                 FreeMIDIEventList(head);
                 return NULL;
             }
-            if (len)
-            {
+            if (len) {
                 currentEvent->extraLen = len;
                 currentEvent->extraData = SDL_malloc(len);
                 SDL_memcpy(currentEvent->extraData, &(track->data[currentPos]), len);
                 currentPos += len;
             }
-        }
-        else
-        {
+        } else {
             a = event;
-            if (a & 0x80) /* It's a status byte */
-            {
+            if (a & 0x80) { /* It's a status byte */
                 /* Extract channel and status information */
                 lastchan = a & 0x0F;
                 laststatus = (a>>4) & 0x0F;
@@ -170,8 +160,7 @@ static MIDIEvent *MIDITracktoStream(MIDITrack *track)
                 /* Read the next byte which should always be a data byte */
                 a = track->data[currentPos++] & 0x7F;
             }
-            switch(laststatus)
-            {
+            switch(laststatus) {
                 case MIDI_STATUS_NOTE_OFF:
                 case MIDI_STATUS_NOTE_ON: /* Note on */
                 case MIDI_STATUS_AFTERTOUCH: /* Key Pressure */
@@ -180,8 +169,7 @@ static MIDIEvent *MIDITracktoStream(MIDITrack *track)
                     b = track->data[currentPos++] & 0x7F;
                     currentEvent->next = CreateEvent(atime, (Uint8)((laststatus<<4)+lastchan), a, b);
                     currentEvent = currentEvent->next;
-                    if (NULL == currentEvent)
-                    {
+                    if (NULL == currentEvent) {
                         FreeMIDIEventList(head);
                         return NULL;
                     }
@@ -192,8 +180,7 @@ static MIDIEvent *MIDITracktoStream(MIDITrack *track)
                     a &= 0x7f;
                     currentEvent->next = CreateEvent(atime, (Uint8)((laststatus<<4)+lastchan), a, 0);
                     currentEvent = currentEvent->next;
-                    if (NULL == currentEvent)
-                    {
+                    if (NULL == currentEvent) {
                         FreeMIDIEventList(head);
                         return NULL;
                     }
@@ -222,47 +209,45 @@ static MIDIEvent *MIDItoStream(MIDIFile *mididata)
     MIDIEvent *currentEvent = head;
     int trackID;
 
-    if (NULL == head)
+    if (NULL == head) {
         return NULL;
+    }
 
     track = (MIDIEvent**) SDL_calloc(1, sizeof(MIDIEvent*) * mididata->nTracks);
-    if (NULL == track)
-    {
+    if (NULL == track) {
         SDL_free(head);
         return NULL;
     }
 
     /* First, convert all tracks to MIDIEvent lists */
-    for (trackID = 0; trackID < mididata->nTracks; trackID++)
+    for (trackID = 0; trackID < mididata->nTracks; trackID++) {
         track[trackID] = MIDITracktoStream(&mididata->track[trackID]);
+    }
 
     /* Now, merge the lists. */
     /* TODO */
-    while(1)
-    {
+    while (1) {
         Uint32 lowestTime = 0x7FFFFFFF; /* INT_MAX */
         int currentTrackID = -1;
 
         /* Find the next event */
-        for (trackID = 0; trackID < mididata->nTracks; trackID++)
-        {
-            if (track[trackID] && (track[trackID]->time < lowestTime))
-            {
+        for (trackID = 0; trackID < mididata->nTracks; trackID++) {
+            if (track[trackID] && (track[trackID]->time < lowestTime)) {
                 currentTrackID = trackID;
                 lowestTime = track[currentTrackID]->time;
             }
         }
 
         /* Check if we processes all events */
-        if (currentTrackID == -1)
+        if (currentTrackID == -1) {
             break;
+        }
 
         currentEvent->next = track[currentTrackID];
         track[currentTrackID] = track[currentTrackID]->next;
 
         currentEvent = currentEvent->next;
 
-
         lowestTime = 0;
     }
 
@@ -278,16 +263,18 @@ static MIDIEvent *MIDItoStream(MIDIFile *mididata)
 static int ReadMIDIFile(MIDIFile *mididata, SDL_RWops *src)
 {
     int i = 0;
-    Uint32  ID;
-    Uint32  size;
-    Uint16  format;
-    Uint16  tracks;
-    Uint16  division;
+    Uint32 ID;
+    Uint32 size;
+    Uint16 format;
+    Uint16 tracks;
+    Uint16 division;
 
-    if (!mididata)
+    if (!mididata) {
         return 0;
-    if (!src)
+    }
+    if (!src) {
         return 0;
+    }
 
     /* Make sure this is really a MIDI file */
     SDL_RWread(src, &ID, 1, 4);
@@ -295,20 +282,23 @@ static int ReadMIDIFile(MIDIFile *mididata, SDL_RWops *src)
         SDL_RWseek(src, 16, RW_SEEK_CUR);
         SDL_RWread(src, &ID, 1, 4);
     }
-    if (BE_LONG(ID) != MIDI_MAGIC)
+    if (BE_LONG(ID) != MIDI_MAGIC) {
         return 0;
+    }
 
     /* Header size must be 6 */
     SDL_RWread(src, &size, 1, 4);
     size = BE_LONG(size);
-    if (size != 6)
+    if (size != 6) {
         return 0;
+    }
 
     /* We only support format 0 and 1, but not 2 */
     SDL_RWread(src, &format, 1, 2);
     format = BE_SHORT(format);
-    if (format != 0 && format != 1)
+    if (format != 0 && format != 1) {
         return 0;
+    }
 
     SDL_RWread(src, &tracks, 1, 2);
     tracks = BE_SHORT(tracks);
@@ -316,8 +306,7 @@ static int ReadMIDIFile(MIDIFile *mididata, SDL_RWops *src)
 
     /* Allocate tracks */
     mididata->track = (MIDITrack*) SDL_calloc(1, sizeof(MIDITrack) * 

(Patch may be truncated, please check the link at the top of this post.)