diff --git a/src/codecs/load_aiff.c b/src/codecs/load_aiff.c index 57779c0..62e47fc 100644 --- a/src/codecs/load_aiff.c +++ b/src/codecs/load_aiff.c @@ -79,12 +79,12 @@ 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_FVER; int found_VHDR; int found_BODY; + int was_error = 0; Sint64 start = 0; Uint32 chunk_type; @@ -302,7 +302,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 6f3674a..242a0f6 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) { - SDL_SetError("Unrecognized file type (not VOC)"); - return(0); + if (SDL_memcmp(signature, "Creative Voice File\032", sizeof(signature)) != 0) { + Mix_SetError("Unrecognized file type (not VOC)"); + return 0; } /* get the offset where the first datablock is located */ - if (SDL_RWread(src, &datablockofs, sizeof (Uint16), 1) != 1) - return(0); + 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,39 +125,38 @@ 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) - { - SDL_SetError("VOC Sample rate is zero?"); + if (!v->has_extended) { + if (uc == 0) { + 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"); + if ((v->rate != VOC_BAD_RATE) && (uc != v->rate)) { + Mix_SetError("VOC sample rate codes differ"); return 0; } @@ -163,12 +165,12 @@ 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) - { - SDL_SetError("VOC decoder only interprets 8-bit data"); + if (uc != 0) { + Mix_SetError("VOC decoder only interprets 8-bit data"); return 0; } @@ -178,39 +180,40 @@ 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) - { - SDL_SetError("VOC Sample rate is zero?"); + if (new_rate_long == 0) { + 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"); + if ((v->rate != VOC_BAD_RATE) && (new_rate_long != v->rate)) { + Mix_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: - SDL_SetError("VOC with unknown data size"); + Mix_SetError("VOC with unknown data size"); 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,15 +223,16 @@ 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) - { - SDL_SetError("VOC silence sample rate is zero"); + } + if (uc == 0) { + Mix_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,62 @@ 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) - { - SDL_SetError("VOC sample rate is zero"); + if (new_rate_short == 0) { + 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"); + if ((v->rate != VOC_BAD_RATE) && (new_rate_short != v->rate)) { + Mix_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) - { - SDL_SetError("VOC decoder only interprets 8-bit data"); + if (uc != 0) { + Mix_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) + if (uc) { spec->channels = 2; /* Stereo */ + } /* 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 +332,32 @@ 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,53 +380,57 @@ 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!"); + 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; } 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/mp3utils.c b/src/codecs/mp3utils.c index bd2b63e..66c8d0c 100644 --- a/src/codecs/mp3utils.c +++ b/src/codecs/mp3utils.c @@ -1320,7 +1320,7 @@ int mp3_read_tags(Mix_MusicMetaTags *out_tags, struct mp3file_t *fil, SDL_bool k break; } /* for (;;) */ - succ: +succ: rc = (fil->length > 0)? 0 : -1; fail: MP3_RWseek(fil, 0, RW_SEEK_SET); diff --git a/src/codecs/music_cmd.c b/src/codecs/music_cmd.c index 85f1b0e..5077bda 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 */ @@ -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 6c7de4f..c116e71 100644 --- a/src/codecs/music_drflac.c +++ b/src/codecs/music_drflac.c @@ -268,8 +268,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 02a0d79..df3125c 100644 --- a/src/codecs/music_flac.c +++ b/src/codecs/music_flac.c @@ -201,7 +201,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; @@ -320,7 +320,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; } @@ -333,7 +333,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) { @@ -489,19 +489,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; } } @@ -516,7 +516,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); @@ -561,13 +561,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) { @@ -650,17 +650,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) { @@ -709,8 +707,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 c385de8..d730fce 100644 --- a/src/codecs/music_fluidsynth.c +++ b/src/codecs/music_fluidsynth.c @@ -43,7 +43,7 @@ typedef struct { #if (FLUIDSYNTH_VERSION_MAJOR >= 2) void (*delete_fluid_player)(fluid_player_t*); void (*delete_fluid_synth)(fluid_synth_t*); - int (*fluid_player_seek)(fluid_player_t*, int); + int (*fluid_player_seek)(fluid_player_t *, int); #else int (*delete_fluid_player)(fluid_player_t*); int (*delete_fluid_synth)(fluid_synth_t*); @@ -94,7 +94,7 @@ static int FLUIDSYNTH_Load() #if (FLUIDSYNTH_VERSION_MAJOR >= 2) FUNCTION_LOADER(delete_fluid_player, void (*)(fluid_player_t*)) FUNCTION_LOADER(delete_fluid_synth, void (*)(fluid_synth_t*)) - FUNCTION_LOADER(fluid_player_seek, int (*)(fluid_player_t*, int)) + FUNCTION_LOADER(fluid_player_seek, int (*)(fluid_player_t *, int)) #else FUNCTION_LOADER(delete_fluid_player, int (*)(fluid_player_t*)) FUNCTION_LOADER(delete_fluid_synth, int (*)(fluid_synth_t*)) @@ -295,7 +295,7 @@ static int FLUIDSYNTH_Play(void *context, int play_count) static void FLUIDSYNTH_Resume(void *context) { - FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music*)context; + FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context; fluidsynth.fluid_player_play(music->player); music->is_paused = SDL_FALSE; } @@ -319,8 +319,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; @@ -344,7 +343,7 @@ static void FLUIDSYNTH_Stop(void *context) static void FLUIDSYNTH_Pause(void *context) { - FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music*)context; + FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context; fluidsynth.fluid_player_stop(music->player); music->is_paused = SDL_TRUE; } diff --git a/src/codecs/music_gme.c b/src/codecs/music_gme.c index 01698fe..79f0089 100644 --- a/src/codecs/music_gme.c +++ b/src/codecs/music_gme.c @@ -58,7 +58,7 @@ static gme_loader gme; #else #define FUNCTION_LOADER(FUNC, SIG) \ gme.FUNC = FUNC; \ - if (gme.FUNC == NULL) { Mix_SetError("Missing GME.framework"); return -1; } + if (gme.FUNC == NULL) { Mix_SetError("Missing gme.framework"); return -1; } #endif #ifdef __APPLE__ @@ -285,8 +285,7 @@ static int initialize_from_track_info(GME_Music *music, int track) err = gme.gme_track_info(music->game_emu, &mus_info, track); if (err != 0) { - Mix_SetError("GME: %s", err); - return -1; + return Mix_SetError("GME: %s", err); } music->track_length = mus_info->length; @@ -364,7 +363,7 @@ static GME_Music *GME_CreateFromRW(SDL_RWops *src, const char *args) SDL_RWseek(src, 0, RW_SEEK_SET); mem = SDL_LoadFile_RW(src, &size, SDL_FALSE); if (mem) { - err = gme.gme_open_data(mem, size, &music->game_emu, music_spec.freq); + err = gme.gme_open_data(mem, (long)size, &music->game_emu, music_spec.freq); SDL_free(mem); if (err != 0) { GME_Delete(music); @@ -464,13 +463,13 @@ static int GME_GetSome(void *context, void *data, int bytes, SDL_bool *done) return 0; } - err = gme.gme_play(music->game_emu, (music->buffer_size / 2), (short*)music->buffer); + err = gme.gme_play(music->game_emu, (int)(music->buffer_size / 2), (short*)music->buffer); if (err != NULL) { Mix_SetError("GME: %s", err); return 0; } - if (SDL_AudioStreamPut(music->stream, music->buffer, music->buffer_size) < 0) { + if (SDL_AudioStreamPut(music->stream, music->buffer, (int)music->buffer_size) < 0) { return -1; } return 0; diff --git a/src/codecs/music_modplug.c b/src/codecs/music_modplug.c index 979fc56..24d13bb 100644 --- a/src/codecs/music_modplug.c +++ b/src/codecs/music_modplug.c @@ -91,6 +91,9 @@ static int MODPLUG_Load(void) FUNCTION_LOADER(ModPlug_GetName, const char* (*)(ModPlugFile* file)) #ifdef MODPLUG_DYNAMIC modplug.ModPlug_Tell = (int (*)(ModPlugFile* file)) SDL_LoadFunction(modplug.handle, "ModPlug_Tell"); + if (modplug.ModPlug_Tell == NULL) { + SDL_ClearError(); /* ModPlug_Tell is optional. */ + } #elif defined(MODPLUG_HAS_TELL) modplug.ModPlug_Tell = ModPlug_Tell; #else diff --git a/src/codecs/music_mpg123.c b/src/codecs/music_mpg123.c index 76e6d86..b138280 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; } @@ -396,8 +395,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", @@ -440,8 +438,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 da52136..26d7af9 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) { @@ -261,7 +260,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; } @@ -395,8 +394,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, §ion); #endif if (amount < 0) { - set_ov_error("ov_read", amount); - return -1; + return set_ov_error("ov_read", amount); } if (section != music->section) { @@ -411,8 +409,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) { @@ -486,7 +483,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) { @@ -495,7 +492,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) { @@ -504,7 +501,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 c4ddf90..6c57efb 100644 --- a/src/codecs/music_opus.c +++ b/src/codecs/music_opus.c @@ -176,8 +176,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) { @@ -236,7 +235,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; } @@ -373,8 +372,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), §ion); if (samples < 0) { - set_op_error("op_read", samples); - return -1; + return set_op_error("op_read", samples); } if (section != music->section) { @@ -389,8 +387,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/codecs/music_wavpack.c b/src/codecs/music_wavpack.c index 15e89a2..870fac6 100644 --- a/src/codecs/music_wavpack.c +++ b/src/codecs/music_wavpack.c @@ -98,7 +98,7 @@ static wavpack_loader wvpk; #else #define FUNCTION_LOADER(FUNC, SIG) \ wvpk.FUNC = FUNC; \ - if (wvpk.FUNC == NULL) { Mix_SetError("Missing WavPack.framework"); return -1; } + if (wvpk.FUNC == NULL) { Mix_SetError("Missing wavpack.framework"); return -1; } #endif #ifdef __APPLE__ @@ -590,7 +590,7 @@ static int WAVPACK_Seek(void *context, double time) int64_t sample = (int64_t)(time * music->samplerate); int success = (wvpk.WavpackSeekSample64 != NULL) ? wvpk.WavpackSeekSample64(music->ctx, sample) : - wvpk.WavpackSeekSample(music->ctx, sample); + wvpk.WavpackSeekSample(music->ctx, (uint32_t)sample); if (!success) { return Mix_SetError("%s", wvpk.WavpackGetErrorMessage(music->ctx)); } diff --git a/src/codecs/native_midi/native_midi_macosx.c b/src/codecs/native_midi/native_midi_macosx.c index c211149..5d0f940 100644 --- a/src/codecs/native_midi/native_midi_macosx.c +++ b/src/codecs/native_midi/native_midi_macosx.c @@ -21,7 +21,7 @@ #include "SDL_config.h" -#if __MACOSX__ +#ifdef __MACOSX__ /* Mac OS X 10.6+, using Core MIDI. */ @@ -105,7 +105,7 @@ GetSequenceAudioUnitMatching(MusicSequence sequence, AudioUnit *aunit, for (i = 0; i < nodecount; i++) { AUNode node; #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 - ComponentDescription desc; + ComponentDescription desc; #else AudioComponentDescription desc; #endif diff --git a/src/codecs/native_midi/native_midi_win32.c b/src/codecs/native_midi/native_midi_win32.c index 1b0c2f7..522bd91 100644 --- a/src/codecs/native_midi/native_midi_win32.c +++ b/src/codecs/native_midi/native_midi_win32.c @@ -22,7 +22,7 @@ /* everything below is currently one very big bad hack ;) Proff */ -#if __WIN32__ +#ifdef __WIN32__ #define WIN32_LEAN_AND_MEAN #include diff --git a/src/codecs/timidity/common.c b/src/codecs/timidity/common.c index 1096a38..8786c19 100644 --- a/src/codecs/timidity/common.c +++ b/src/codecs/timidity/common.c @@ -13,7 +13,7 @@ #include "options.h" #include "common.h" -#if defined(__WIN32__) || defined(__OS2__) +#if defined(_WIN32) || defined(__OS2__) #define CHAR_DIRSEP '\\' #define is_dirsep(c) ((c) == '/' || (c) == '\\') #define is_abspath(p) ((p)[0] == '/' || (p)[0] == '\\' || ((p)[0] && (p)[1] == ':'))