changeset 1034:2eca15c3f609

clear convert.buf before filling it
author Patrice Mandin <patmandin@gmail.com>
date Sat, 29 Jan 2005 09:58:40 +0000
parents aebfa3ce2a53
children 974ba6ae0fa3
files src/audio/mint/SDL_mintaudio.c
diffstat 1 files changed, 18 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/audio/mint/SDL_mintaudio.c	Tue Jan 25 17:58:44 2005 +0000
+++ b/src/audio/mint/SDL_mintaudio.c	Sat Jan 29 09:58:40 2005 +0000
@@ -49,19 +49,29 @@
 void SDL_MintAudio_Callback(void)
 {
 	Uint8 *buffer;
+	SDL_AudioDevice *audio = SDL_MintAudio_device;
 
  	buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf];
-	memset(buffer, SDL_MintAudio_device->spec.silence, SDL_MintAudio_device->spec.size);
+	memset(buffer, audio->spec.silence, audio->spec.size);
+
+	if (audio->paused)
+		return;
+
+	if (audio->convert.needed) {
+		int silence;
 
-	if ( ! SDL_MintAudio_device->paused ) {
-		if ( SDL_MintAudio_device->convert.needed ) {
-			SDL_MintAudio_device->spec.callback(SDL_MintAudio_device->spec.userdata,
-				(Uint8 *)SDL_MintAudio_device->convert.buf,SDL_MintAudio_device->convert.len);
-			SDL_ConvertAudio(&SDL_MintAudio_device->convert);
-			memcpy(buffer, SDL_MintAudio_device->convert.buf, SDL_MintAudio_device->convert.len_cvt);
+		if ( audio->convert.src_format == AUDIO_U8 ) {
+			silence = 0x80;
 		} else {
-			SDL_MintAudio_device->spec.callback(SDL_MintAudio_device->spec.userdata, buffer, SDL_MintAudio_device->spec.size);
+			silence = 0;
 		}
+		memset(audio->convert.buf, silence, audio->convert.len);
+		audio->spec.callback(audio->spec.userdata,
+			(Uint8 *)audio->convert.buf,audio->convert.len);
+		SDL_ConvertAudio(&audio->convert);
+		memcpy(buffer, audio->convert.buf, audio->convert.len_cvt);
+	} else {
+		audio->spec.callback(audio->spec.userdata, buffer, audio->spec.size);
 	}
 }