clear convert.buf before filling it
authorPatrice Mandin <patmandin@gmail.com>
Sat, 29 Jan 2005 09:58:40 +0000
changeset 10342eca15c3f609
parent 1033 aebfa3ce2a53
child 1035 974ba6ae0fa3
clear convert.buf before filling it
src/audio/mint/SDL_mintaudio.c
     1.1 --- a/src/audio/mint/SDL_mintaudio.c	Tue Jan 25 17:58:44 2005 +0000
     1.2 +++ b/src/audio/mint/SDL_mintaudio.c	Sat Jan 29 09:58:40 2005 +0000
     1.3 @@ -49,19 +49,29 @@
     1.4  void SDL_MintAudio_Callback(void)
     1.5  {
     1.6  	Uint8 *buffer;
     1.7 +	SDL_AudioDevice *audio = SDL_MintAudio_device;
     1.8  
     1.9   	buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf];
    1.10 -	memset(buffer, SDL_MintAudio_device->spec.silence, SDL_MintAudio_device->spec.size);
    1.11 +	memset(buffer, audio->spec.silence, audio->spec.size);
    1.12  
    1.13 -	if ( ! SDL_MintAudio_device->paused ) {
    1.14 -		if ( SDL_MintAudio_device->convert.needed ) {
    1.15 -			SDL_MintAudio_device->spec.callback(SDL_MintAudio_device->spec.userdata,
    1.16 -				(Uint8 *)SDL_MintAudio_device->convert.buf,SDL_MintAudio_device->convert.len);
    1.17 -			SDL_ConvertAudio(&SDL_MintAudio_device->convert);
    1.18 -			memcpy(buffer, SDL_MintAudio_device->convert.buf, SDL_MintAudio_device->convert.len_cvt);
    1.19 +	if (audio->paused)
    1.20 +		return;
    1.21 +
    1.22 +	if (audio->convert.needed) {
    1.23 +		int silence;
    1.24 +
    1.25 +		if ( audio->convert.src_format == AUDIO_U8 ) {
    1.26 +			silence = 0x80;
    1.27  		} else {
    1.28 -			SDL_MintAudio_device->spec.callback(SDL_MintAudio_device->spec.userdata, buffer, SDL_MintAudio_device->spec.size);
    1.29 +			silence = 0;
    1.30  		}
    1.31 +		memset(audio->convert.buf, silence, audio->convert.len);
    1.32 +		audio->spec.callback(audio->spec.userdata,
    1.33 +			(Uint8 *)audio->convert.buf,audio->convert.len);
    1.34 +		SDL_ConvertAudio(&audio->convert);
    1.35 +		memcpy(buffer, audio->convert.buf, audio->convert.len_cvt);
    1.36 +	} else {
    1.37 +		audio->spec.callback(audio->spec.userdata, buffer, audio->spec.size);
    1.38  	}
    1.39  }
    1.40