load_flac.c
changeset 470 5cebd6c5be2d
parent 436 8ec227cabdd4
child 473 60b7e1c4f6b2
     1.1 --- a/load_flac.c	Sun Nov 08 15:06:43 2009 +0000
     1.2 +++ b/load_flac.c	Sun Nov 08 16:35:36 2009 +0000
     1.3 @@ -208,7 +208,8 @@
     1.4  static void flac_metadata_load_cb(
     1.5  					const FLAC__StreamDecoder *decoder,
     1.6  					const FLAC__StreamMetadata *metadata,
     1.7 -					void *client_data) {
     1.8 +					void *client_data)
     1.9 +{
    1.10  	FLAC_SDL_Data *data = (FLAC_SDL_Data *)client_data;
    1.11  	FLAC__uint64 total_samples;
    1.12  	unsigned bps;
    1.13 @@ -237,7 +238,8 @@
    1.14  static void flac_error_load_cb(
    1.15  				const FLAC__StreamDecoder *decoder,
    1.16  				FLAC__StreamDecoderErrorStatus status,
    1.17 -				void *client_data) {
    1.18 +				void *client_data)
    1.19 +{
    1.20  	// print an SDL error based on the error status
    1.21  	switch (status) {
    1.22  		case FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC:
    1.23 @@ -260,7 +262,8 @@
    1.24  
    1.25  /* don't call this directly; use Mix_LoadWAV_RW() for now. */
    1.26  SDL_AudioSpec *Mix_LoadFLAC_RW (SDL_RWops *src, int freesrc,
    1.27 -        SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len) {
    1.28 +        SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
    1.29 +{
    1.30  	FLAC__StreamDecoder *decoder = 0;
    1.31  	FLAC__StreamDecoderInitStatus init_status;
    1.32  	int was_error = 1;
    1.33 @@ -271,11 +274,11 @@
    1.34  	FLAC_SDL_Data* client_data;
    1.35  	client_data = (FLAC_SDL_Data *)malloc (sizeof (FLAC_SDL_Data));
    1.36  
    1.37 -    if ((!src) || (!audio_buf) || (!audio_len))   /* sanity checks. */
    1.38 -        goto done;
    1.39 +	if ((!src) || (!audio_buf) || (!audio_len))   /* sanity checks. */
    1.40 +		goto done;
    1.41  
    1.42 -    if (Mix_InitFLAC() < 0)
    1.43 -        goto done;
    1.44 +	if (!Mix_Init(MIX_INIT_FLAC))
    1.45 +		goto done;
    1.46  
    1.47  	if ((decoder = flac.FLAC__stream_decoder_new ()) == NULL) {
    1.48  		SDL_SetError ("Unable to allocate FLAC decoder.");
    1.49 @@ -313,25 +316,23 @@
    1.50      *audio_len &= ~(samplesize - 1);
    1.51  
    1.52  done:
    1.53 -	if(was_init && decoder) {
    1.54 +	if (was_init && decoder) {
    1.55  		flac.FLAC__stream_decoder_finish (decoder);
    1.56  	}
    1.57  
    1.58 -	if(decoder) {
    1.59 +	if (decoder) {
    1.60  		flac.FLAC__stream_decoder_delete (decoder);
    1.61  	}
    1.62  
    1.63 -    if (src) {
    1.64 -        if (freesrc)
    1.65 -            SDL_RWclose (src);
    1.66 -        else
    1.67 -            SDL_RWseek (src, 0, SEEK_SET);
    1.68 -    }
    1.69 +	if (src) {
    1.70 +		if (freesrc)
    1.71 +			SDL_RWclose (src);
    1.72 +		else
    1.73 +			SDL_RWseek (src, 0, SEEK_SET);
    1.74 +	}
    1.75  
    1.76 -    if (was_error)
    1.77 -        spec = NULL;
    1.78 -
    1.79 -    Mix_QuitFLAC ();
    1.80 +	if (was_error)
    1.81 +		spec = NULL;
    1.82  
    1.83      return spec;
    1.84  }