src/audio/mint/SDL_mintaudio.c
changeset 1034 2eca15c3f609
parent 961 185acc07127a
child 1107 856f76a099c7
equal deleted inserted replaced
1033:aebfa3ce2a53 1034:2eca15c3f609
    47 /* The callback function, called by each driver whenever needed */
    47 /* The callback function, called by each driver whenever needed */
    48 
    48 
    49 void SDL_MintAudio_Callback(void)
    49 void SDL_MintAudio_Callback(void)
    50 {
    50 {
    51 	Uint8 *buffer;
    51 	Uint8 *buffer;
       
    52 	SDL_AudioDevice *audio = SDL_MintAudio_device;
    52 
    53 
    53  	buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf];
    54  	buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf];
    54 	memset(buffer, SDL_MintAudio_device->spec.silence, SDL_MintAudio_device->spec.size);
    55 	memset(buffer, audio->spec.silence, audio->spec.size);
    55 
    56 
    56 	if ( ! SDL_MintAudio_device->paused ) {
    57 	if (audio->paused)
    57 		if ( SDL_MintAudio_device->convert.needed ) {
    58 		return;
    58 			SDL_MintAudio_device->spec.callback(SDL_MintAudio_device->spec.userdata,
    59 
    59 				(Uint8 *)SDL_MintAudio_device->convert.buf,SDL_MintAudio_device->convert.len);
    60 	if (audio->convert.needed) {
    60 			SDL_ConvertAudio(&SDL_MintAudio_device->convert);
    61 		int silence;
    61 			memcpy(buffer, SDL_MintAudio_device->convert.buf, SDL_MintAudio_device->convert.len_cvt);
    62 
       
    63 		if ( audio->convert.src_format == AUDIO_U8 ) {
       
    64 			silence = 0x80;
    62 		} else {
    65 		} else {
    63 			SDL_MintAudio_device->spec.callback(SDL_MintAudio_device->spec.userdata, buffer, SDL_MintAudio_device->spec.size);
    66 			silence = 0;
    64 		}
    67 		}
       
    68 		memset(audio->convert.buf, silence, audio->convert.len);
       
    69 		audio->spec.callback(audio->spec.userdata,
       
    70 			(Uint8 *)audio->convert.buf,audio->convert.len);
       
    71 		SDL_ConvertAudio(&audio->convert);
       
    72 		memcpy(buffer, audio->convert.buf, audio->convert.len_cvt);
       
    73 	} else {
       
    74 		audio->spec.callback(audio->spec.userdata, buffer, audio->spec.size);
    65 	}
    75 	}
    66 }
    76 }
    67 
    77 
    68 /* Add a new frequency/clock/predivisor to the current list */
    78 /* Add a new frequency/clock/predivisor to the current list */
    69 void SDL_MintAudio_AddFrequency(_THIS, Uint32 frequency, Uint32 clock, Uint32 prediv)
    79 void SDL_MintAudio_AddFrequency(_THIS, Uint32 frequency, Uint32 clock, Uint32 prediv)