comparison src/audio/SDL_audio.c @ 1336:3692456e7b0f

Use SDL_ prefixed versions of C library functions. FIXME: Change #include <stdlib.h> to #include "SDL_stdlib.h" Change #include <string.h> to #include "SDL_string.h" Make sure nothing else broke because of this...
author Sam Lantinga <slouken@libsdl.org>
date Tue, 07 Feb 2006 06:59:48 +0000
parents 450721ad5436
children d02b552e5304
comparison
equal deleted inserted replaced
1335:c39265384763 1336:3692456e7b0f
218 stream = audio->GetAudioBuf(audio); 218 stream = audio->GetAudioBuf(audio);
219 if ( stream == NULL ) { 219 if ( stream == NULL ) {
220 stream = audio->fake_stream; 220 stream = audio->fake_stream;
221 } 221 }
222 } 222 }
223 memset(stream, silence, stream_len); 223 SDL_memset(stream, silence, stream_len);
224 224
225 if ( ! audio->paused ) { 225 if ( ! audio->paused ) {
226 SDL_mutexP(audio->mixer_lock); 226 SDL_mutexP(audio->mixer_lock);
227 (*fill)(udata, stream, stream_len); 227 (*fill)(udata, stream, stream_len);
228 SDL_mutexV(audio->mixer_lock); 228 SDL_mutexV(audio->mixer_lock);
233 SDL_ConvertAudio(&audio->convert); 233 SDL_ConvertAudio(&audio->convert);
234 stream = audio->GetAudioBuf(audio); 234 stream = audio->GetAudioBuf(audio);
235 if ( stream == NULL ) { 235 if ( stream == NULL ) {
236 stream = audio->fake_stream; 236 stream = audio->fake_stream;
237 } 237 }
238 memcpy(stream, audio->convert.buf, 238 SDL_memcpy(stream, audio->convert.buf,
239 audio->convert.len_cvt); 239 audio->convert.len_cvt);
240 } 240 }
241 241
242 /* Ready current buffer for play and change current buffer */ 242 /* Ready current buffer for play and change current buffer */
243 if ( stream != audio->fake_stream ) { 243 if ( stream != audio->fake_stream ) {
297 297
298 /* Select the proper audio driver */ 298 /* Select the proper audio driver */
299 audio = NULL; 299 audio = NULL;
300 idx = 0; 300 idx = 0;
301 #ifdef unix 301 #ifdef unix
302 if ( (driver_name == NULL) && (getenv("ESPEAKER") != NULL) ) { 302 if ( (driver_name == NULL) && (SDL_getenv("ESPEAKER") != NULL) ) {
303 /* Ahem, we know that if ESPEAKER is set, user probably wants 303 /* Ahem, we know that if ESPEAKER is set, user probably wants
304 to use ESD, but don't start it if it's not already running. 304 to use ESD, but don't start it if it's not already running.
305 This probably isn't the place to do this, but... Shh! :) 305 This probably isn't the place to do this, but... Shh! :)
306 */ 306 */
307 for ( i=0; bootstrap[i]; ++i ) { 307 for ( i=0; bootstrap[i]; ++i ) {
308 if ( strcmp(bootstrap[i]->name, "esd") == 0 ) { 308 if ( SDL_strcmp(bootstrap[i]->name, "esd") == 0 ) {
309 const char *esd_no_spawn; 309 const char *esd_no_spawn;
310 310
311 /* Don't start ESD if it's not running */ 311 /* Don't start ESD if it's not running */
312 esd_no_spawn = getenv("ESD_NO_SPAWN"); 312 esd_no_spawn = SDL_getenv("ESD_NO_SPAWN");
313 if ( esd_no_spawn == NULL ) { 313 if ( esd_no_spawn == NULL ) {
314 putenv("ESD_NO_SPAWN=1"); 314 putenv("ESD_NO_SPAWN=1");
315 } 315 }
316 if ( bootstrap[i]->available() ) { 316 if ( bootstrap[i]->available() ) {
317 audio = bootstrap[i]->create(0); 317 audio = bootstrap[i]->create(0);
327 } 327 }
328 #endif /* unix */ 328 #endif /* unix */
329 if ( audio == NULL ) { 329 if ( audio == NULL ) {
330 if ( driver_name != NULL ) { 330 if ( driver_name != NULL ) {
331 #if 0 /* This will be replaced with a better driver selection API */ 331 #if 0 /* This will be replaced with a better driver selection API */
332 if ( strrchr(driver_name, ':') != NULL ) { 332 if ( SDL_strrchr(driver_name, ':') != NULL ) {
333 idx = atoi(strrchr(driver_name, ':')+1); 333 idx = atoi(SDL_strrchr(driver_name, ':')+1);
334 } 334 }
335 #endif 335 #endif
336 for ( i=0; bootstrap[i]; ++i ) { 336 for ( i=0; bootstrap[i]; ++i ) {
337 if (strncmp(bootstrap[i]->name, driver_name, 337 if (SDL_strncmp(bootstrap[i]->name, driver_name,
338 strlen(bootstrap[i]->name)) == 0) { 338 SDL_strlen(bootstrap[i]->name)) == 0) {
339 if ( bootstrap[i]->available() ) { 339 if ( bootstrap[i]->available() ) {
340 audio=bootstrap[i]->create(idx); 340 audio=bootstrap[i]->create(idx);
341 break; 341 break;
342 } 342 }
343 } 343 }
373 } 373 }
374 374
375 char *SDL_AudioDriverName(char *namebuf, int maxlen) 375 char *SDL_AudioDriverName(char *namebuf, int maxlen)
376 { 376 {
377 if ( current_audio != NULL ) { 377 if ( current_audio != NULL ) {
378 strncpy(namebuf, current_audio->name, maxlen-1); 378 SDL_strncpy(namebuf, current_audio->name, maxlen-1);
379 namebuf[maxlen-1] = '\0'; 379 namebuf[maxlen-1] = '\0';
380 return(namebuf); 380 return(namebuf);
381 } 381 }
382 return(NULL); 382 return(NULL);
383 } 383 }
434 434
435 /* Calculate the silence and size of the audio specification */ 435 /* Calculate the silence and size of the audio specification */
436 SDL_CalculateAudioSpec(desired); 436 SDL_CalculateAudioSpec(desired);
437 437
438 /* Open the audio subsystem */ 438 /* Open the audio subsystem */
439 memcpy(&audio->spec, desired, sizeof(audio->spec)); 439 SDL_memcpy(&audio->spec, desired, sizeof(audio->spec));
440 audio->convert.needed = 0; 440 audio->convert.needed = 0;
441 audio->enabled = 1; 441 audio->enabled = 1;
442 audio->paused = 1; 442 audio->paused = 1;
443 443
444 #ifndef ENABLE_AHI 444 #ifndef ENABLE_AHI
487 return(-1); 487 return(-1);
488 } 488 }
489 489
490 /* See if we need to do any conversion */ 490 /* See if we need to do any conversion */
491 if ( obtained != NULL ) { 491 if ( obtained != NULL ) {
492 memcpy(obtained, &audio->spec, sizeof(audio->spec)); 492 SDL_memcpy(obtained, &audio->spec, sizeof(audio->spec));
493 } else if ( desired->freq != audio->spec.freq || 493 } else if ( desired->freq != audio->spec.freq ||
494 desired->format != audio->spec.format || 494 desired->format != audio->spec.format ||
495 desired->channels != audio->spec.channels ) { 495 desired->channels != audio->spec.channels ) {
496 /* Build an audio conversion block */ 496 /* Build an audio conversion block */
497 if ( SDL_BuildAudioCVT(&audio->convert, 497 if ( SDL_BuildAudioCVT(&audio->convert,