comparison src/audio/SDL_audio.c @ 2147:a5f11bc178b4

Removed campatibility behavior for 1.3
author Sam Lantinga <slouken@libsdl.org>
date Thu, 05 Jul 2007 04:34:48 +0000
parents 665c2669e6a3
children 60b4c52a7906
comparison
equal deleted inserted replaced
2146:9fcde304c7b6 2147:a5f11bc178b4
142 &DART_bootstrap, 142 &DART_bootstrap,
143 #endif 143 #endif
144 NULL 144 NULL
145 }; 145 };
146 146
147 /*
148 * If non-zero, use legacy behaviour (memset the callback buffer before call).
149 * Changed to NOT initializing the buffer before the callback in 1.2.12.
150 * Set environment SDL_AUDIO_MUST_INIT_BUFFERS=1 to get old behaviour.
151 */
152 static int must_init_callback_buffer = 0;
153
154 static SDL_AudioDevice * 147 static SDL_AudioDevice *
155 get_audio_device(SDL_AudioDeviceID id) 148 get_audio_device(SDL_AudioDeviceID id)
156 { 149 {
157 id--; 150 id--;
158 if ((id >= SDL_arraysize(open_devices)) || (open_devices[id] == NULL)) { 151 if ((id >= SDL_arraysize(open_devices)) || (open_devices[id] == NULL)) {
304 } else { 297 } else {
305 stream = current_audio.impl.GetDeviceBuf(device); 298 stream = current_audio.impl.GetDeviceBuf(device);
306 if (stream == NULL) { 299 if (stream == NULL) {
307 stream = device->fake_stream; 300 stream = device->fake_stream;
308 } 301 }
309 }
310
311 /* New code should fill buffer or set it to silence themselves. */
312 if ( must_init_callback_buffer ) {
313 SDL_memset(stream, silence, stream_len);
314 } 302 }
315 303
316 if (!device->paused) { 304 if (!device->paused) {
317 SDL_mutexP(device->mixer_lock); 305 SDL_mutexP(device->mixer_lock);
318 (*fill) (udata, stream, stream_len); 306 (*fill) (udata, stream, stream_len);
394 SDL_AudioInit(const char *driver_name) 382 SDL_AudioInit(const char *driver_name)
395 { 383 {
396 int i = 0; 384 int i = 0;
397 int initialized = 0; 385 int initialized = 0;
398 int tried_to_init = 0; 386 int tried_to_init = 0;
399 const char *envr = SDL_getenv("SDL_AUDIO_MUST_INIT_BUFFERS");
400
401 must_init_callback_buffer = ((envr != NULL) && (SDL_atoi(envr)));
402 387
403 if (SDL_WasInit(SDL_INIT_AUDIO)) { 388 if (SDL_WasInit(SDL_INIT_AUDIO)) {
404 SDL_AudioQuit(); /* shutdown driver if already running. */ 389 SDL_AudioQuit(); /* shutdown driver if already running. */
405 } 390 }
406 391