From 774174795da9e4d1c01ceafcb2f1481dd2773e24 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 10 Oct 2009 10:23:03 +0000 Subject: [PATCH] Fixed bug #832 Fixed building FLAC support with older gcc --- load_flac.c | 21 ++++++++++++++------- music_flac.c | 9 +++------ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/load_flac.c b/load_flac.c index 9c556076..4544192c 100644 --- a/load_flac.c +++ b/load_flac.c @@ -50,7 +50,8 @@ static FLAC__StreamDecoderReadStatus flac_read_load_cb( const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, - void *client_data) { + void *client_data) +{ // make sure there is something to be reading if (*bytes > 0) { FLAC_SDL_Data *data = (FLAC_SDL_Data *)client_data; @@ -76,7 +77,8 @@ static FLAC__StreamDecoderReadStatus flac_read_load_cb( static FLAC__StreamDecoderSeekStatus flac_seek_load_cb( const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, - void *client_data) { + void *client_data) +{ FLAC_SDL_Data *data = (FLAC_SDL_Data *)client_data; if (SDL_RWseek (data->sdl_src, absolute_byte_offset, SEEK_SET) < 0) { @@ -90,7 +92,8 @@ static FLAC__StreamDecoderSeekStatus flac_seek_load_cb( static FLAC__StreamDecoderTellStatus flac_tell_load_cb( const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, - void *client_data) { + void *client_data) +{ FLAC_SDL_Data *data = (FLAC_SDL_Data *)client_data; int pos = SDL_RWtell (data->sdl_src); @@ -107,7 +110,8 @@ static FLAC__StreamDecoderTellStatus flac_tell_load_cb( static FLAC__StreamDecoderLengthStatus flac_length_load_cb( const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, - void *client_data) { + void *client_data) +{ FLAC_SDL_Data *data = (FLAC_SDL_Data *)client_data; int pos = SDL_RWtell (data->sdl_src); @@ -125,7 +129,8 @@ static FLAC__StreamDecoderLengthStatus flac_length_load_cb( } static FLAC__bool flac_eof_load_cb(const FLAC__StreamDecoder *decoder, - void *client_data) { + void *client_data) +{ FLAC_SDL_Data *data = (FLAC_SDL_Data *)client_data; int pos = SDL_RWtell (data->sdl_src); @@ -148,9 +153,11 @@ static FLAC__StreamDecoderWriteStatus flac_write_load_cb( const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *const buffer[], - void *client_data) { + void *client_data) +{ FLAC_SDL_Data *data = (FLAC_SDL_Data *)client_data; size_t i; + Uint8 *buf; if (data->flac_total_samples == 0) { SDL_SetError ("Given FLAC file does not specify its sample count."); @@ -176,7 +183,7 @@ static FLAC__StreamDecoderWriteStatus flac_write_load_cb( } } - Uint8 *buf = *(data->sdl_audio_buf); + buf = *(data->sdl_audio_buf); for (i = 0; i < frame->header.blocksize; i++) { FLAC__int16 i16; diff --git a/music_flac.c b/music_flac.c index f67ec98c..296be51a 100644 --- a/music_flac.c +++ b/music_flac.c @@ -189,6 +189,9 @@ static FLAC__StreamDecoderWriteStatus flac_write_music_cb( } for (i = 0; i < frame->header.blocksize; i++) { + FLAC__int16 i16; + FLAC__uint16 ui16; + // make sure we still have at least two bytes that can be read (one for // each channel) if (data->flac_data.max_to_read >= 4) { @@ -206,9 +209,6 @@ static FLAC__StreamDecoderWriteStatus flac_write_music_cb( } } - FLAC__int16 i16; - FLAC__uint16 ui16; - i16 = (FLAC__int16)buffer[0][i]; ui16 = (FLAC__uint16)i16; @@ -249,9 +249,6 @@ static FLAC__StreamDecoderWriteStatus flac_write_music_cb( } } - FLAC__int16 i16; - FLAC__uint16 ui16; - i16 = (FLAC__int16)buffer[0][i]; ui16 = (FLAC__uint16)i16;