Skip to content

Commit

Permalink
style clean-up.
Browse files Browse the repository at this point in the history
  • Loading branch information
sezero committed Jan 15, 2024
1 parent 5c64964 commit c774255
Show file tree
Hide file tree
Showing 11 changed files with 384 additions and 389 deletions.
32 changes: 16 additions & 16 deletions examples/playmus.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static 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;
Expand Down Expand Up @@ -104,9 +104,9 @@ static void Menu(void)
static void IntHandler(int sig)
{
switch (sig) {
case SIGINT:
next_track++;
break;
case SIGINT:
next_track++;
break;
}
}
#endif
Expand Down Expand Up @@ -134,7 +134,7 @@ int main(int argc, char *argv[])
spec.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 ((SDL_strcmp(argv[i], "-r") == 0) && argv[i+1]) {
++i;
spec.freq = SDL_atoi(argv[i]);
Expand Down Expand Up @@ -170,18 +170,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
Expand All @@ -190,10 +190,9 @@ int main(int argc, char *argv[])
#endif

/* Open the audio device */

if (Mix_OpenAudio(0, &spec) < 0) {
SDL_Log("Couldn't open audio: %s\n", SDL_GetError());
return(2);
return 2;
} else {
Mix_QuerySpec(&spec.freq, &spec.format, &spec.channels);
SDL_Log("Opened audio at %d Hz %d bit%s %s audio buffer\n", spec.freq,
Expand All @@ -219,8 +218,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);
}

Expand Down Expand Up @@ -292,9 +290,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);
Expand All @@ -308,7 +306,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++;
}
Expand Down
21 changes: 10 additions & 11 deletions examples/playwave.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,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
}

Expand All @@ -164,7 +164,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",
Expand Down Expand Up @@ -235,7 +235,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",
Expand Down Expand Up @@ -377,7 +377,7 @@ int main(int argc, char *argv[])
spec.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 ((SDL_strcmp(argv[i], "-r") == 0) && argv[i+1]) {
++i;
spec.freq = SDL_atoi(argv[i]);
Expand Down Expand Up @@ -405,18 +405,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);
Expand Down Expand Up @@ -453,8 +453,7 @@ int main(int argc, char *argv[])
/* Load the requested wave file */
g_wave = Mix_LoadWAV(argv[i]);
if (g_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);
}

Expand Down
6 changes: 4 additions & 2 deletions src/codecs/load_aiff.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ static Uint32 SANE_to_Uint32 (Uint8 *sanebuf)
SDL_AudioSpec *Mix_LoadAIFF_RW (SDL_RWops *src, SDL_bool freesrc,
SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
{
SDL_bool was_error = SDL_TRUE;
int found_SSND;
int found_COMM;
int found_VHDR;
int found_BODY;
SDL_bool was_error = SDL_TRUE;
Sint64 start = 0;

Uint32 chunk_type;
Expand Down Expand Up @@ -146,9 +146,11 @@ SDL_AudioSpec *Mix_LoadAIFF_RW (SDL_RWops *src, SDL_bool freesrc,
goto done;
}
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:
Expand Down
Loading

0 comments on commit c774255

Please sign in to comment.