# HG changeset patch # User Ryan C. Gordon # Date 1183602276 0 # Node ID 6831b8723a85135dfa30584a8c84e71666ae38f8 # Parent 9776ab9063dec99cdf0e2411fc9e240f93f6f0c5 Don't initialize the audio buffer passed to the application's audio callback, since they are expected to entirely fill it with data or silence. For legacy apps that might expect the buffer to already have silence and thus may not fill the buffer in the callback, there's an environment variable to expose the old behaviour. Fixes Bugzilla #416. diff -r 9776ab9063de -r 6831b8723a85 src/audio/SDL_audio.c --- a/src/audio/SDL_audio.c Wed Jul 04 15:22:47 2007 +0000 +++ b/src/audio/SDL_audio.c Thu Jul 05 02:24:36 2007 +0000 @@ -117,6 +117,13 @@ }; SDL_AudioDevice *current_audio = NULL; +/* + * If non-zero, use legacy behaviour (memset the callback buffer before call). + * Changed to NOT initializing the buffer before the callback in 1.2.12. + * Set environment SDL_AUDIO_MUST_INIT_BUFFERS=1 to get old behaviour. + */ +static int must_init_callback_buffer = 0; + /* Various local functions */ int SDL_AudioInit(const char *driver_name); void SDL_AudioQuit(void); @@ -190,7 +197,10 @@ stream = audio->fake_stream; } } - SDL_memset(stream, silence, stream_len); + + if ( must_init_callback_buffer ) { + SDL_memset(stream, silence, stream_len); + } if ( ! audio->paused ) { SDL_mutexP(audio->mixer_lock); @@ -300,6 +310,9 @@ { SDL_AudioDevice *audio; int i = 0, idx; + const char *envr = SDL_getenv("SDL_AUDIO_MUST_INIT_BUFFERS"); + + must_init_callback_buffer = ((envr != NULL) && (SDL_atoi(envr))); /* Check to make sure we don't overwrite 'current_audio' */ if ( current_audio != NULL ) {