Fixed bug 1833 - Memory leak issue in SDL_mixer-1.2.12/music.c file
authorSam Lantinga <slouken@libsdl.org>
Tue, 21 May 2013 21:09:26 -0700
changeset 6167ead8213dfb0
parent 615 4c87c4fabeb5
child 617 87116a42526e
Fixed bug 1833 - Memory leak issue in SDL_mixer-1.2.12/music.c file

Nitz

In this code 'music' is dynamically allocated. But memory get leaked at return MUS_NONE.
music.c
     1.1 --- a/music.c	Tue May 21 21:08:33 2013 -0700
     1.2 +++ b/music.c	Tue May 21 21:09:26 2013 -0700
     1.3 @@ -80,48 +80,48 @@
     1.4  static int music_volume = MIX_MAX_VOLUME;
     1.5  
     1.6  struct _Mix_Music {
     1.7 -	Mix_MusicType type;
     1.8 -	union {
     1.9 +    Mix_MusicType type;
    1.10 +    union {
    1.11  #ifdef CMD_MUSIC
    1.12 -		MusicCMD *cmd;
    1.13 +        MusicCMD *cmd;
    1.14  #endif
    1.15  #ifdef WAV_MUSIC
    1.16 -		WAVStream *wave;
    1.17 +        WAVStream *wave;
    1.18  #endif
    1.19  #ifdef MODPLUG_MUSIC
    1.20 -		modplug_data *modplug;
    1.21 +        modplug_data *modplug;
    1.22  #endif
    1.23  #ifdef MOD_MUSIC
    1.24 -		struct MODULE *module;
    1.25 +        struct MODULE *module;
    1.26  #endif
    1.27  #ifdef MID_MUSIC
    1.28  #ifdef USE_TIMIDITY_MIDI
    1.29 -		MidiSong *midi;
    1.30 +        MidiSong *midi;
    1.31  #endif
    1.32  #ifdef USE_FLUIDSYNTH_MIDI
    1.33 -		FluidSynthMidiSong *fluidsynthmidi;
    1.34 +        FluidSynthMidiSong *fluidsynthmidi;
    1.35  #endif
    1.36  #ifdef USE_NATIVE_MIDI
    1.37 -		NativeMidiSong *nativemidi;
    1.38 +        NativeMidiSong *nativemidi;
    1.39  #endif
    1.40  #endif
    1.41  #ifdef OGG_MUSIC
    1.42 -		OGG_music *ogg;
    1.43 +        OGG_music *ogg;
    1.44  #endif
    1.45  #ifdef MP3_MUSIC
    1.46 -		SMPEG *mp3;
    1.47 +        SMPEG *mp3;
    1.48  #endif
    1.49  #ifdef MP3_MAD_MUSIC
    1.50 -		mad_data *mp3_mad;
    1.51 +        mad_data *mp3_mad;
    1.52  #endif
    1.53  #ifdef FLAC_MUSIC
    1.54 -		FLAC_music *flac;
    1.55 +        FLAC_music *flac;
    1.56  #endif
    1.57 -	} data;
    1.58 -	Mix_Fading fading;
    1.59 -	int fade_step;
    1.60 -	int fade_steps;
    1.61 -	int error;
    1.62 +    } data;
    1.63 +    Mix_Fading fading;
    1.64 +    int fade_step;
    1.65 +    int fade_steps;
    1.66 +    int error;
    1.67  };
    1.68  #ifdef MID_MUSIC
    1.69  #ifdef USE_TIMIDITY_MIDI
    1.70 @@ -150,25 +150,25 @@
    1.71  
    1.72  int Mix_GetNumMusicDecoders(void)
    1.73  {
    1.74 -	return(num_decoders);
    1.75 +    return(num_decoders);
    1.76  }
    1.77  
    1.78  const char *Mix_GetMusicDecoder(int index)
    1.79  {
    1.80 -	if ((index < 0) || (index >= num_decoders)) {
    1.81 -		return NULL;
    1.82 -	}
    1.83 -	return(music_decoders[index]);
    1.84 +    if ((index < 0) || (index >= num_decoders)) {
    1.85 +        return NULL;
    1.86 +    }
    1.87 +    return(music_decoders[index]);
    1.88  }
    1.89  
    1.90  static void add_music_decoder(const char *decoder)
    1.91  {
    1.92 -	void *ptr = SDL_realloc(music_decoders, (num_decoders + 1) * sizeof (const char **));
    1.93 -	if (ptr == NULL) {
    1.94 -		return;  /* oh well, go on without it. */
    1.95 -	}
    1.96 -	music_decoders = (const char **) ptr;
    1.97 -	music_decoders[num_decoders++] = decoder;
    1.98 +    void *ptr = SDL_realloc(music_decoders, (num_decoders + 1) * sizeof (const char **));
    1.99 +    if (ptr == NULL) {
   1.100 +        return;  /* oh well, go on without it. */
   1.101 +    }
   1.102 +    music_decoders = (const char **) ptr;
   1.103 +    music_decoders[num_decoders++] = decoder;
   1.104  }
   1.105  
   1.106  /* Local low-level functions prototypes */
   1.107 @@ -185,9 +185,9 @@
   1.108  
   1.109  void Mix_HookMusicFinished(void (*music_finished)(void))
   1.110  {
   1.111 -	SDL_LockAudio();
   1.112 -	music_finished_hook = music_finished;
   1.113 -	SDL_UnlockAudio();
   1.114 +    SDL_LockAudio();
   1.115 +    music_finished_hook = music_finished;
   1.116 +    SDL_UnlockAudio();
   1.117  }
   1.118  
   1.119  
   1.120 @@ -195,37 +195,37 @@
   1.121  /* otherwhise. NOP if the music is playing */
   1.122  static int music_halt_or_loop (void)
   1.123  {
   1.124 -	/* Restart music if it has to loop */
   1.125 -	
   1.126 -	if (!music_internal_playing()) 
   1.127 -	{
   1.128 +    /* Restart music if it has to loop */
   1.129 +
   1.130 +    if (!music_internal_playing())
   1.131 +    {
   1.132  #ifdef USE_NATIVE_MIDI
   1.133 -		/* Native MIDI handles looping internally */
   1.134 -		if (music_playing->type == MUS_MID && native_midi_ok) {
   1.135 -			music_loops = 0;
   1.136 -		}
   1.137 +        /* Native MIDI handles looping internally */
   1.138 +        if (music_playing->type == MUS_MID && native_midi_ok) {
   1.139 +            music_loops = 0;
   1.140 +        }
   1.141  #endif
   1.142  
   1.143 -		/* Restart music if it has to loop at a high level */
   1.144 -		if (music_loops)
   1.145 -		{
   1.146 -			Mix_Fading current_fade;
   1.147 -			--music_loops;
   1.148 -			current_fade = music_playing->fading;
   1.149 -			music_internal_play(music_playing, 0.0);
   1.150 -			music_playing->fading = current_fade;
   1.151 -		} 
   1.152 -		else 
   1.153 -		{
   1.154 -			music_internal_halt();
   1.155 -			if (music_finished_hook)
   1.156 -				music_finished_hook();
   1.157 -			
   1.158 -			return 0;
   1.159 -		}
   1.160 -	}
   1.161 -	
   1.162 -	return 1;
   1.163 +        /* Restart music if it has to loop at a high level */
   1.164 +        if (music_loops)
   1.165 +        {
   1.166 +            Mix_Fading current_fade;
   1.167 +            --music_loops;
   1.168 +            current_fade = music_playing->fading;
   1.169 +            music_internal_play(music_playing, 0.0);
   1.170 +            music_playing->fading = current_fade;
   1.171 +        }
   1.172 +        else
   1.173 +        {
   1.174 +            music_internal_halt();
   1.175 +            if (music_finished_hook)
   1.176 +                music_finished_hook();
   1.177 +
   1.178 +            return 0;
   1.179 +        }
   1.180 +    }
   1.181 +
   1.182 +    return 1;
   1.183  }
   1.184  
   1.185  
   1.186 @@ -233,227 +233,227 @@
   1.187  /* Mixing function */
   1.188  void music_mixer(void *udata, Uint8 *stream, int len)
   1.189  {
   1.190 -	int left = 0;
   1.191 +    int left = 0;
   1.192  
   1.193 -	if ( music_playing && music_active ) {
   1.194 -		/* Handle fading */
   1.195 -		if ( music_playing->fading != MIX_NO_FADING ) {
   1.196 -			if ( music_playing->fade_step++ < music_playing->fade_steps ) {
   1.197 -				int volume;
   1.198 -				int fade_step = music_playing->fade_step;
   1.199 -				int fade_steps = music_playing->fade_steps;
   1.200 +    if ( music_playing && music_active ) {
   1.201 +        /* Handle fading */
   1.202 +        if ( music_playing->fading != MIX_NO_FADING ) {
   1.203 +            if ( music_playing->fade_step++ < music_playing->fade_steps ) {
   1.204 +                int volume;
   1.205 +                int fade_step = music_playing->fade_step;
   1.206 +                int fade_steps = music_playing->fade_steps;
   1.207  
   1.208 -				if ( music_playing->fading == MIX_FADING_OUT ) {
   1.209 -					volume = (music_volume * (fade_steps-fade_step)) / fade_steps;
   1.210 -				} else { /* Fading in */
   1.211 -					volume = (music_volume * fade_step) / fade_steps;
   1.212 -				}
   1.213 -				music_internal_volume(volume);
   1.214 -			} else {
   1.215 -				if ( music_playing->fading == MIX_FADING_OUT ) {
   1.216 -					music_internal_halt();
   1.217 -					if ( music_finished_hook ) {
   1.218 -						music_finished_hook();
   1.219 -					}
   1.220 -					return;
   1.221 -				}
   1.222 -				music_playing->fading = MIX_NO_FADING;
   1.223 -			}
   1.224 -		}
   1.225 -		
   1.226 -		music_halt_or_loop();
   1.227 -		if (!music_internal_playing())
   1.228 -			return;
   1.229 +                if ( music_playing->fading == MIX_FADING_OUT ) {
   1.230 +                    volume = (music_volume * (fade_steps-fade_step)) / fade_steps;
   1.231 +                } else { /* Fading in */
   1.232 +                    volume = (music_volume * fade_step) / fade_steps;
   1.233 +                }
   1.234 +                music_internal_volume(volume);
   1.235 +            } else {
   1.236 +                if ( music_playing->fading == MIX_FADING_OUT ) {
   1.237 +                    music_internal_halt();
   1.238 +                    if ( music_finished_hook ) {
   1.239 +                        music_finished_hook();
   1.240 +                    }
   1.241 +                    return;
   1.242 +                }
   1.243 +                music_playing->fading = MIX_NO_FADING;
   1.244 +            }
   1.245 +        }
   1.246  
   1.247 -		switch (music_playing->type) {
   1.248 +        music_halt_or_loop();
   1.249 +        if (!music_internal_playing())
   1.250 +            return;
   1.251 +
   1.252 +        switch (music_playing->type) {
   1.253  #ifdef CMD_MUSIC
   1.254 -			case MUS_CMD:
   1.255 -				/* The playing is done externally */
   1.256 -				break;
   1.257 +            case MUS_CMD:
   1.258 +                /* The playing is done externally */
   1.259 +                break;
   1.260  #endif
   1.261  #ifdef WAV_MUSIC
   1.262 -			case MUS_WAV:
   1.263 -				left = WAVStream_PlaySome(stream, len);
   1.264 -				break;
   1.265 +            case MUS_WAV:
   1.266 +                left = WAVStream_PlaySome(stream, len);
   1.267 +                break;
   1.268  #endif
   1.269  #ifdef MODPLUG_MUSIC
   1.270 -			case MUS_MODPLUG:
   1.271 -				left = modplug_playAudio(music_playing->data.modplug, stream, len);
   1.272 -				break;
   1.273 +            case MUS_MODPLUG:
   1.274 +                left = modplug_playAudio(music_playing->data.modplug, stream, len);
   1.275 +                break;
   1.276  #endif
   1.277  #ifdef MOD_MUSIC
   1.278 -			case MUS_MOD:
   1.279 -				left = MOD_playAudio(music_playing->data.module, stream, len);
   1.280 -				break;
   1.281 +            case MUS_MOD:
   1.282 +                left = MOD_playAudio(music_playing->data.module, stream, len);
   1.283 +                break;
   1.284  #endif
   1.285  #ifdef MID_MUSIC
   1.286 -			case MUS_MID:
   1.287 +            case MUS_MID:
   1.288  #ifdef USE_NATIVE_MIDI
   1.289 -  				if ( native_midi_ok ) {
   1.290 -					/* Native midi is handled asynchronously */
   1.291 -					goto skip;
   1.292 -	  			}
   1.293 +                if ( native_midi_ok ) {
   1.294 +                    /* Native midi is handled asynchronously */
   1.295 +                    goto skip;
   1.296 +                }
   1.297  #endif
   1.298  #ifdef USE_FLUIDSYNTH_MIDI
   1.299 -				if ( fluidsynth_ok ) {
   1.300 -					fluidsynth_playsome(music_playing->data.fluidsynthmidi, stream, len);
   1.301 -					goto skip;
   1.302 -				}
   1.303 +                if ( fluidsynth_ok ) {
   1.304 +                    fluidsynth_playsome(music_playing->data.fluidsynthmidi, stream, len);
   1.305 +                    goto skip;
   1.306 +                }
   1.307  #endif
   1.308  #ifdef USE_TIMIDITY_MIDI
   1.309 -				if ( timidity_ok ) {
   1.310 -					int samples = len / samplesize;
   1.311 -  					Timidity_PlaySome(stream, samples);
   1.312 -					goto skip;
   1.313 -				}
   1.314 +                if ( timidity_ok ) {
   1.315 +                    int samples = len / samplesize;
   1.316 +                    Timidity_PlaySome(stream, samples);
   1.317 +                    goto skip;
   1.318 +                }
   1.319  #endif
   1.320 -				break;
   1.321 +                break;
   1.322  #endif
   1.323  #ifdef OGG_MUSIC
   1.324 -			case MUS_OGG:
   1.325 -				
   1.326 -				left = OGG_playAudio(music_playing->data.ogg, stream, len);
   1.327 -				break;
   1.328 +            case MUS_OGG:
   1.329 +
   1.330 +                left = OGG_playAudio(music_playing->data.ogg, stream, len);
   1.331 +                break;
   1.332  #endif
   1.333  #ifdef FLAC_MUSIC
   1.334 -			case MUS_FLAC:
   1.335 -				left = FLAC_playAudio(music_playing->data.flac, stream, len);
   1.336 -				break;
   1.337 +            case MUS_FLAC:
   1.338 +                left = FLAC_playAudio(music_playing->data.flac, stream, len);
   1.339 +                break;
   1.340  #endif
   1.341  #ifdef MP3_MUSIC
   1.342 -			case MUS_MP3:
   1.343 -				left = (len - smpeg.SMPEG_playAudio(music_playing->data.mp3, stream, len));
   1.344 -				break;
   1.345 +            case MUS_MP3:
   1.346 +                left = (len - smpeg.SMPEG_playAudio(music_playing->data.mp3, stream, len));
   1.347 +                break;
   1.348  #endif
   1.349  #ifdef MP3_MAD_MUSIC
   1.350 -			case MUS_MP3_MAD:
   1.351 -				left = mad_getSamples(music_playing->data.mp3_mad, stream, len);
   1.352 -				break;
   1.353 +            case MUS_MP3_MAD:
   1.354 +                left = mad_getSamples(music_playing->data.mp3_mad, stream, len);
   1.355 +                break;
   1.356  #endif
   1.357 -			default:
   1.358 -				/* Unknown music type?? */
   1.359 -				break;
   1.360 -		}
   1.361 -	}
   1.362 +            default:
   1.363 +                /* Unknown music type?? */
   1.364 +                break;
   1.365 +        }
   1.366 +    }
   1.367  
   1.368  skip:
   1.369 -	/* Handle seamless music looping */
   1.370 -	if (left > 0 && left < len) {
   1.371 -		music_halt_or_loop();
   1.372 -		if (music_internal_playing())
   1.373 -			music_mixer(udata, stream+(len-left), left);
   1.374 -	}
   1.375 +    /* Handle seamless music looping */
   1.376 +    if (left > 0 && left < len) {
   1.377 +        music_halt_or_loop();
   1.378 +        if (music_internal_playing())
   1.379 +            music_mixer(udata, stream+(len-left), left);
   1.380 +    }
   1.381  }
   1.382  
   1.383  /* Initialize the music players with a certain desired audio format */
   1.384  int open_music(SDL_AudioSpec *mixer)
   1.385  {
   1.386  #ifdef WAV_MUSIC
   1.387 -	if ( WAVStream_Init(mixer) == 0 ) {
   1.388 -		add_music_decoder("WAVE");
   1.389 -	}
   1.390 +    if ( WAVStream_Init(mixer) == 0 ) {
   1.391 +        add_music_decoder("WAVE");
   1.392 +    }
   1.393  #endif
   1.394  #ifdef MODPLUG_MUSIC
   1.395 -	if ( modplug_init(mixer) == 0 ) {
   1.396 -		add_music_decoder("MODPLUG");
   1.397 -	}
   1.398 +    if ( modplug_init(mixer) == 0 ) {
   1.399 +        add_music_decoder("MODPLUG");
   1.400 +    }
   1.401  #endif
   1.402  #ifdef MOD_MUSIC
   1.403 -	if ( MOD_init(mixer) == 0 ) {
   1.404 -		add_music_decoder("MIKMOD");
   1.405 -	}
   1.406 +    if ( MOD_init(mixer) == 0 ) {
   1.407 +        add_music_decoder("MIKMOD");
   1.408 +    }
   1.409  #endif
   1.410  #ifdef MID_MUSIC
   1.411  #ifdef USE_TIMIDITY_MIDI
   1.412 -	samplesize = mixer->size / mixer->samples;
   1.413 -	if ( Timidity_Init(mixer->freq, mixer->format,
   1.414 -	                    mixer->channels, mixer->samples) == 0 ) {
   1.415 -		timidity_ok = 1;
   1.416 -		add_music_decoder("TIMIDITY");
   1.417 -	} else {
   1.418 -		timidity_ok = 0;
   1.419 -	}
   1.420 +    samplesize = mixer->size / mixer->samples;
   1.421 +    if ( Timidity_Init(mixer->freq, mixer->format,
   1.422 +                        mixer->channels, mixer->samples) == 0 ) {
   1.423 +        timidity_ok = 1;
   1.424 +        add_music_decoder("TIMIDITY");
   1.425 +    } else {
   1.426 +        timidity_ok = 0;
   1.427 +    }
   1.428  #endif
   1.429  #ifdef USE_FLUIDSYNTH_MIDI
   1.430 -	if ( fluidsynth_init(mixer) == 0 ) {
   1.431 -		fluidsynth_ok = 1;
   1.432 -		add_music_decoder("FLUIDSYNTH");
   1.433 -	} else {
   1.434 -		fluidsynth_ok = 0;
   1.435 -	}
   1.436 +    if ( fluidsynth_init(mixer) == 0 ) {
   1.437 +        fluidsynth_ok = 1;
   1.438 +        add_music_decoder("FLUIDSYNTH");
   1.439 +    } else {
   1.440 +        fluidsynth_ok = 0;
   1.441 +    }
   1.442  #endif
   1.443  #ifdef USE_NATIVE_MIDI
   1.444  #ifdef USE_FLUIDSYNTH_MIDI
   1.445 -	native_midi_ok = !fluidsynth_ok;
   1.446 -	if ( native_midi_ok )
   1.447 +    native_midi_ok = !fluidsynth_ok;
   1.448 +    if ( native_midi_ok )
   1.449  #endif
   1.450  #ifdef USE_TIMIDITY_MIDI
   1.451 -		native_midi_ok = !timidity_ok;
   1.452 -	if ( !native_midi_ok ) {
   1.453 -		native_midi_ok = (getenv("SDL_NATIVE_MUSIC") != NULL);
   1.454 -	}
   1.455 -	if ( native_midi_ok )
   1.456 +        native_midi_ok = !timidity_ok;
   1.457 +    if ( !native_midi_ok ) {
   1.458 +        native_midi_ok = (getenv("SDL_NATIVE_MUSIC") != NULL);
   1.459 +    }
   1.460 +    if ( native_midi_ok )
   1.461  #endif
   1.462 -		native_midi_ok = native_midi_detect();
   1.463 -	if ( native_midi_ok )
   1.464 -		add_music_decoder("NATIVEMIDI");
   1.465 +        native_midi_ok = native_midi_detect();
   1.466 +    if ( native_midi_ok )
   1.467 +        add_music_decoder("NATIVEMIDI");
   1.468  #endif
   1.469  #endif
   1.470  #ifdef OGG_MUSIC
   1.471 -	if ( OGG_init(mixer) == 0 ) {
   1.472 -		add_music_decoder("OGG");
   1.473 -	}
   1.474 +    if ( OGG_init(mixer) == 0 ) {
   1.475 +        add_music_decoder("OGG");
   1.476 +    }
   1.477  #endif
   1.478  #ifdef FLAC_MUSIC
   1.479 -	if ( FLAC_init(mixer) == 0 ) {
   1.480 -		add_music_decoder("FLAC");
   1.481 -	}
   1.482 +    if ( FLAC_init(mixer) == 0 ) {
   1.483 +        add_music_decoder("FLAC");
   1.484 +    }
   1.485  #endif
   1.486  #if defined(MP3_MUSIC) || defined(MP3_MAD_MUSIC)
   1.487 -	/* Keep a copy of the mixer */
   1.488 -	used_mixer = *mixer;
   1.489 -	add_music_decoder("MP3");
   1.490 +    /* Keep a copy of the mixer */
   1.491 +    used_mixer = *mixer;
   1.492 +    add_music_decoder("MP3");
   1.493  #endif
   1.494  
   1.495 -	music_playing = NULL;
   1.496 -	music_stopped = 0;
   1.497 -	Mix_VolumeMusic(SDL_MIX_MAXVOLUME);
   1.498 +    music_playing = NULL;
   1.499 +    music_stopped = 0;
   1.500 +    Mix_VolumeMusic(SDL_MIX_MAXVOLUME);
   1.501  
   1.502 -	/* Calculate the number of ms for each callback */
   1.503 -	ms_per_step = (int) (((float)mixer->samples * 1000.0) / mixer->freq);
   1.504 +    /* Calculate the number of ms for each callback */
   1.505 +    ms_per_step = (int) (((float)mixer->samples * 1000.0) / mixer->freq);
   1.506  
   1.507 -	return(0);
   1.508 +    return(0);
   1.509  }
   1.510  
   1.511  /* Portable case-insensitive string compare function */
   1.512  int MIX_string_equals(const char *str1, const char *str2)
   1.513  {
   1.514 -	while ( *str1 && *str2 ) {
   1.515 -		if ( toupper((unsigned char)*str1) !=
   1.516 -		     toupper((unsigned char)*str2) )
   1.517 -			break;
   1.518 -		++str1;
   1.519 -		++str2;
   1.520 -	}
   1.521 -	return (!*str1 && !*str2);
   1.522 +    while ( *str1 && *str2 ) {
   1.523 +        if ( toupper((unsigned char)*str1) !=
   1.524 +             toupper((unsigned char)*str2) )
   1.525 +            break;
   1.526 +        ++str1;
   1.527 +        ++str2;
   1.528 +    }
   1.529 +    return (!*str1 && !*str2);
   1.530  }
   1.531  
   1.532  static int detect_mp3(Uint8 *magic)
   1.533  {
   1.534 -	if ( strncmp((char *)magic, "ID3", 3) == 0 ) {
   1.535 -		return 1;
   1.536 -	}
   1.537 +    if ( strncmp((char *)magic, "ID3", 3) == 0 ) {
   1.538 +        return 1;
   1.539 +    }
   1.540  
   1.541 -	/* Detection code lifted from SMPEG */
   1.542 -	if(((magic[0] & 0xff) != 0xff) || // No sync bits
   1.543 -	   ((magic[1] & 0xf0) != 0xf0) || //
   1.544 -	   ((magic[2] & 0xf0) == 0x00) || // Bitrate is 0
   1.545 -	   ((magic[2] & 0xf0) == 0xf0) || // Bitrate is 15
   1.546 -	   ((magic[2] & 0x0c) == 0x0c) || // Frequency is 3
   1.547 -	   ((magic[1] & 0x06) == 0x00)) { // Layer is 4
   1.548 -		return(0);
   1.549 -	}
   1.550 -	return 1;
   1.551 +    /* Detection code lifted from SMPEG */
   1.552 +    if(((magic[0] & 0xff) != 0xff) || // No sync bits
   1.553 +       ((magic[1] & 0xf0) != 0xf0) || //
   1.554 +       ((magic[2] & 0xf0) == 0x00) || // Bitrate is 0
   1.555 +       ((magic[2] & 0xf0) == 0xf0) || // Bitrate is 15
   1.556 +       ((magic[2] & 0x0c) == 0x0c) || // Frequency is 3
   1.557 +       ((magic[1] & 0x06) == 0x00)) { // Layer is 4
   1.558 +        return(0);
   1.559 +    }
   1.560 +    return 1;
   1.561  }
   1.562  
   1.563  /* MUS_MOD can't be auto-detected. If no other format was detected, MOD is
   1.564 @@ -463,383 +463,384 @@
   1.565   * Returns MUS_NONE in case of errors. */
   1.566  static Mix_MusicType detect_music_type(SDL_RWops *rw)
   1.567  {
   1.568 -	Uint8 magic[5];
   1.569 -	Uint8 moremagic[9];
   1.570 +    Uint8 magic[5];
   1.571 +    Uint8 moremagic[9];
   1.572  
   1.573 -	int start = SDL_RWtell(rw);
   1.574 -	if (SDL_RWread(rw, magic, 1, 4) != 4 || SDL_RWread(rw, moremagic, 1, 8) != 8 ) {
   1.575 -		Mix_SetError("Couldn't read from RWops");
   1.576 -		return MUS_NONE;
   1.577 -	}
   1.578 -	SDL_RWseek(rw, start, RW_SEEK_SET);
   1.579 -	magic[4]='\0';
   1.580 -	moremagic[8] = '\0';
   1.581 +    int start = SDL_RWtell(rw);
   1.582 +    if (SDL_RWread(rw, magic, 1, 4) != 4 || SDL_RWread(rw, moremagic, 1, 8) != 8 ) {
   1.583 +        Mix_SetError("Couldn't read from RWops");
   1.584 +        return MUS_NONE;
   1.585 +    }
   1.586 +    SDL_RWseek(rw, start, RW_SEEK_SET);
   1.587 +    magic[4]='\0';
   1.588 +    moremagic[8] = '\0';
   1.589  
   1.590 -	/* WAVE files have the magic four bytes "RIFF"
   1.591 -	   AIFF files have the magic 12 bytes "FORM" XXXX "AIFF" */
   1.592 -	if (((strcmp((char *)magic, "RIFF") == 0) && (strcmp((char *)(moremagic+4), "WAVE") == 0)) ||
   1.593 -		(strcmp((char *)magic, "FORM") == 0)) {
   1.594 -		return MUS_WAV;
   1.595 -	}
   1.596 +    /* WAVE files have the magic four bytes "RIFF"
   1.597 +       AIFF files have the magic 12 bytes "FORM" XXXX "AIFF" */
   1.598 +    if (((strcmp((char *)magic, "RIFF") == 0) && (strcmp((char *)(moremagic+4), "WAVE") == 0)) ||
   1.599 +        (strcmp((char *)magic, "FORM") == 0)) {
   1.600 +        return MUS_WAV;
   1.601 +    }
   1.602  
   1.603 -	/* Ogg Vorbis files have the magic four bytes "OggS" */
   1.604 -	if (strcmp((char *)magic, "OggS") == 0) {
   1.605 -		return MUS_OGG;
   1.606 -	}
   1.607 +    /* Ogg Vorbis files have the magic four bytes "OggS" */
   1.608 +    if (strcmp((char *)magic, "OggS") == 0) {
   1.609 +        return MUS_OGG;
   1.610 +    }
   1.611  
   1.612 -	/* FLAC files have the magic four bytes "fLaC" */
   1.613 -	if (strcmp((char *)magic, "fLaC") == 0) {
   1.614 -		return MUS_FLAC;
   1.615 -	}
   1.616 +    /* FLAC files have the magic four bytes "fLaC" */
   1.617 +    if (strcmp((char *)magic, "fLaC") == 0) {
   1.618 +        return MUS_FLAC;
   1.619 +    }
   1.620  
   1.621 -	/* MIDI files have the magic four bytes "MThd" */
   1.622 -	if (strcmp((char *)magic, "MThd") == 0) {
   1.623 -		return MUS_MID;
   1.624 -	}
   1.625 +    /* MIDI files have the magic four bytes "MThd" */
   1.626 +    if (strcmp((char *)magic, "MThd") == 0) {
   1.627 +        return MUS_MID;
   1.628 +    }
   1.629  
   1.630 -	if (detect_mp3(magic)) {
   1.631 -		return MUS_MP3;
   1.632 -	}
   1.633 +    if (detect_mp3(magic)) {
   1.634 +        return MUS_MP3;
   1.635 +    }
   1.636  
   1.637 -	/* Assume MOD format.
   1.638 -	 *
   1.639 -	 * Apparently there is no way to check if the file is really a MOD,
   1.640 -	 * or there are too many formats supported by MikMod/ModPlug, or
   1.641 -	 * MikMod/ModPlug does this check by itself. */
   1.642 -	return MUS_MOD;
   1.643 +    /* Assume MOD format.
   1.644 +     *
   1.645 +     * Apparently there is no way to check if the file is really a MOD,
   1.646 +     * or there are too many formats supported by MikMod/ModPlug, or
   1.647 +     * MikMod/ModPlug does this check by itself. */
   1.648 +    return MUS_MOD;
   1.649  }
   1.650  
   1.651  /* Load a music file */
   1.652  Mix_Music *Mix_LoadMUS(const char *file)
   1.653  {
   1.654 -	SDL_RWops *rw;
   1.655 -	Mix_Music *music;
   1.656 -	Mix_MusicType type;
   1.657 -	char *ext = strrchr(file, '.');
   1.658 +    SDL_RWops *rw;
   1.659 +    Mix_Music *music;
   1.660 +    Mix_MusicType type;
   1.661 +    char *ext = strrchr(file, '.');
   1.662  
   1.663  #ifdef CMD_MUSIC
   1.664 -	if ( music_cmd ) {
   1.665 -		/* Allocate memory for the music structure */
   1.666 -		music = (Mix_Music *)SDL_malloc(sizeof(Mix_Music));
   1.667 -		if ( music == NULL ) {
   1.668 -			Mix_SetError("Out of memory");
   1.669 -			return(NULL);
   1.670 -		}
   1.671 -		music->error = 0;
   1.672 -		music->type = MUS_CMD;
   1.673 -		music->data.cmd = MusicCMD_LoadSong(music_cmd, file);
   1.674 -		if ( music->data.cmd == NULL ) {
   1.675 -			SDL_free(music);
   1.676 -			music = NULL;
   1.677 -		}
   1.678 -		return music;
   1.679 -	}
   1.680 +    if ( music_cmd ) {
   1.681 +        /* Allocate memory for the music structure */
   1.682 +        music = (Mix_Music *)SDL_malloc(sizeof(Mix_Music));
   1.683 +        if ( music == NULL ) {
   1.684 +            Mix_SetError("Out of memory");
   1.685 +            return(NULL);
   1.686 +        }
   1.687 +        music->error = 0;
   1.688 +        music->type = MUS_CMD;
   1.689 +        music->data.cmd = MusicCMD_LoadSong(music_cmd, file);
   1.690 +        if ( music->data.cmd == NULL ) {
   1.691 +            SDL_free(music);
   1.692 +            music = NULL;
   1.693 +        }
   1.694 +        return music;
   1.695 +    }
   1.696  #endif
   1.697  
   1.698 -	rw = SDL_RWFromFile(file, "rb");
   1.699 -	if ( rw == NULL ) {
   1.700 -		Mix_SetError("Couldn't open '%s'", file);
   1.701 -		return NULL;
   1.702 -	}
   1.703 +    rw = SDL_RWFromFile(file, "rb");
   1.704 +    if ( rw == NULL ) {
   1.705 +        Mix_SetError("Couldn't open '%s'", file);
   1.706 +        return NULL;
   1.707 +    }
   1.708  
   1.709 -	/* Use the extension as a first guess on the file type */
   1.710 -	type = MUS_NONE;
   1.711 -	ext = strrchr(file, '.');
   1.712 -	/* No need to guard these with #ifdef *_MUSIC stuff,
   1.713 -	 * since we simply call Mix_LoadMUSType_RW() later */
   1.714 -	if ( ext ) {
   1.715 -		++ext; /* skip the dot in the extension */
   1.716 -		if ( MIX_string_equals(ext, "WAV") ) {
   1.717 -			type = MUS_WAV;
   1.718 -		} else if ( MIX_string_equals(ext, "MID") ||
   1.719 -		            MIX_string_equals(ext, "MIDI") ||
   1.720 -		            MIX_string_equals(ext, "KAR") ) {
   1.721 -			type = MUS_MID;
   1.722 -		} else if ( MIX_string_equals(ext, "OGG") ) {
   1.723 -			type = MUS_OGG;
   1.724 -		} else if ( MIX_string_equals(ext, "FLAC") ) {
   1.725 -			type = MUS_FLAC;
   1.726 -		} else 	if ( MIX_string_equals(ext, "MPG") ||
   1.727 -		             MIX_string_equals(ext, "MPEG") ||
   1.728 -		             MIX_string_equals(ext, "MP3") ||
   1.729 -		             MIX_string_equals(ext, "MAD") ) {
   1.730 -			type = MUS_MP3;
   1.731 -		}
   1.732 -	}
   1.733 -	if ( type == MUS_NONE ) {
   1.734 -		type = detect_music_type(rw);
   1.735 -	}
   1.736 +    /* Use the extension as a first guess on the file type */
   1.737 +    type = MUS_NONE;
   1.738 +    ext = strrchr(file, '.');
   1.739 +    /* No need to guard these with #ifdef *_MUSIC stuff,
   1.740 +     * since we simply call Mix_LoadMUSType_RW() later */
   1.741 +    if ( ext ) {
   1.742 +        ++ext; /* skip the dot in the extension */
   1.743 +        if ( MIX_string_equals(ext, "WAV") ) {
   1.744 +            type = MUS_WAV;
   1.745 +        } else if ( MIX_string_equals(ext, "MID") ||
   1.746 +                    MIX_string_equals(ext, "MIDI") ||
   1.747 +                    MIX_string_equals(ext, "KAR") ) {
   1.748 +            type = MUS_MID;
   1.749 +        } else if ( MIX_string_equals(ext, "OGG") ) {
   1.750 +            type = MUS_OGG;
   1.751 +        } else if ( MIX_string_equals(ext, "FLAC") ) {
   1.752 +            type = MUS_FLAC;
   1.753 +        } else  if ( MIX_string_equals(ext, "MPG") ||
   1.754 +                     MIX_string_equals(ext, "MPEG") ||
   1.755 +                     MIX_string_equals(ext, "MP3") ||
   1.756 +                     MIX_string_equals(ext, "MAD") ) {
   1.757 +            type = MUS_MP3;
   1.758 +        }
   1.759 +    }
   1.760 +    if ( type == MUS_NONE ) {
   1.761 +        type = detect_music_type(rw);
   1.762 +    }
   1.763  
   1.764 -	/* We need to know if a specific error occurs; if not, we'll set a
   1.765 -	 * generic one, so we clear the current one. */
   1.766 -	Mix_SetError("");
   1.767 -	music = Mix_LoadMUSType_RW(rw, type, SDL_TRUE);
   1.768 -	if ( music == NULL && Mix_GetError()[0] == '\0' ) {
   1.769 -		SDL_FreeRW(rw);
   1.770 -		Mix_SetError("Couldn't open '%s'", file);
   1.771 -	}
   1.772 -	return music;
   1.773 +    /* We need to know if a specific error occurs; if not, we'll set a
   1.774 +     * generic one, so we clear the current one. */
   1.775 +    Mix_SetError("");
   1.776 +    music = Mix_LoadMUSType_RW(rw, type, SDL_TRUE);
   1.777 +    if ( music == NULL && Mix_GetError()[0] == '\0' ) {
   1.778 +        SDL_FreeRW(rw);
   1.779 +        Mix_SetError("Couldn't open '%s'", file);
   1.780 +    }
   1.781 +    return music;
   1.782  }
   1.783  
   1.784  Mix_Music *Mix_LoadMUS_RW(SDL_RWops *rw)
   1.785  {
   1.786 -	return Mix_LoadMUSType_RW(rw, MUS_NONE, SDL_FALSE);
   1.787 +    return Mix_LoadMUSType_RW(rw, MUS_NONE, SDL_FALSE);
   1.788  }
   1.789  
   1.790  Mix_Music *Mix_LoadMUSType_RW(SDL_RWops *rw, Mix_MusicType type, int freesrc)
   1.791  {
   1.792 -	Mix_Music *music;
   1.793 +    Mix_Music *music;
   1.794  
   1.795 -	if (!rw) {
   1.796 -		Mix_SetError("RWops pointer is NULL");
   1.797 -		return NULL;
   1.798 -	}
   1.799 +    if (!rw) {
   1.800 +        Mix_SetError("RWops pointer is NULL");
   1.801 +        return NULL;
   1.802 +    }
   1.803  
   1.804 -	/* If the caller wants auto-detection, figure out what kind of file
   1.805 -	 * this is. */
   1.806 -	if (type == MUS_NONE) {
   1.807 -		if ((type = detect_music_type(rw)) == MUS_NONE) {
   1.808 -			/* Don't call Mix_SetError() here since detect_music_type()
   1.809 -			 * does that. */
   1.810 -			return NULL;
   1.811 -		}
   1.812 -	}
   1.813 +    /* If the caller wants auto-detection, figure out what kind of file
   1.814 +     * this is. */
   1.815 +    if (type == MUS_NONE) {
   1.816 +        if ((type = detect_music_type(rw)) == MUS_NONE) {
   1.817 +            /* Don't call Mix_SetError() here since detect_music_type()
   1.818 +             * does that. */
   1.819 +            return NULL;
   1.820 +        }
   1.821 +    }
   1.822  
   1.823 -	/* Allocate memory for the music structure */
   1.824 -	music = (Mix_Music *)SDL_malloc(sizeof(Mix_Music));
   1.825 -	if (music == NULL ) {
   1.826 -		Mix_SetError("Out of memory");
   1.827 -		return NULL;
   1.828 -	}
   1.829 -	music->error = 0;
   1.830 +    /* Allocate memory for the music structure */
   1.831 +    music = (Mix_Music *)SDL_malloc(sizeof(Mix_Music));
   1.832 +    if (music == NULL ) {
   1.833 +        Mix_SetError("Out of memory");
   1.834 +        return NULL;
   1.835 +    }
   1.836 +    music->error = 0;
   1.837  
   1.838 -	switch (type) {
   1.839 +    switch (type) {
   1.840  #ifdef WAV_MUSIC
   1.841 -	case MUS_WAV:
   1.842 -		/* The WAVE loader needs the first 4 bytes of the header */
   1.843 -		{
   1.844 -			Uint8 magic[5];
   1.845 -			int start = SDL_RWtell(rw);
   1.846 -			if (SDL_RWread(rw, magic, 1, 4) != 4) {
   1.847 -				Mix_SetError("Couldn't read from RWops");
   1.848 -				return MUS_NONE;
   1.849 -			}
   1.850 -			SDL_RWseek(rw, start, RW_SEEK_SET);
   1.851 -			magic[4] = '\0';
   1.852 -			music->type = MUS_WAV;
   1.853 -			music->data.wave = WAVStream_LoadSong_RW(rw, (char *)magic, freesrc);
   1.854 -		}
   1.855 -		if (music->data.wave == NULL) {
   1.856 -			music->error = 1;
   1.857 -		}
   1.858 -		break;
   1.859 +    case MUS_WAV:
   1.860 +        /* The WAVE loader needs the first 4 bytes of the header */
   1.861 +        {
   1.862 +            Uint8 magic[5];
   1.863 +            int start = SDL_RWtell(rw);
   1.864 +            if (SDL_RWread(rw, magic, 1, 4) != 4) {
   1.865 +                Mix_SetError("Couldn't read from RWops");
   1.866 +                SDL_free(music);
   1.867 +                return MUS_NONE;
   1.868 +            }
   1.869 +            SDL_RWseek(rw, start, RW_SEEK_SET);
   1.870 +            magic[4] = '\0';
   1.871 +            music->type = MUS_WAV;
   1.872 +            music->data.wave = WAVStream_LoadSong_RW(rw, (char *)magic, freesrc);
   1.873 +        }
   1.874 +        if (music->data.wave == NULL) {
   1.875 +            music->error = 1;
   1.876 +        }
   1.877 +        break;
   1.878  #endif
   1.879  #ifdef OGG_MUSIC
   1.880 -	case MUS_OGG:
   1.881 -		music->type = MUS_OGG;
   1.882 -		music->data.ogg = OGG_new_RW(rw, freesrc);
   1.883 -		if ( music->data.ogg == NULL ) {
   1.884 -			music->error = 1;
   1.885 -		}
   1.886 -		break;
   1.887 +    case MUS_OGG:
   1.888 +        music->type = MUS_OGG;
   1.889 +        music->data.ogg = OGG_new_RW(rw, freesrc);
   1.890 +        if ( music->data.ogg == NULL ) {
   1.891 +            music->error = 1;
   1.892 +        }
   1.893 +        break;
   1.894  #endif
   1.895  #ifdef FLAC_MUSIC
   1.896 -	case MUS_FLAC:
   1.897 -		music->type = MUS_FLAC;
   1.898 -		music->data.flac = FLAC_new_RW(rw, freesrc);
   1.899 -		if ( music->data.flac == NULL ) {
   1.900 -			music->error = 1;
   1.901 -		}
   1.902 -		break;
   1.903 +    case MUS_FLAC:
   1.904 +        music->type = MUS_FLAC;
   1.905 +        music->data.flac = FLAC_new_RW(rw, freesrc);
   1.906 +        if ( music->data.flac == NULL ) {
   1.907 +            music->error = 1;
   1.908 +        }
   1.909 +        break;
   1.910  #endif
   1.911  #ifdef MP3_MUSIC
   1.912 -	case MUS_MP3:
   1.913 -		if ( Mix_Init(MIX_INIT_MP3) ) {
   1.914 -			SMPEG_Info info;
   1.915 -			music->type = MUS_MP3;
   1.916 -			music->data.mp3 = smpeg.SMPEG_new_rwops(rw, &info, 0);
   1.917 -			if ( !info.has_audio ) {
   1.918 -				Mix_SetError("MPEG file does not have any audio stream.");
   1.919 -				music->error = 1;
   1.920 -			} else {
   1.921 -				smpeg.SMPEG_actualSpec(music->data.mp3, &used_mixer);
   1.922 -			}
   1.923 -		} else {
   1.924 -			music->error = 1;
   1.925 -		}
   1.926 -		break;
   1.927 +    case MUS_MP3:
   1.928 +        if ( Mix_Init(MIX_INIT_MP3) ) {
   1.929 +            SMPEG_Info info;
   1.930 +            music->type = MUS_MP3;
   1.931 +            music->data.mp3 = smpeg.SMPEG_new_rwops(rw, &info, 0);
   1.932 +            if ( !info.has_audio ) {
   1.933 +                Mix_SetError("MPEG file does not have any audio stream.");
   1.934 +                music->error = 1;
   1.935 +            } else {
   1.936 +                smpeg.SMPEG_actualSpec(music->data.mp3, &used_mixer);
   1.937 +            }
   1.938 +        } else {
   1.939 +            music->error = 1;
   1.940 +        }
   1.941 +        break;
   1.942  #elif defined(MP3_MAD_MUSIC)
   1.943 -	case MUS_MP3:
   1.944 -		music->type = MUS_MP3_MAD;
   1.945 -		music->data.mp3_mad = mad_openFileRW(rw, &used_mixer, freesrc);
   1.946 -		if (music->data.mp3_mad == 0) {
   1.947 -			Mix_SetError("Could not initialize MPEG stream.");
   1.948 -			music->error = 1;
   1.949 -		}
   1.950 -		break;
   1.951 +    case MUS_MP3:
   1.952 +        music->type = MUS_MP3_MAD;
   1.953 +        music->data.mp3_mad = mad_openFileRW(rw, &used_mixer, freesrc);
   1.954 +        if (music->data.mp3_mad == 0) {
   1.955 +            Mix_SetError("Could not initialize MPEG stream.");
   1.956 +            music->error = 1;
   1.957 +        }
   1.958 +        break;
   1.959  #endif
   1.960  #ifdef MID_MUSIC
   1.961 -	case MUS_MID:
   1.962 -		music->type = MUS_MID;
   1.963 +    case MUS_MID:
   1.964 +        music->type = MUS_MID;
   1.965  #ifdef USE_NATIVE_MIDI
   1.966 -		if ( native_midi_ok ) {
   1.967 -			music->data.nativemidi = native_midi_loadsong_RW(rw, freesrc);
   1.968 -	  		if ( music->data.nativemidi == NULL ) {
   1.969 -		  		Mix_SetError("%s", native_midi_error());
   1.970 -			  	music->error = 1;
   1.971 -			}
   1.972 -			break;
   1.973 -		}
   1.974 +        if ( native_midi_ok ) {
   1.975 +            music->data.nativemidi = native_midi_loadsong_RW(rw, freesrc);
   1.976 +            if ( music->data.nativemidi == NULL ) {
   1.977 +                Mix_SetError("%s", native_midi_error());
   1.978 +                music->error = 1;
   1.979 +            }
   1.980 +            break;
   1.981 +        }
   1.982  #endif
   1.983  #ifdef USE_FLUIDSYNTH_MIDI
   1.984 -		if ( fluidsynth_ok ) {
   1.985 -			music->data.fluidsynthmidi = fluidsynth_loadsong_RW(rw, freesrc);
   1.986 -			if ( music->data.fluidsynthmidi == NULL ) {
   1.987 -				music->error = 1;
   1.988 -			}
   1.989 -			break;
   1.990 -		}
   1.991 +        if ( fluidsynth_ok ) {
   1.992 +            music->data.fluidsynthmidi = fluidsynth_loadsong_RW(rw, freesrc);
   1.993 +            if ( music->data.fluidsynthmidi == NULL ) {
   1.994 +                music->error = 1;
   1.995 +            }
   1.996 +            break;
   1.997 +        }
   1.998  #endif
   1.999  #ifdef USE_TIMIDITY_MIDI
  1.1000 -		if ( timidity_ok ) {
  1.1001 -			music->data.midi = Timidity_LoadSong_RW(rw, freesrc);
  1.1002 -			if ( music->data.midi == NULL ) {
  1.1003 -				Mix_SetError("%s", Timidity_Error());
  1.1004 -				music->error = 1;
  1.1005 -			}
  1.1006 -		} else {
  1.1007 -			Mix_SetError("%s", Timidity_Error());
  1.1008 -			music->error = 1;
  1.1009 -		}
  1.1010 +        if ( timidity_ok ) {
  1.1011 +            music->data.midi = Timidity_LoadSong_RW(rw, freesrc);
  1.1012 +            if ( music->data.midi == NULL ) {
  1.1013 +                Mix_SetError("%s", Timidity_Error());
  1.1014 +                music->error = 1;
  1.1015 +            }
  1.1016 +        } else {
  1.1017 +            Mix_SetError("%s", Timidity_Error());
  1.1018 +            music->error = 1;
  1.1019 +        }
  1.1020  #endif
  1.1021 -		break;
  1.1022 +        break;
  1.1023  #endif
  1.1024  #if defined(MODPLUG_MUSIC) || defined(MOD_MUSIC)
  1.1025 -	case MUS_MOD:
  1.1026 -		music->error = 1;
  1.1027 +    case MUS_MOD:
  1.1028 +        music->error = 1;
  1.1029  #ifdef MODPLUG_MUSIC
  1.1030 -		if ( music->error ) {
  1.1031 -			music->type = MUS_MODPLUG;
  1.1032 -			music->data.modplug = modplug_new_RW(rw, freesrc);
  1.1033 -			if ( music->data.modplug ) {
  1.1034 -				music->error = 0;
  1.1035 -			}
  1.1036 -		}
  1.1037 +        if ( music->error ) {
  1.1038 +            music->type = MUS_MODPLUG;
  1.1039 +            music->data.modplug = modplug_new_RW(rw, freesrc);
  1.1040 +            if ( music->data.modplug ) {
  1.1041 +                music->error = 0;
  1.1042 +            }
  1.1043 +        }
  1.1044  #endif
  1.1045  #ifdef MOD_MUSIC
  1.1046 -		if ( music->error ) {
  1.1047 -			music->type = MUS_MOD;
  1.1048 -			music->data.module = MOD_new_RW(rw, freesrc);
  1.1049 -			if ( music->data.module ) {
  1.1050 -				music->error = 0;
  1.1051 -			}
  1.1052 -		}
  1.1053 +        if ( music->error ) {
  1.1054 +            music->type = MUS_MOD;
  1.1055 +            music->data.module = MOD_new_RW(rw, freesrc);
  1.1056 +            if ( music->data.module ) {
  1.1057 +                music->error = 0;
  1.1058 +            }
  1.1059 +        }
  1.1060  #endif
  1.1061 -		break;
  1.1062 +        break;
  1.1063  #endif
  1.1064  
  1.1065 -	default:
  1.1066 -		Mix_SetError("Unrecognized music format");
  1.1067 -		music->error=1;
  1.1068 -	} /* switch (want) */
  1.1069 +    default:
  1.1070 +        Mix_SetError("Unrecognized music format");
  1.1071 +        music->error=1;
  1.1072 +    } /* switch (want) */
  1.1073  
  1.1074  
  1.1075 -	if (music->error) {
  1.1076 -		SDL_free(music);
  1.1077 -		music=NULL;
  1.1078 -	}
  1.1079 -	return(music);
  1.1080 +    if (music->error) {
  1.1081 +        SDL_free(music);
  1.1082 +        music=NULL;
  1.1083 +    }
  1.1084 +    return(music);
  1.1085  }
  1.1086  
  1.1087  /* Free a music chunk previously loaded */
  1.1088  void Mix_FreeMusic(Mix_Music *music)
  1.1089  {
  1.1090 -	if ( music ) {
  1.1091 -		/* Stop the music if it's currently playing */
  1.1092 -		SDL_LockAudio();
  1.1093 -		if ( music == music_playing ) {
  1.1094 -			/* Wait for any fade out to finish */
  1.1095 -			while ( music->fading == MIX_FADING_OUT ) {
  1.1096 -				SDL_UnlockAudio();
  1.1097 -				SDL_Delay(100);
  1.1098 -				SDL_LockAudio();
  1.1099 -			}
  1.1100 -			if ( music == music_playing ) {
  1.1101 -				music_internal_halt();
  1.1102 -			}
  1.1103 -		}
  1.1104 -		SDL_UnlockAudio();
  1.1105 -		switch (music->type) {
  1.1106 +    if ( music ) {
  1.1107 +        /* Stop the music if it's currently playing */
  1.1108 +        SDL_LockAudio();
  1.1109 +        if ( music == music_playing ) {
  1.1110 +            /* Wait for any fade out to finish */
  1.1111 +            while ( music->fading == MIX_FADING_OUT ) {
  1.1112 +                SDL_UnlockAudio();
  1.1113 +                SDL_Delay(100);
  1.1114 +                SDL_LockAudio();
  1.1115 +            }
  1.1116 +            if ( music == music_playing ) {
  1.1117 +                music_internal_halt();
  1.1118 +            }
  1.1119 +        }
  1.1120 +        SDL_UnlockAudio();
  1.1121 +        switch (music->type) {
  1.1122  #ifdef CMD_MUSIC
  1.1123 -			case MUS_CMD:
  1.1124 -				MusicCMD_FreeSong(music->data.cmd);
  1.1125 -				break;
  1.1126 +            case MUS_CMD:
  1.1127 +                MusicCMD_FreeSong(music->data.cmd);
  1.1128 +                break;
  1.1129  #endif
  1.1130  #ifdef WAV_MUSIC
  1.1131 -			case MUS_WAV:
  1.1132 -				WAVStream_FreeSong(music->data.wave);
  1.1133 -				break;
  1.1134 +            case MUS_WAV:
  1.1135 +                WAVStream_FreeSong(music->data.wave);
  1.1136 +                break;
  1.1137  #endif
  1.1138  #ifdef MODPLUG_MUSIC
  1.1139 -			case MUS_MODPLUG:
  1.1140 -				modplug_delete(music->data.modplug);
  1.1141 -				break;
  1.1142 +            case MUS_MODPLUG:
  1.1143 +                modplug_delete(music->data.modplug);
  1.1144 +                break;
  1.1145  #endif
  1.1146  #ifdef MOD_MUSIC
  1.1147 -			case MUS_MOD:
  1.1148 -				MOD_delete(music->data.module);
  1.1149 -				break;
  1.1150 +            case MUS_MOD:
  1.1151 +                MOD_delete(music->data.module);
  1.1152 +                break;
  1.1153  #endif
  1.1154  #ifdef MID_MUSIC
  1.1155 -			case MUS_MID:
  1.1156 +            case MUS_MID:
  1.1157  #ifdef USE_NATIVE_MIDI
  1.1158 -  				if ( native_midi_ok ) {
  1.1159 -					native_midi_freesong(music->data.nativemidi);
  1.1160 -					goto skip;
  1.1161 -				}
  1.1162 +                if ( native_midi_ok ) {
  1.1163 +                    native_midi_freesong(music->data.nativemidi);
  1.1164 +                    goto skip;
  1.1165 +                }
  1.1166  #endif
  1.1167  #ifdef USE_FLUIDSYNTH_MIDI
  1.1168 -				if ( fluidsynth_ok ) {
  1.1169 -					fluidsynth_freesong(music->data.fluidsynthmidi);
  1.1170 -					goto skip;
  1.1171 -				}
  1.1172 +                if ( fluidsynth_ok ) {
  1.1173 +                    fluidsynth_freesong(music->data.fluidsynthmidi);
  1.1174 +                    goto skip;
  1.1175 +                }
  1.1176  #endif
  1.1177  #ifdef USE_TIMIDITY_MIDI
  1.1178 -				if ( timidity_ok ) {
  1.1179 -					Timidity_FreeSong(music->data.midi);
  1.1180 -					goto skip;
  1.1181 -				}
  1.1182 +                if ( timidity_ok ) {
  1.1183 +                    Timidity_FreeSong(music->data.midi);
  1.1184 +                    goto skip;
  1.1185 +                }
  1.1186  #endif
  1.1187 -				break;
  1.1188 +                break;
  1.1189  #endif
  1.1190  #ifdef OGG_MUSIC
  1.1191 -			case MUS_OGG:
  1.1192 -				OGG_delete(music->data.ogg);
  1.1193 -				break;
  1.1194 +            case MUS_OGG:
  1.1195 +                OGG_delete(music->data.ogg);
  1.1196 +                break;
  1.1197  #endif
  1.1198  #ifdef FLAC_MUSIC
  1.1199 -			case MUS_FLAC:
  1.1200 -				FLAC_delete(music->data.flac);
  1.1201 -				break;
  1.1202 +            case MUS_FLAC:
  1.1203 +                FLAC_delete(music->data.flac);
  1.1204 +                break;
  1.1205  #endif
  1.1206  #ifdef MP3_MUSIC
  1.1207 -			case MUS_MP3:
  1.1208 -				smpeg.SMPEG_delete(music->data.mp3);
  1.1209 -				break;
  1.1210 +            case MUS_MP3:
  1.1211 +                smpeg.SMPEG_delete(music->data.mp3);
  1.1212 +                break;
  1.1213  #endif
  1.1214  #ifdef MP3_MAD_MUSIC
  1.1215 -			case MUS_MP3_MAD:
  1.1216 -				mad_closeFile(music->data.mp3_mad);
  1.1217 -				break;
  1.1218 +            case MUS_MP3_MAD:
  1.1219 +                mad_closeFile(music->data.mp3_mad);
  1.1220 +                break;
  1.1221  #endif
  1.1222 -			default:
  1.1223 -				/* Unknown music type?? */
  1.1224 -				break;
  1.1225 -		}
  1.1226 +            default:
  1.1227 +                /* Unknown music type?? */
  1.1228 +                break;
  1.1229 +        }
  1.1230  
  1.1231      skip:
  1.1232 -		SDL_free(music);
  1.1233 -	}
  1.1234 +        SDL_free(music);
  1.1235 +    }
  1.1236  }
  1.1237  
  1.1238  /* Find out the music format of a mixer music, or the currently playing
  1.1239 @@ -847,471 +848,471 @@
  1.1240  */
  1.1241  Mix_MusicType Mix_GetMusicType(const Mix_Music *music)
  1.1242  {
  1.1243 -	Mix_MusicType type = MUS_NONE;
  1.1244 +    Mix_MusicType type = MUS_NONE;
  1.1245  
  1.1246 -	if ( music ) {
  1.1247 -		type = music->type;
  1.1248 -	} else {
  1.1249 -		SDL_LockAudio();
  1.1250 -		if ( music_playing ) {
  1.1251 -			type = music_playing->type;
  1.1252 -		}
  1.1253 -		SDL_UnlockAudio();
  1.1254 -	}
  1.1255 -	return(type);
  1.1256 +    if ( music ) {
  1.1257 +        type = music->type;
  1.1258 +    } else {
  1.1259 +        SDL_LockAudio();
  1.1260 +        if ( music_playing ) {
  1.1261 +            type = music_playing->type;
  1.1262 +        }
  1.1263 +        SDL_UnlockAudio();
  1.1264 +    }
  1.1265 +    return(type);
  1.1266  }
  1.1267  
  1.1268  /* Play a music chunk.  Returns 0, or -1 if there was an error.
  1.1269   */
  1.1270  static int music_internal_play(Mix_Music *music, double position)
  1.1271  {
  1.1272 -	int retval = 0;
  1.1273 +    int retval = 0;
  1.1274  
  1.1275  #if defined(__MACOSX__) && defined(USE_NATIVE_MIDI)
  1.1276 -	/* This fixes a bug with native MIDI on Mac OS X, where you
  1.1277 -	   can't really stop and restart MIDI from the audio callback.
  1.1278 -	*/
  1.1279 -	if ( music == music_playing && music->type == MUS_MID && native_midi_ok ) {
  1.1280 -		/* Just a seek suffices to restart playing */
  1.1281 -		music_internal_position(position);
  1.1282 -		return 0;
  1.1283 -	}
  1.1284 +    /* This fixes a bug with native MIDI on Mac OS X, where you
  1.1285 +       can't really stop and restart MIDI from the audio callback.
  1.1286 +    */
  1.1287 +    if ( music == music_playing && music->type == MUS_MID && native_midi_ok ) {
  1.1288 +        /* Just a seek suffices to restart playing */
  1.1289 +        music_internal_position(position);
  1.1290 +        return 0;
  1.1291 +    }
  1.1292  #endif
  1.1293  
  1.1294 -	/* Note the music we're playing */
  1.1295 -	if ( music_playing ) {
  1.1296 -		music_internal_halt();
  1.1297 -	}
  1.1298 -	music_playing = music;
  1.1299 +    /* Note the music we're playing */
  1.1300 +    if ( music_playing ) {
  1.1301 +        music_internal_halt();
  1.1302 +    }
  1.1303 +    music_playing = music;
  1.1304  
  1.1305 -	/* Set the initial volume */
  1.1306 -	if ( music->type != MUS_MOD ) {
  1.1307 -		music_internal_initialize_volume();
  1.1308 -	}
  1.1309 +    /* Set the initial volume */
  1.1310 +    if ( music->type != MUS_MOD ) {
  1.1311 +        music_internal_initialize_volume();
  1.1312 +    }
  1.1313  
  1.1314 -	/* Set up for playback */
  1.1315 -	switch (music->type) {
  1.1316 +    /* Set up for playback */
  1.1317 +    switch (music->type) {
  1.1318  #ifdef CMD_MUSIC
  1.1319 -	    case MUS_CMD:
  1.1320 -		MusicCMD_Start(music->data.cmd);
  1.1321 -		break;
  1.1322 +        case MUS_CMD:
  1.1323 +        MusicCMD_Start(music->data.cmd);
  1.1324 +        break;
  1.1325  #endif
  1.1326  #ifdef WAV_MUSIC
  1.1327 -	    case MUS_WAV:
  1.1328 -		WAVStream_Start(music->data.wave);
  1.1329 -		break;
  1.1330 +        case MUS_WAV:
  1.1331 +        WAVStream_Start(music->data.wave);
  1.1332 +        break;
  1.1333  #endif
  1.1334  #ifdef MODPLUG_MUSIC
  1.1335 -	    case MUS_MODPLUG:
  1.1336 -		/* can't set volume until file is loaded, so finally set it now */
  1.1337 -		music_internal_initialize_volume();
  1.1338 -		modplug_play(music->data.modplug);
  1.1339 -		break;
  1.1340 +        case MUS_MODPLUG:
  1.1341 +        /* can't set volume until file is loaded, so finally set it now */
  1.1342 +        music_internal_initialize_volume();
  1.1343 +        modplug_play(music->data.modplug);
  1.1344 +        break;
  1.1345  #endif
  1.1346  #ifdef MOD_MUSIC
  1.1347 -	    case MUS_MOD:
  1.1348 -		MOD_play(music->data.module);
  1.1349 -		/* Player_SetVolume() does nothing before Player_Start() */
  1.1350 -		music_internal_initialize_volume();
  1.1351 -		break;
  1.1352 +        case MUS_MOD:
  1.1353 +        MOD_play(music->data.module);
  1.1354 +        /* Player_SetVolume() does nothing before Player_Start() */
  1.1355 +        music_internal_initialize_volume();
  1.1356 +        break;
  1.1357  #endif
  1.1358  #ifdef MID_MUSIC
  1.1359 -	    case MUS_MID:
  1.1360 +        case MUS_MID:
  1.1361  #ifdef USE_NATIVE_MIDI
  1.1362 -		if ( native_midi_ok ) {
  1.1363 -			native_midi_start(music->data.nativemidi, music_loops);
  1.1364 -			goto skip;
  1.1365 -		}
  1.1366 +        if ( native_midi_ok ) {
  1.1367 +            native_midi_start(music->data.nativemidi, music_loops);
  1.1368 +            goto skip;
  1.1369 +        }
  1.1370  #endif
  1.1371  #ifdef USE_FLUIDSYNTH_MIDI
  1.1372 -		if (fluidsynth_ok ) {
  1.1373 -			fluidsynth_start(music->data.fluidsynthmidi);
  1.1374 -			goto skip;
  1.1375 -		}
  1.1376 +        if (fluidsynth_ok ) {
  1.1377 +            fluidsynth_start(music->data.fluidsynthmidi);
  1.1378 +            goto skip;
  1.1379 +        }
  1.1380  #endif
  1.1381  #ifdef USE_TIMIDITY_MIDI
  1.1382 -		if ( timidity_ok ) {
  1.1383 -			Timidity_Start(music->data.midi);
  1.1384 -			goto skip;
  1.1385 -		}
  1.1386 +        if ( timidity_ok ) {
  1.1387 +            Timidity_Start(music->data.midi);
  1.1388 +            goto skip;
  1.1389 +        }
  1.1390  #endif
  1.1391 -		break;
  1.1392 +        break;
  1.1393  #endif
  1.1394  #ifdef OGG_MUSIC
  1.1395 -	    case MUS_OGG:
  1.1396 -		OGG_play(music->data.ogg);
  1.1397 -		break;
  1.1398 +        case MUS_OGG:
  1.1399 +        OGG_play(music->data.ogg);
  1.1400 +        break;
  1.1401  #endif
  1.1402  #ifdef FLAC_MUSIC
  1.1403 -	    case MUS_FLAC:
  1.1404 -		FLAC_play(music->data.flac);
  1.1405 -		break;
  1.1406 +        case MUS_FLAC:
  1.1407 +        FLAC_play(music->data.flac);
  1.1408 +        break;
  1.1409  #endif
  1.1410  #ifdef MP3_MUSIC
  1.1411 -	    case MUS_MP3:
  1.1412 -		smpeg.SMPEG_enableaudio(music->data.mp3,1);
  1.1413 -		smpeg.SMPEG_enablevideo(music->data.mp3,0);
  1.1414 -		smpeg.SMPEG_play(music_playing->data.mp3);
  1.1415 -		break;
  1.1416 +        case MUS_MP3:
  1.1417 +        smpeg.SMPEG_enableaudio(music->data.mp3,1);
  1.1418 +        smpeg.SMPEG_enablevideo(music->data.mp3,0);
  1.1419 +        smpeg.SMPEG_play(music_playing->data.mp3);
  1.1420 +        break;
  1.1421  #endif
  1.1422  #ifdef MP3_MAD_MUSIC
  1.1423 -	    case MUS_MP3_MAD:
  1.1424 -		mad_start(music->data.mp3_mad);
  1.1425 -		break;
  1.1426 +        case MUS_MP3_MAD:
  1.1427 +        mad_start(music->data.mp3_mad);
  1.1428 +        break;
  1.1429  #endif
  1.1430 -	    default:
  1.1431 -		Mix_SetError("Can't play unknown music type");
  1.1432 -		retval = -1;
  1.1433 -		break;
  1.1434 -	}
  1.1435 +        default:
  1.1436 +        Mix_SetError("Can't play unknown music type");
  1.1437 +        retval = -1;
  1.1438 +        break;
  1.1439 +    }
  1.1440  
  1.1441  skip:
  1.1442 -	/* Set the playback position, note any errors if an offset is used */
  1.1443 -	if ( retval == 0 ) {
  1.1444 -		if ( position > 0.0 ) {
  1.1445 -			if ( music_internal_position(position) < 0 ) {
  1.1446 -				Mix_SetError("Position not implemented for music type");
  1.1447 -				retval = -1;
  1.1448 -			}
  1.1449 -		} else {
  1.1450 -			music_internal_position(0.0);
  1.1451 -		}
  1.1452 -	}
  1.1453 +    /* Set the playback position, note any errors if an offset is used */
  1.1454 +    if ( retval == 0 ) {
  1.1455 +        if ( position > 0.0 ) {
  1.1456 +            if ( music_internal_position(position) < 0 ) {
  1.1457 +                Mix_SetError("Position not implemented for music type");
  1.1458 +                retval = -1;
  1.1459 +            }
  1.1460 +        } else {
  1.1461 +            music_internal_position(0.0);
  1.1462 +        }
  1.1463 +    }
  1.1464  
  1.1465 -	/* If the setup failed, we're not playing any music anymore */
  1.1466 -	if ( retval < 0 ) {
  1.1467 -		music_playing = NULL;
  1.1468 -	}
  1.1469 -	return(retval);
  1.1470 +    /* If the setup failed, we're not playing any music anymore */
  1.1471 +    if ( retval < 0 ) {
  1.1472 +        music_playing = NULL;
  1.1473 +    }
  1.1474 +    return(retval);
  1.1475  }
  1.1476  int Mix_FadeInMusicPos(Mix_Music *music, int loops, int ms, double position)
  1.1477  {
  1.1478 -	int retval;
  1.1479 +    int retval;
  1.1480  
  1.1481 -	if ( ms_per_step == 0 ) {
  1.1482 -		SDL_SetError("Audio device hasn't been opened");
  1.1483 -		return(-1);
  1.1484 -	}
  1.1485 +    if ( ms_per_step == 0 ) {
  1.1486 +        SDL_SetError("Audio device hasn't been opened");
  1.1487 +        return(-1);
  1.1488 +    }
  1.1489  
  1.1490 -	/* Don't play null pointers :-) */
  1.1491 -	if ( music == NULL ) {
  1.1492 -		Mix_SetError("music parameter was NULL");
  1.1493 -		return(-1);
  1.1494 -	}
  1.1495 +    /* Don't play null pointers :-) */
  1.1496 +    if ( music == NULL ) {
  1.1497 +        Mix_SetError("music parameter was NULL");
  1.1498 +        return(-1);
  1.1499 +    }
  1.1500  
  1.1501 -	/* Setup the data */
  1.1502 -	if ( ms ) {
  1.1503 -		music->fading = MIX_FADING_IN;
  1.1504 -	} else {
  1.1505 -		music->fading = MIX_NO_FADING;
  1.1506 -	}
  1.1507 -	music->fade_step = 0;
  1.1508 -	music->fade_steps = ms/ms_per_step;
  1.1509 +    /* Setup the data */
  1.1510 +    if ( ms ) {
  1.1511 +        music->fading = MIX_FADING_IN;
  1.1512 +    } else {
  1.1513 +        music->fading = MIX_NO_FADING;
  1.1514 +    }
  1.1515 +    music->fade_step = 0;
  1.1516 +    music->fade_steps = ms/ms_per_step;
  1.1517  
  1.1518 -	/* Play the puppy */
  1.1519 -	SDL_LockAudio();
  1.1520 -	/* If the current music is fading out, wait for the fade to complete */
  1.1521 -	while ( music_playing && (music_playing->fading == MIX_FADING_OUT) ) {
  1.1522 -		SDL_UnlockAudio();
  1.1523 -		SDL_Delay(100);
  1.1524 -		SDL_LockAudio();
  1.1525 -	}
  1.1526 -	music_active = 1;
  1.1527 -	if (loops == 1) {
  1.1528 -		/* Loop is the number of times to play the audio */
  1.1529 -		loops = 0;
  1.1530 -	}
  1.1531 -	music_loops = loops;
  1.1532 -	retval = music_internal_play(music, position);
  1.1533 -	SDL_UnlockAudio();
  1.1534 +    /* Play the puppy */
  1.1535 +    SDL_LockAudio();
  1.1536 +    /* If the current music is fading out, wait for the fade to complete */
  1.1537 +    while ( music_playing && (music_playing->fading == MIX_FADING_OUT) ) {
  1.1538 +        SDL_UnlockAudio();
  1.1539 +        SDL_Delay(100);
  1.1540 +        SDL_LockAudio();
  1.1541 +    }
  1.1542 +    music_active = 1;
  1.1543 +    if (loops == 1) {
  1.1544 +        /* Loop is the number of times to play the audio */
  1.1545 +        loops = 0;
  1.1546 +    }
  1.1547 +    music_loops = loops;
  1.1548 +    retval = music_internal_play(music, position);
  1.1549 +    SDL_UnlockAudio();
  1.1550  
  1.1551 -	return(retval);
  1.1552 +    return(retval);
  1.1553  }
  1.1554  int Mix_FadeInMusic(Mix_Music *music, int loops, int ms)
  1.1555  {
  1.1556 -	return Mix_FadeInMusicPos(music, loops, ms, 0.0);
  1.1557 +    return Mix_FadeInMusicPos(music, loops, ms, 0.0);
  1.1558  }
  1.1559  int Mix_PlayMusic(Mix_Music *music, int loops)
  1.1560  {
  1.1561 -	return Mix_FadeInMusicPos(music, loops, 0, 0.0);
  1.1562 +    return Mix_FadeInMusicPos(music, loops, 0, 0.0);
  1.1563  }
  1.1564  
  1.1565  /* Set the playing music position */
  1.1566  int music_internal_position(double position)
  1.1567  {
  1.1568 -	int retval = 0;
  1.1569 +    int retval = 0;
  1.1570  
  1.1571 -	switch (music_playing->type) {
  1.1572 +    switch (music_playing->type) {
  1.1573  #ifdef MODPLUG_MUSIC
  1.1574 -	    case MUS_MODPLUG:
  1.1575 -		modplug_jump_to_time(music_playing->data.modplug, position);
  1.1576 -		break;
  1.1577 +        case MUS_MODPLUG:
  1.1578 +        modplug_jump_to_time(music_playing->data.modplug, position);
  1.1579 +        break;
  1.1580  #endif
  1.1581  #ifdef MOD_MUSIC
  1.1582 -	    case MUS_MOD:
  1.1583 -		MOD_jump_to_time(music_playing->data.module, position);
  1.1584 -		break;
  1.1585 +        case MUS_MOD:
  1.1586 +        MOD_jump_to_time(music_playing->data.module, position);
  1.1587 +        break;
  1.1588  #endif
  1.1589  #ifdef OGG_MUSIC
  1.1590 -	    case MUS_OGG:
  1.1591 -		OGG_jump_to_time(music_playing->data.ogg, position);
  1.1592 -		break;
  1.1593 +        case MUS_OGG:
  1.1594 +        OGG_jump_to_time(music_playing->data.ogg, position);
  1.1595 +        break;
  1.1596  #endif
  1.1597  #ifdef FLAC_MUSIC
  1.1598 -	    case MUS_FLAC:
  1.1599 -		FLAC_jump_to_time(music_playing->data.flac, position);
  1.1600 -		break;
  1.1601 +        case MUS_FLAC:
  1.1602 +        FLAC_jump_to_time(music_playing->data.flac, position);
  1.1603 +        break;
  1.1604  #endif
  1.1605  #ifdef MP3_MUSIC
  1.1606 -	    case MUS_MP3:
  1.1607 -		smpeg.SMPEG_rewind(music_playing->data.mp3);
  1.1608 -		smpeg.SMPEG_play(music_playing->data.mp3);
  1.1609 -		if ( position > 0.0 ) {
  1.1610 -			smpeg.SMPEG_skip(music_playing->data.mp3, (float)position);
  1.1611 -		}
  1.1612 -		break;
  1.1613 +        case MUS_MP3:
  1.1614 +        smpeg.SMPEG_rewind(music_playing->data.mp3);
  1.1615 +        smpeg.SMPEG_play(music_playing->data.mp3);
  1.1616 +        if ( position > 0.0 ) {
  1.1617 +            smpeg.SMPEG_skip(music_playing->data.mp3, (float)position);
  1.1618 +        }
  1.1619 +        break;
  1.1620  #endif
  1.1621  #ifdef MP3_MAD_MUSIC
  1.1622 -	    case MUS_MP3_MAD:
  1.1623 -		mad_seek(music_playing->data.mp3_mad, position);
  1.1624 -		break;
  1.1625 +        case MUS_MP3_MAD:
  1.1626 +        mad_seek(music_playing->data.mp3_mad, position);
  1.1627 +        break;
  1.1628  #endif
  1.1629 -	    default:
  1.1630 -		/* TODO: Implement this for other music backends */
  1.1631 -		retval = -1;
  1.1632 -		break;
  1.1633 -	}
  1.1634 -	return(retval);
  1.1635 +        default:
  1.1636 +        /* TODO: Implement this for other music backends */
  1.1637 +        retval = -1;
  1.1638 +        break;
  1.1639 +    }
  1.1640 +    return(retval);
  1.1641  }
  1.1642  int Mix_SetMusicPosition(double position)
  1.1643  {
  1.1644 -	int retval;
  1.1645 +    int retval;
  1.1646  
  1.1647 -	SDL_LockAudio();
  1.1648 -	if ( music_playing ) {
  1.1649 -		retval = music_internal_position(position);
  1.1650 -		if ( retval < 0 ) {
  1.1651 -			Mix_SetError("Position not implemented for music type");
  1.1652 -		}
  1.1653 -	} else {
  1.1654 -		Mix_SetError("Music isn't playing");
  1.1655 -		retval = -1;
  1.1656 -	}
  1.1657 -	SDL_UnlockAudio();
  1.1658 +    SDL_LockAudio();
  1.1659 +    if ( music_playing ) {
  1.1660 +        retval = music_internal_position(position);
  1.1661 +        if ( retval < 0 ) {
  1.1662 +            Mix_SetError("Position not implemented for music type");
  1.1663 +        }
  1.1664 +    } else {
  1.1665 +        Mix_SetError("Music isn't playing");
  1.1666 +        retval = -1;
  1.1667 +    }
  1.1668 +    SDL_UnlockAudio();
  1.1669  
  1.1670 -	return(retval);
  1.1671 +    return(retval);
  1.1672  }
  1.1673  
  1.1674  /* Set the music's initial volume */
  1.1675  static void music_internal_initialize_volume(void)
  1.1676  {
  1.1677 -	if ( music_playing->fading == MIX_FADING_IN ) {
  1.1678 -		music_internal_volume(0);
  1.1679 -	} else {
  1.1680 -		music_internal_volume(music_volume);
  1.1681 -	}
  1.1682 +    if ( music_playing->fading == MIX_FADING_IN ) {
  1.1683 +        music_internal_volume(0);
  1.1684 +    } else {
  1.1685 +        music_internal_volume(music_volume);
  1.1686 +    }
  1.1687  }
  1.1688  
  1.1689  /* Set the music volume */
  1.1690  static void music_internal_volume(int volume)
  1.1691  {
  1.1692 -	switch (music_playing->type) {
  1.1693 +    switch (music_playing->type) {
  1.1694  #ifdef CMD_MUSIC
  1.1695 -	    case MUS_CMD:
  1.1696 -		MusicCMD_SetVolume(volume);
  1.1697 -		break;
  1.1698 +        case MUS_CMD:
  1.1699 +        MusicCMD_SetVolume(volume);
  1.1700 +        break;
  1.1701  #endif
  1.1702  #ifdef WAV_MUSIC
  1.1703 -	    case MUS_WAV:
  1.1704 -		WAVStream_SetVolume(volume);
  1.1705 -		break;
  1.1706 +        case MUS_WAV:
  1.1707 +        WAVStream_SetVolume(volume);
  1.1708 +        break;
  1.1709  #endif
  1.1710  #ifdef MODPLUG_MUSIC
  1.1711 -	    case MUS_MODPLUG:
  1.1712 -		modplug_setvolume(music_playing->data.modplug, volume);
  1.1713 -		break;
  1.1714 +        case MUS_MODPLUG:
  1.1715 +        modplug_setvolume(music_playing->data.modplug, volume);
  1.1716 +        break;
  1.1717  #endif
  1.1718  #ifdef MOD_MUSIC
  1.1719 -	    case MUS_MOD:
  1.1720 -		MOD_setvolume(music_playing->data.module, volume);
  1.1721 -		break;
  1.1722 +        case MUS_MOD:
  1.1723 +        MOD_setvolume(music_playing->data.module, volume);
  1.1724 +        break;
  1.1725  #endif
  1.1726  #ifdef MID_MUSIC
  1.1727 -	    case MUS_MID:
  1.1728 +        case MUS_MID:
  1.1729  #ifdef USE_NATIVE_MIDI
  1.1730 -		if ( native_midi_ok ) {
  1.1731 -			native_midi_setvolume(volume);
  1.1732 -			return;
  1.1733 -		}
  1.1734 +        if ( native_midi_ok ) {
  1.1735 +            native_midi_setvolume(volume);
  1.1736 +            return;
  1.1737 +        }
  1.1738  #endif
  1.1739  #ifdef USE_FLUIDSYNTH_MIDI
  1.1740 -		if ( fluidsynth_ok ) {
  1.1741 -			fluidsynth_setvolume(music_playing->data.fluidsynthmidi, volume);
  1.1742 -			return;
  1.1743 -		}
  1.1744 +        if ( fluidsynth_ok ) {
  1.1745 +            fluidsynth_setvolume(music_playing->data.fluidsynthmidi, volume);
  1.1746 +            return;
  1.1747 +        }
  1.1748  #endif
  1.1749  #ifdef USE_TIMIDITY_MIDI
  1.1750 -		if ( timidity_ok ) {
  1.1751 -			Timidity_SetVolume(volume);
  1.1752 -			return;
  1.1753 -		}
  1.1754 +        if ( timidity_ok ) {
  1.1755 +            Timidity_SetVolume(volume);
  1.1756 +            return;
  1.1757 +        }
  1.1758  #endif
  1.1759 -		break;
  1.1760 +        break;
  1.1761  #endif
  1.1762  #ifdef OGG_MUSIC
  1.1763 -	    case MUS_OGG:
  1.1764 -		OGG_setvolume(music_playing->data.ogg, volume);
  1.1765 -		break;
  1.1766 +        case MUS_OGG:
  1.1767 +        OGG_setvolume(music_playing->data.ogg, volume);
  1.1768 +        break;
  1.1769  #endif
  1.1770  #ifdef FLAC_MUSIC
  1.1771 -	    case MUS_FLAC:
  1.1772 -		FLAC_setvolume(music_playing->data.flac, volume);
  1.1773 -		break;
  1.1774 +        case MUS_FLAC:
  1.1775 +        FLAC_setvolume(music_playing->data.flac, volume);
  1.1776 +        break;
  1.1777  #endif
  1.1778  #ifdef MP3_MUSIC
  1.1779 -	    case MUS_MP3:
  1.1780 -		smpeg.SMPEG_setvolume(music_playing->data.mp3,(int)(((float)volume/(float)MIX_MAX_VOLUME)*100.0));
  1.1781 -		break;
  1.1782 +        case MUS_MP3:
  1.1783 +        smpeg.SMPEG_setvolume(music_playing->data.mp3,(int)(((float)volume/(float)MIX_MAX_VOLUME)*100.0));
  1.1784 +        break;
  1.1785  #endif
  1.1786  #ifdef MP3_MAD_MUSIC
  1.1787 -	    case MUS_MP3_MAD:
  1.1788 -		mad_setVolume(music_playing->data.mp3_mad, volume);
  1.1789 -		break;
  1.1790 +        case MUS_MP3_MAD:
  1.1791 +        mad_setVolume(music_playing->data.mp3_mad, volume);
  1.1792 +        break;
  1.1793  #endif
  1.1794 -	    default:
  1.1795 -		/* Unknown music type?? */
  1.1796 -		break;
  1.1797 -	}
  1.1798 +        default:
  1.1799 +        /* Unknown music type?? */
  1.1800 +        break;
  1.1801 +    }
  1.1802  }
  1.1803  int Mix_VolumeMusic(int volume)
  1.1804  {
  1.1805 -	int prev_volume;
  1.1806 +    int prev_volume;
  1.1807  
  1.1808 -	prev_volume = music_volume;
  1.1809 -	if ( volume < 0 ) {
  1.1810 -		return prev_volume;
  1.1811 -	}
  1.1812 -	if ( volume > SDL_MIX_MAXVOLUME ) {
  1.1813 -		volume = SDL_MIX_MAXVOLUME;
  1.1814 -	}
  1.1815 -	music_volume = volume;
  1.1816 -	SDL_LockAudio();
  1.1817 -	if ( music_playing ) {
  1.1818 -		music_internal_volume(music_volume);
  1.1819 -	}
  1.1820 -	SDL_UnlockAudio();
  1.1821 -	return(prev_volume);
  1.1822 +    prev_volume = music_volume;
  1.1823 +    if ( volume < 0 ) {
  1.1824 +        return prev_volume;
  1.1825 +    }
  1.1826 +    if ( volume > SDL_MIX_MAXVOLUME ) {
  1.1827 +        volume = SDL_MIX_MAXVOLUME;
  1.1828 +    }
  1.1829 +    music_volume = volume;
  1.1830 +    SDL_LockAudio();
  1.1831 +    if ( music_playing ) {
  1.1832 +        music_internal_volume(music_volume);
  1.1833 +    }
  1.1834 +    SDL_UnlockAudio();
  1.1835 +    return(prev_volume);
  1.1836  }
  1.1837  
  1.1838  /* Halt playing of music */
  1.1839  static void music_internal_halt(void)
  1.1840  {
  1.1841 -	switch (music_playing->type) {
  1.1842 +    switch (music_playing->type) {
  1.1843  #ifdef CMD_MUSIC
  1.1844 -	    case MUS_CMD:
  1.1845 -		MusicCMD_Stop(music_playing->data.cmd);
  1.1846 -		break;
  1.1847 +        case MUS_CMD:
  1.1848 +        MusicCMD_Stop(music_playing->data.cmd);
  1.1849 +        break;
  1.1850  #endif
  1.1851  #ifdef WAV_MUSIC
  1.1852 -	    case MUS_WAV:
  1.1853 -		WAVStream_Stop();
  1.1854 -		break;
  1.1855 +        case MUS_WAV:
  1.1856 +        WAVStream_Stop();
  1.1857 +        break;
  1.1858  #endif
  1.1859  #ifdef MODPLUG_MUSIC
  1.1860 -	    case MUS_MODPLUG:
  1.1861 -		modplug_stop(music_playing->data.modplug);
  1.1862 -		break;
  1.1863 +        case MUS_MODPLUG:
  1.1864 +        modplug_stop(music_playing->data.modplug);
  1.1865 +        break;
  1.1866  #endif
  1.1867  #ifdef MOD_MUSIC
  1.1868 -	    case MUS_MOD:
  1.1869 -		MOD_stop(music_playing->data.module);
  1.1870 -		break;
  1.1871 +        case MUS_MOD:
  1.1872 +        MOD_stop(music_playing->data.module);
  1.1873 +        break;
  1.1874  #endif
  1.1875  #ifdef MID_MUSIC
  1.1876 -	    case MUS_MID:
  1.1877 +        case MUS_MID:
  1.1878  #ifdef USE_NATIVE_MIDI
  1.1879 -		if ( native_midi_ok ) {
  1.1880 -			native_midi_stop();
  1.1881 -			goto skip;
  1.1882 -		}
  1.1883 +        if ( native_midi_ok ) {
  1.1884 +            native_midi_stop();
  1.1885 +            goto skip;
  1.1886 +        }
  1.1887  #endif
  1.1888  #ifdef USE_FLUIDSYNTH_MIDI
  1.1889 -		if ( fluidsynth_ok ) {
  1.1890 -			fluidsynth_stop(music_playing->data.fluidsynthmidi);
  1.1891 -			goto skip;
  1.1892 -		}
  1.1893 +        if ( fluidsynth_ok ) {
  1.1894 +            fluidsynth_stop(music_playing->data.fluidsynthmidi);
  1.1895 +            goto skip;
  1.1896 +        }
  1.1897  #endif
  1.1898  #ifdef USE_TIMIDITY_MIDI
  1.1899 -		if ( timidity_ok ) {
  1.1900 -			Timidity_Stop();
  1.1901 -			goto skip;
  1.1902 -		}
  1.1903 +        if ( timidity_ok ) {
  1.1904 +            Timidity_Stop();
  1.1905 +            goto skip;
  1.1906 +        }
  1.1907  #endif
  1.1908 -		break;
  1.1909 +        break;
  1.1910  #endif
  1.1911  #ifdef OGG_MUSIC
  1.1912 -	    case MUS_OGG:
  1.1913 -		OGG_stop(music_playing->data.ogg);
  1.1914 -		break;
  1.1915 +        case MUS_OGG:
  1.1916 +        OGG_stop(music_playing->data.ogg);
  1.1917 +        break;
  1.1918  #endif
  1.1919  #ifdef FLAC_MUSIC
  1.1920 -	    case MUS_FLAC:
  1.1921 -		FLAC_stop(music_playing->data.flac);
  1.1922 -		break;
  1.1923 +        case MUS_FLAC:
  1.1924 +        FLAC_stop(music_playing->data.flac);
  1.1925 +        break;
  1.1926  #endif
  1.1927  #ifdef MP3_MUSIC
  1.1928 -	    case MUS_MP3:
  1.1929 -		smpeg.SMPEG_stop(music_playing->data.mp3);
  1.1930 -		break;
  1.1931 +        case MUS_MP3:
  1.1932 +        smpeg.SMPEG_stop(music_playing->data.mp3);
  1.1933 +        break;
  1.1934  #endif
  1.1935  #ifdef MP3_MAD_MUSIC
  1.1936 -	    case MUS_MP3_MAD:
  1.1937 -		mad_stop(music_playing->data.mp3_mad);
  1.1938 -		break;
  1.1939 +        case MUS_MP3_MAD:
  1.1940 +        mad_stop(music_playing->data.mp3_mad);
  1.1941 +        break;
  1.1942  #endif
  1.1943 -	    default:
  1.1944 -		/* Unknown music type?? */
  1.1945 -		return;
  1.1946 -	}
  1.1947 +        default:
  1.1948 +        /* Unknown music type?? */
  1.1949 +        return;
  1.1950 +    }
  1.1951  
  1.1952  skip:
  1.1953 -	music_playing->fading = MIX_NO_FADING;
  1.1954 -	music_playing = NULL;
  1.1955 +    music_playing->fading = MIX_NO_FADING;
  1.1956 +    music_playing = NULL;
  1.1957  }
  1.1958  int Mix_HaltMusic(void)
  1.1959  {
  1.1960 -	SDL_LockAudio();
  1.1961 -	if ( music_playing ) {
  1.1962 -		music_internal_halt();
  1.1963 -		if ( music_finished_hook ) {
  1.1964 -			music_finished_hook();
  1.1965 -		}
  1.1966 -	}
  1.1967 -	SDL_UnlockAudio();
  1.1968 +    SDL_LockAudio();
  1.1969 +    if ( music_playing ) {
  1.1970 +        music_internal_halt();
  1.1971 +        if ( music_finished_hook ) {
  1.1972 +            music_finished_hook();
  1.1973 +        }
  1.1974 +    }
  1.1975 +    SDL_UnlockAudio();
  1.1976  
  1.1977 -	return(0);
  1.1978 +    return(0);
  1.1979  }
  1.1980  
  1.1981  /* Progressively stop the music */
  1.1982  int Mix_FadeOutMusic(int ms)
  1.1983  {
  1.1984 -	int retval = 0;
  1.1985 +    int retval = 0;
  1.1986  
  1.1987 -	if ( ms_per_step == 0 ) {
  1.1988 -		SDL_SetError("Audio device hasn't been opened");
  1.1989 -		return 0;
  1.1990 -	}
  1.1991 +    if ( ms_per_step == 0 ) {
  1.1992 +        SDL_SetError("Audio device hasn't been opened");
  1.1993 +        return 0;
  1.1994 +    }
  1.1995  
  1.1996 -	if (ms <= 0) {  /* just halt immediately. */
  1.1997 -		Mix_HaltMusic();
  1.1998 -		return 1;
  1.1999 -	}
  1.2000 +    if (ms <= 0) {  /* just halt immediately. */
  1.2001 +        Mix_HaltMusic();
  1.2002 +        return 1;
  1.2003 +    }
  1.2004  
  1.2005 -	SDL_LockAudio();
  1.2006 -	if ( music_playing) {
  1.2007 +    SDL_LockAudio();
  1.2008 +    if ( music_playing) {
  1.2009                  int fade_steps = (ms + ms_per_step - 1)/ms_per_step;
  1.2010                  if ( music_playing->fading == MIX_NO_FADING ) {
  1.2011 -	        	music_playing->fade_step = 0;
  1.2012 +                music_playing->fade_step = 0;
  1.2013                  } else {
  1.2014                          int step;
  1.2015                          int old_fade_steps = music_playing->fade_steps;
  1.2016 @@ -1324,277 +1325,277 @@
  1.2017                          music_playing->fade_step = (step * fade_steps)
  1.2018                                  / old_fade_steps;
  1.2019                  }
  1.2020 -		music_playing->fading = MIX_FADING_OUT;
  1.2021 -		music_playing->fade_steps = fade_steps;
  1.2022 -		retval = 1;
  1.2023 -	}
  1.2024 -	SDL_UnlockAudio();
  1.2025 +        music_playing->fading = MIX_FADING_OUT;
  1.2026 +        music_playing->fade_steps = fade_steps;
  1.2027 +        retval = 1;
  1.2028 +    }
  1.2029 +    SDL_UnlockAudio();
  1.2030  
  1.2031 -	return(retval);
  1.2032 +    return(retval);
  1.2033  }
  1.2034  
  1.2035  Mix_Fading Mix_FadingMusic(void)
  1.2036  {
  1.2037 -	Mix_Fading fading = MIX_NO_FADING;
  1.2038 +    Mix_Fading fading = MIX_NO_FADING;
  1.2039  
  1.2040 -	SDL_LockAudio();
  1.2041 -	if ( music_playing ) {
  1.2042 -		fading = music_playing->fading;
  1.2043 -	}
  1.2044 -	SDL_UnlockAudio();
  1.2045 +    SDL_LockAudio();
  1.2046 +    if ( music_playing ) {
  1.2047 +        fading = music_playing->fading;
  1.2048 +    }
  1.2049 +    SDL_UnlockAudio();
  1.2050  
  1.2051 -	return(fading);
  1.2052 +    return(fading);
  1.2053  }
  1.2054  
  1.2055  /* Pause/Resume the music stream */
  1.2056  void Mix_PauseMusic(void)
  1.2057  {
  1.2058 -	music_active = 0;
  1.2059 +    music_active = 0;
  1.2060  }
  1.2061  
  1.2062  void Mix_ResumeMusic(void)
  1.2063  {
  1.2064 -	music_active = 1;
  1.2065 +    music_active = 1;
  1.2066  }
  1.2067  
  1.2068  void Mix_RewindMusic(void)
  1.2069  {
  1.2070 -	Mix_SetMusicPosition(0.0);
  1.2071 +    Mix_SetMusicPosition(0.0);
  1.2072  }
  1.2073  
  1.2074  int Mix_PausedMusic(void)
  1.2075  {
  1.2076 -	return (music_active == 0);
  1.2077 +    return (music_active == 0);
  1.2078  }
  1.2079  
  1.2080  /* Check the status of the music */
  1.2081  static int music_internal_playing()
  1.2082  {
  1.2083 -	int playing = 1;
  1.2084 +    int playing = 1;
  1.2085  
  1.2086 -	if (music_playing == NULL) {
  1.2087 -		return 0;
  1.2088 -	}
  1.2089 +    if (music_playing == NULL) {
  1.2090 +        return 0;
  1.2091 +    }
  1.2092  
  1.2093 -	switch (music_playing->type) {
  1.2094 +    switch (music_playing->type) {
  1.2095  #ifdef CMD_MUSIC
  1.2096 -	    case MUS_CMD:
  1.2097 -		if (!MusicCMD_Active(music_playing->data.cmd)) {
  1.2098 -			playing = 0;
  1.2099 -		}
  1.2100 -		break;
  1.2101 +        case MUS_CMD:
  1.2102 +        if (!MusicCMD_Active(music_playing->data.cmd)) {
  1.2103 +            playing = 0;
  1.2104 +        }
  1.2105 +        break;
  1.2106  #endif
  1.2107  #ifdef WAV_MUSIC
  1.2108 -	    case MUS_WAV:
  1.2109 -		if ( ! WAVStream_Active() ) {
  1.2110 -			playing = 0;
  1.2111 -		}
  1.2112 -		break;
  1.2113 +        case MUS_WAV:
  1.2114 +        if ( ! WAVStream_Active() ) {
  1.2115 +            playing = 0;
  1.2116 +        }
  1.2117 +        break;
  1.2118  #endif
  1.2119  #ifdef MODPLUG_MUSIC
  1.2120 -	    case MUS_MODPLUG:
  1.2121 -		if ( ! modplug_playing(music_playing->data.modplug) ) {
  1.2122 -			playing = 0;
  1.2123 -		}
  1.2124 -		break;
  1.2125 +        case MUS_MODPLUG:
  1.2126 +        if ( ! modplug_playing(music_playing->data.modplug) ) {
  1.2127 +            playing = 0;
  1.2128 +        }
  1.2129 +        break;
  1.2130  #endif
  1.2131  #ifdef MOD_MUSIC
  1.2132 -	    case MUS_MOD:
  1.2133 -		if ( ! MOD_playing(music_playing->data.module) ) {
  1.2134 -			playing = 0;
  1.2135 -		}
  1.2136 -		break;
  1.2137 +        case MUS_MOD:
  1.2138 +        if ( ! MOD_playing(music_playing->data.module) ) {
  1.2139 +            playing = 0;
  1.2140 +        }
  1.2141 +        break;
  1.2142  #endif
  1.2143  #ifdef MID_MUSIC
  1.2144 -	    case MUS_MID:
  1.2145 +        case MUS_MID:
  1.2146  #ifdef USE_NATIVE_MIDI
  1.2147 -		if ( native_midi_ok ) {
  1.2148 -			if ( ! native_midi_active() )
  1.2149 -				playing = 0;
  1.2150 -			goto skip;
  1.2151 -		}
  1.2152 +        if ( native_midi_ok ) {
  1.2153 +            if ( ! native_midi_active() )
  1.2154 +                playing = 0;
  1.2155 +            goto skip;
  1.2156 +        }
  1.2157  #endif
  1.2158  #ifdef USE_FLUIDSYNTH_MIDI
  1.2159 -		if ( fluidsynth_ok ) {
  1.2160 -			if ( ! fluidsynth_active(music_playing->data.fluidsynthmidi) )
  1.2161 -				playing = 0;
  1.2162 -			goto skip;
  1.2163 -		}
  1.2164 +        if ( fluidsynth_ok ) {
  1.2165 +            if ( ! fluidsynth_active(music_playing->data.fluidsynthmidi) )
  1.2166 +                playing = 0;
  1.2167 +            goto skip;
  1.2168 +        }
  1.2169  #endif
  1.2170  #ifdef USE_TIMIDITY_MIDI
  1.2171 -		if ( timidity_ok ) {
  1.2172 -			if ( ! Timidity_Active() )
  1.2173 -				playing = 0;
  1.2174 -			goto skip;
  1.2175 -		}
  1.2176 +        if ( timidity_ok ) {
  1.2177 +            if ( ! Timidity_Active() )
  1.2178 +                playing = 0;
  1.2179 +            goto skip;
  1.2180 +        }
  1.2181  #endif
  1.2182 -		break;
  1.2183 +        break;
  1.2184  #endif
  1.2185  #ifdef OGG_MUSIC
  1.2186 -	    case MUS_OGG:
  1.2187 -		if ( ! OGG_playing(music_playing->data.ogg) ) {
  1.2188 -			playing = 0;
  1.2189 -		}
  1.2190 -		break;
  1.2191 +        case MUS_OGG:
  1.2192 +        if ( ! OGG_playing(music_playing->data.ogg) ) {
  1.2193 +            playing = 0;
  1.2194 +        }
  1.2195 +        break;
  1.2196  #endif
  1.2197  #ifdef FLAC_MUSIC
  1.2198 -	    case MUS_FLAC:
  1.2199 -		if ( ! FLAC_playing(music_playing->data.flac) ) {
  1.2200 -			playing = 0;
  1.2201 -		}
  1.2202 -		break;
  1.2203 +        case MUS_FLAC:
  1.2204 +        if ( ! FLAC_playing(music_playing->data.flac) ) {
  1.2205 +            playing = 0;
  1.2206 +        }
  1.2207 +        break;
  1.2208  #endif
  1.2209  #ifdef MP3_MUSIC
  1.2210 -	    case MUS_MP3:
  1.2211 -		if ( smpeg.SMPEG_status(music_playing->data.mp3) != SMPEG_PLAYING )
  1.2212 -			playing = 0;
  1.2213 -		break;
  1.2214 +        case MUS_MP3:
  1.2215 +        if ( smpeg.SMPEG_status(music_playing->data.mp3) != SMPEG_PLAYING )
  1.2216 +            playing = 0;
  1.2217 +        break;
  1.2218  #endif
  1.2219  #ifdef MP3_MAD_MUSIC
  1.2220 -	    case MUS_MP3_MAD:
  1.2221 -		if (!mad_isPlaying(music_playing->data.mp3_mad)) {
  1.2222 -			playing = 0;
  1.2223 -		}
  1.2224 -		break;
  1.2225 +        case MUS_MP3_MAD:
  1.2226 +        if (!mad_isPlaying(music_playing->data.mp3_mad)) {
  1.2227 +            playing = 0;
  1.2228 +        }
  1.2229 +        break;
  1.2230  #endif
  1.2231 -	    default:
  1.2232 -		playing = 0;
  1.2233 -		break;
  1.2234 -	}
  1.2235 +        default:
  1.2236 +        playing = 0;
  1.2237 +        break;
  1.2238 +    }
  1.2239  
  1.2240  skip:
  1.2241 -	return(playing);
  1.2242 +    return(playing);
  1.2243  }
  1.2244  int Mix_PlayingMusic(void)
  1.2245  {
  1.2246 -	int playing = 0;
  1.2247 +    int playing = 0;
  1.2248  
  1.2249 -	SDL_LockAudio();
  1.2250 -	if ( music_playing ) {
  1.2251 -		playing = music_loops || music_internal_playing();
  1.2252 -	}
  1.2253 -	SDL_UnlockAudio();
  1.2254 +    SDL_LockAudio();
  1.2255 +    if ( music_playing ) {
  1.2256 +        playing = music_loops || music_internal_playing();
  1.2257 +    }
  1.2258 +    SDL_UnlockAudio();
  1.2259  
  1.2260 -	return(playing);
  1.2261 +    return(playing);
  1.2262  }
  1.2263  
  1.2264  /* Set the external music playback command */
  1.2265  int Mix_SetMusicCMD(const char *command)
  1.2266  {
  1.2267 -	Mix_HaltMusic();
  1.2268 -	if ( music_cmd ) {
  1.2269 -		SDL_free(music_cmd);
  1.2270 -		music_cmd = NULL;
  1.2271 -	}
  1.2272 -	if ( command ) {
  1.2273 -		music_cmd = (char *)SDL_malloc(strlen(command)+1);
  1.2274 -		if ( music_cmd == NULL ) {
  1.2275 -			return(-1);
  1.2276 -		}
  1.2277 -		strcpy(music_cmd, command);
  1.2278 -	}
  1.2279 -	return(0);
  1.2280 +    Mix_HaltMusic();
  1.2281 +    if ( music_cmd ) {
  1.2282 +        SDL_free(music_cmd);
  1.2283 +        music_cmd = NULL;
  1.2284 +    }
  1.2285 +    if ( command ) {
  1.2286 +        music_cmd = (char *)SDL_malloc(strlen(command)+1);
  1.2287 +        if ( music_cmd == NULL ) {
  1.2288 +            return(-1);
  1.2289 +        }
  1.2290 +        strcpy(music_cmd, command);
  1.2291 +    }
  1.2292 +    return(0);
  1.2293  }
  1.2294  
  1.2295  int Mix_SetSynchroValue(int i)
  1.2296  {
  1.2297 -	/* Not supported by any players at this time */
  1.2298 -	return(-1);
  1.2299 +    /* Not supported by any players at this time */
  1.2300 +    return(-1);
  1.2301  }
  1.2302  
  1.2303  int Mix_GetSynchroValue(void)
  1.2304  {
  1.2305 -	/* Not supported by any players at this time */
  1.2306 -	return(-1);
  1.2307 +    /* Not supported by any players at this time */
  1.2308 +    return(-1);
  1.2309  }
  1.2310  
  1.2311  
  1.2312  /* Uninitialize the music players */
  1.2313  void close_music(void)
  1.2314  {
  1.2315 -	Mix_HaltMusic();
  1.2316 +    Mix_HaltMusic();
  1.2317  #ifdef CMD_MUSIC
  1.2318 -	Mix_SetMusicCMD(NULL);
  1.2319 +    Mix_SetMusicCMD(NULL);
  1.2320  #endif
  1.2321  #ifdef MODPLUG_MUSIC
  1.2322 -	modplug_exit();
  1.2323 +    modplug_exit();
  1.2324  #endif
  1.2325  #ifdef MOD_MUSIC
  1.2326 -	MOD_exit();
  1.2327 +    MOD_exit();
  1.2328  #endif
  1.2329  #ifdef MID_MUSIC
  1.2330  # ifdef USE_TIMIDITY_MIDI
  1.2331 -	Timidity_Close();
  1.2332 +    Timidity_Close();
  1.2333  # endif
  1.2334  #endif
  1.2335  
  1.2336 -	/* rcg06042009 report available decoders at runtime. */
  1.2337 -	SDL_free(music_decoders);
  1.2338 -	music_decoders = NULL;
  1.2339 -	num_decoders = 0;
  1.2340 +    /* rcg06042009 report available decoders at runtime. */
  1.2341 +    SDL_free(music_decoders);
  1.2342 +    music_decoders = NULL;
  1.2343 +    num_decoders = 0;
  1.2344  
  1.2345 -	ms_per_step = 0;
  1.2346 +    ms_per_step = 0;
  1.2347  }
  1.2348  
  1.2349  int Mix_SetSoundFonts(const char *paths)
  1.2350  {
  1.2351  #ifdef MID_MUSIC
  1.2352 -	if (soundfont_paths) {
  1.2353 -		SDL_free(soundfont_paths);
  1.2354 -		soundfont_paths = NULL;
  1.2355 -	}
  1.2356 +    if (soundfont_paths) {
  1.2357 +        SDL_free(soundfont_paths);
  1.2358 +        soundfont_paths = NULL;
  1.2359 +    }
  1.2360  
  1.2361 -	if (paths) {
  1.2362 -		if (!(soundfont_paths = SDL_strdup(paths))) {
  1.2363 -			Mix_SetError("Insufficient memory to set SoundFonts");
  1.2364 -			return 0;
  1.2365 -		}
  1.2366 -	}
  1.2367 +    if (paths) {
  1.2368 +        if (!(soundfont_paths = SDL_strdup(paths))) {
  1.2369 +            Mix_SetError("Insufficient memory to set SoundFonts");
  1.2370 +            return 0;
  1.2371 +        }
  1.2372 +    }
  1.2373  #endif
  1.2374 -	return 1;
  1.2375 +    return 1;
  1.2376  }
  1.2377  
  1.2378  #ifdef MID_MUSIC
  1.2379  const char* Mix_GetSoundFonts(void)
  1.2380  {
  1.2381 -	const char* force = getenv("SDL_FORCE_SOUNDFONTS");
  1.2382 +    const char* force = getenv("SDL_FORCE_SOUNDFONTS");
  1.2383  
  1.2384 -	if (!soundfont_paths || (force && force[0] == '1')) {
  1.2385 -		return getenv("SDL_SOUNDFONTS");
  1.2386 -	} else {
  1.2387 -		return soundfont_paths;
  1.2388 -	}
  1.2389 +    if (!soundfont_paths || (force && force[0] == '1')) {
  1.2390 +        return getenv("SDL_SOUNDFONTS");
  1.2391 +    } else {
  1.2392 +        return soundfont_paths;
  1.2393 +    }
  1.2394  }
  1.2395  
  1.2396  int Mix_EachSoundFont(int (*function)(const char*, void*), void *data)
  1.2397  {
  1.2398 -	char *context, *path, *paths;
  1.2399 -	const char* cpaths = Mix_GetSoundFonts();
  1.2400 +    char *context, *path, *paths;
  1.2401 +    const char* cpaths = Mix_GetSoundFonts();
  1.2402  
  1.2403 -	if (!cpaths) {
  1.2404 -		Mix_SetError("No SoundFonts have been requested");
  1.2405 -		return 0;
  1.2406 -	}
  1.2407 +    if (!cpaths) {
  1.2408 +        Mix_SetError("No SoundFonts have been requested");
  1.2409 +        return 0;
  1.2410 +    }
  1.2411  
  1.2412 -	if (!(paths = SDL_strdup(cpaths))) {
  1.2413 -		Mix_SetError("Insufficient memory to iterate over SoundFonts");
  1.2414 -		return 0;
  1.2415 -	}
  1.2416 +    if (!(paths = SDL_strdup(cpaths))) {
  1.2417 +        Mix_SetError("Insufficient memory to iterate over SoundFonts");
  1.2418 +        return 0;
  1.2419 +    }
  1.2420  
  1.2421  #if defined(__MINGW32__) || defined(__MINGW64__)
  1.2422 -	for (path = strtok(paths, ";"); path; path = strtok(NULL, ";")) {
  1.2423 +    for (path = strtok(paths, ";"); path; path = strtok(NULL, ";")) {
  1.2424  #elif defined(_WIN32)
  1.2425 -	for (path = strtok_s(paths, ";", &context); path; path = strtok_s(NULL, ";", &context)) {
  1.2426 +    for (path = strtok_s(paths, ";", &context); path; path = strtok_s(NULL, ";", &context)) {
  1.2427  #else
  1.2428 -	for (path = strtok_r(paths, ":;", &context); path; path = strtok_r(NULL, ":;", &context)) {
  1.2429 +    for (path = strtok_r(paths, ":;", &context); path; path = strtok_r(NULL, ":;", &context)) {
  1.2430  #endif
  1.2431 -		if (!function(path, data)) {
  1.2432 -			SDL_free(paths);
  1.2433 -			return 0;
  1.2434 -		}
  1.2435 -	}
  1.2436 +        if (!function(path, data)) {
  1.2437 +            SDL_free(paths);
  1.2438 +            return 0;
  1.2439 +        }
  1.2440 +    }
  1.2441  
  1.2442 -	SDL_free(paths);
  1.2443 -	return 1;
  1.2444 +    SDL_free(paths);
  1.2445 +    return 1;
  1.2446  }
  1.2447  #endif