Skip to content

Commit e23a8d3

Browse files
committed
style clean-up.
1 parent f9933b5 commit e23a8d3

File tree

12 files changed

+402
-408
lines changed

12 files changed

+402
-408
lines changed

playmus.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void Menu(void)
7575
printf("Available commands: (p)ause (r)esume (h)alt volume(v#) > ");
7676
fflush(stdin);
7777
if (scanf("%s",buf) == 1) {
78-
switch(buf[0]){
78+
switch(buf[0]) {
7979
#if defined(SEEK_TEST)
8080
case '0': Mix_SetMusicPosition(0); break;
8181
case '1': Mix_SetMusicPosition(10);break;
@@ -105,9 +105,9 @@ void Menu(void)
105105
void IntHandler(int sig)
106106
{
107107
switch (sig) {
108-
case SIGINT:
109-
next_track++;
110-
break;
108+
case SIGINT:
109+
next_track++;
110+
break;
111111
}
112112
}
113113
#endif
@@ -139,7 +139,7 @@ int main(int argc, char *argv[])
139139
audio_buffers = 4096;
140140

141141
/* Check command line usage */
142-
for (i=1; argv[i] && (*argv[i] == '-'); ++i) {
142+
for (i = 1; argv[i] && (*argv[i] == '-'); ++i) {
143143
if ((strcmp(argv[i], "-r") == 0) && argv[i+1]) {
144144
++i;
145145
audio_rate = atoi(argv[i]);
@@ -175,18 +175,18 @@ int main(int argc, char *argv[])
175175
rwops = 1;
176176
} else {
177177
Usage(argv[0]);
178-
return(1);
178+
return 1;
179179
}
180180
}
181-
if (! argv[i]) {
181+
if (!argv[i]) {
182182
Usage(argv[0]);
183-
return(1);
183+
return 1;
184184
}
185185

186186
/* Initialize the SDL library */
187187
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
188188
SDL_Log("Couldn't initialize SDL: %s\n",SDL_GetError());
189-
return(255);
189+
return 255;
190190
}
191191

192192
#ifdef HAVE_SIGNAL_H
@@ -197,7 +197,7 @@ int main(int argc, char *argv[])
197197
/* Open the audio device */
198198
if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) < 0) {
199199
SDL_Log("Couldn't open audio: %s\n", SDL_GetError());
200-
return(2);
200+
return 2;
201201
} else {
202202
Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
203203
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[])
224224
music = Mix_LoadMUS(argv[i]);
225225
}
226226
if (music == NULL) {
227-
SDL_Log("Couldn't load %s: %s\n",
228-
argv[i], SDL_GetError());
227+
SDL_Log("Couldn't load %s: %s\n", argv[i], SDL_GetError());
229228
CleanUp(2);
230229
}
231230

@@ -297,9 +296,9 @@ int main(int argc, char *argv[])
297296
}
298297
Mix_FadeInMusic(music,looping,2000);
299298
while (!next_track && (Mix_PlayingMusic() || Mix_PausedMusic())) {
300-
if(interactive)
299+
if (interactive) {
301300
Menu();
302-
else {
301+
} else {
303302
current_position = Mix_GetMusicPosition(music);
304303
if (current_position >= 0.0) {
305304
printf("Position: %g seconds \r", current_position);
@@ -313,7 +312,9 @@ int main(int argc, char *argv[])
313312

314313
/* If the user presses Ctrl-C more than once, exit. */
315314
SDL_Delay(500);
316-
if (next_track > 1) break;
315+
if (next_track > 1) {
316+
break;
317+
}
317318

318319
i++;
319320
}

playwave.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ static void SDLCALL channel_complete_callback (int chan)
148148
static int still_playing(void)
149149
{
150150
#ifdef TEST_MIX_CHANNELFINISHED
151-
return(!channel_is_done);
151+
return !channel_is_done;
152152
#else
153-
return(Mix_Playing(0));
153+
return Mix_Playing(0);
154154
#endif
155155
}
156156

@@ -165,7 +165,7 @@ static void do_panning_update(void)
165165
static int panningok = 1;
166166
static Uint32 next_panning_update = 0;
167167

168-
if ((panningok) && (SDL_GetTicks() >= next_panning_update)) {
168+
if (panningok && (SDL_GetTicks() >= next_panning_update)) {
169169
panningok = Mix_SetPanning(0, leftvol, rightvol);
170170
if (!panningok) {
171171
SDL_Log("Mix_SetPanning(0, %d, %d) failed!\n",
@@ -236,7 +236,7 @@ static void do_position_update(void)
236236
static int positionok = 1;
237237
static Uint32 next_position_update = 0;
238238

239-
if ((positionok) && (SDL_GetTicks() >= next_position_update)) {
239+
if (positionok && (SDL_GetTicks() >= next_position_update)) {
240240
positionok = Mix_SetPosition(0, angle, (Uint8)distance);
241241
if (!positionok) {
242242
SDL_Log("Mix_SetPosition(0, %d, %d) failed!\n",
@@ -380,7 +380,7 @@ int main(int argc, char *argv[])
380380
audio_channels = MIX_DEFAULT_CHANNELS;
381381

382382
/* Check command line usage */
383-
for (i=1; argv[i] && (*argv[i] == '-'); ++i) {
383+
for (i = 1; argv[i] && (*argv[i] == '-'); ++i) {
384384
if ((strcmp(argv[i], "-r") == 0) && argv[i+1]) {
385385
++i;
386386
audio_rate = atoi(argv[i]);
@@ -408,18 +408,18 @@ int main(int argc, char *argv[])
408408
reverse_sample = 1;
409409
} else {
410410
Usage(argv[0]);
411-
return(1);
411+
return 1;
412412
}
413413
}
414-
if (! argv[i]) {
414+
if (!argv[i]) {
415415
Usage(argv[0]);
416-
return(1);
416+
return 1;
417417
}
418418

419419
/* Initialize the SDL library */
420420
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
421421
SDL_Log("Couldn't initialize SDL: %s\n",SDL_GetError());
422-
return(255);
422+
return 255;
423423
}
424424
#ifdef HAVE_SIGNAL_H
425425
signal(SIGINT, CleanUp);
@@ -456,8 +456,7 @@ int main(int argc, char *argv[])
456456
/* Load the requested wave file */
457457
wave = Mix_LoadWAV(argv[i]);
458458
if (wave == NULL) {
459-
SDL_Log("Couldn't load %s: %s\n",
460-
argv[i], SDL_GetError());
459+
SDL_Log("Couldn't load %s: %s\n", argv[i], SDL_GetError());
461460
CleanUp(2);
462461
}
463462

src/codecs/load_aiff.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ static Uint32 SANE_to_Uint32 (Uint8 *sanebuf)
6565
SDL_AudioSpec *Mix_LoadAIFF_RW (SDL_RWops *src, int freesrc,
6666
SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
6767
{
68-
int was_error;
6968
int found_SSND;
7069
int found_COMM;
7170
int found_VHDR;
7271
int found_BODY;
72+
int was_error = 0;
7373
Sint64 start = 0;
7474

7575
Uint32 chunk_type;
@@ -92,7 +92,6 @@ SDL_AudioSpec *Mix_LoadAIFF_RW (SDL_RWops *src, int freesrc,
9292
Uint32 frequency = 0;
9393

9494
/* Make sure we are passed a valid data source */
95-
was_error = 0;
9695
if (src == NULL) {
9796
was_error = 1;
9897
goto done;
@@ -124,9 +123,11 @@ SDL_AudioSpec *Mix_LoadAIFF_RW (SDL_RWops *src, int freesrc,
124123
chunk_type = SDL_ReadLE32(src);
125124
chunk_length = SDL_ReadBE32(src);
126125
next_chunk = SDL_RWtell(src) + chunk_length;
126+
127127
/* Paranoia to avoid infinite loops */
128-
if (chunk_length == 0)
128+
if (chunk_length == 0) {
129129
break;
130+
}
130131

131132
switch (chunk_type) {
132133
case SSND:
@@ -223,12 +224,12 @@ SDL_AudioSpec *Mix_LoadAIFF_RW (SDL_RWops *src, int freesrc,
223224
*audio_buf = (Uint8 *)SDL_malloc(*audio_len);
224225
if (*audio_buf == NULL) {
225226
Mix_OutOfMemory();
226-
return(NULL);
227+
return NULL;
227228
}
228229
SDL_RWseek(src, start, RW_SEEK_SET);
229230
if (SDL_RWread(src, *audio_buf, *audio_len, 1) != 1) {
230231
Mix_SetError("Unable to read audio data");
231-
return(NULL);
232+
return NULL;
232233
}
233234

234235
/* 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,
241242
if (was_error) {
242243
spec = NULL;
243244
}
244-
return(spec);
245+
return spec;
245246
}
246247

247248
/* vi: set ts=4 sw=4 expandtab: */

0 commit comments

Comments
 (0)