Mercurial > sdl-ios-xcode
comparison src/audio/macrom/SDL_romaudio.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 | c9b51268668f |
children | 604d73db6802 |
comparison
equal
deleted
inserted
replaced
1335:c39265384763 | 1336:3692456e7b0f |
---|---|
64 return(1); | 64 return(1); |
65 } | 65 } |
66 | 66 |
67 static void Audio_DeleteDevice(SDL_AudioDevice *device) | 67 static void Audio_DeleteDevice(SDL_AudioDevice *device) |
68 { | 68 { |
69 free(device->hidden); | 69 SDL_free(device->hidden); |
70 free(device); | 70 SDL_free(device); |
71 } | 71 } |
72 | 72 |
73 static SDL_AudioDevice *Audio_CreateDevice(int devindex) | 73 static SDL_AudioDevice *Audio_CreateDevice(int devindex) |
74 { | 74 { |
75 SDL_AudioDevice *this; | 75 SDL_AudioDevice *this; |
76 | 76 |
77 /* Initialize all variables that we clean on shutdown */ | 77 /* Initialize all variables that we clean on shutdown */ |
78 this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); | 78 this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice)); |
79 if ( this ) { | 79 if ( this ) { |
80 memset(this, 0, (sizeof *this)); | 80 SDL_memset(this, 0, (sizeof *this)); |
81 this->hidden = (struct SDL_PrivateAudioData *) | 81 this->hidden = (struct SDL_PrivateAudioData *) |
82 malloc((sizeof *this->hidden)); | 82 SDL_malloc((sizeof *this->hidden)); |
83 } | 83 } |
84 if ( (this == NULL) || (this->hidden == NULL) ) { | 84 if ( (this == NULL) || (this->hidden == NULL) ) { |
85 SDL_OutOfMemory(); | 85 SDL_OutOfMemory(); |
86 if ( this ) { | 86 if ( this ) { |
87 free(this); | 87 SDL_free(this); |
88 } | 88 } |
89 return(0); | 89 return(0); |
90 } | 90 } |
91 memset(this->hidden, 0, (sizeof *this->hidden)); | 91 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); |
92 | 92 |
93 /* Set the function pointers */ | 93 /* Set the function pointers */ |
94 this->OpenAudio = Mac_OpenAudio; | 94 this->OpenAudio = Mac_OpenAudio; |
95 this->CloseAudio = Mac_CloseAudio; | 95 this->CloseAudio = Mac_CloseAudio; |
96 this->LockAudio = Mac_LockAudio; | 96 this->LockAudio = Mac_LockAudio; |
133 (Uint8 *)audio->convert.buf,audio->convert.len); | 133 (Uint8 *)audio->convert.buf,audio->convert.len); |
134 SDL_ConvertAudio(&audio->convert); | 134 SDL_ConvertAudio(&audio->convert); |
135 if ( audio->convert.len_cvt != audio->spec.size ) { | 135 if ( audio->convert.len_cvt != audio->spec.size ) { |
136 /* Uh oh... probably crashes here */; | 136 /* Uh oh... probably crashes here */; |
137 } | 137 } |
138 memcpy(buffer, audio->convert.buf, audio->convert.len_cvt); | 138 SDL_memcpy(buffer, audio->convert.buf, audio->convert.len_cvt); |
139 } else { | 139 } else { |
140 audio->spec.callback(audio->spec.userdata, buffer, audio->spec.size); | 140 audio->spec.callback(audio->spec.userdata, buffer, audio->spec.size); |
141 } | 141 } |
142 #ifdef MACOSX | 142 #ifdef MACOSX |
143 SDL_mutexV(audio->mixer_lock); | 143 SDL_mutexV(audio->mixer_lock); |
265 } | 265 } |
266 memset (buffer[i], 0, spec->size); | 266 memset (buffer[i], 0, spec->size); |
267 } | 267 } |
268 | 268 |
269 /* Create the sound manager channel */ | 269 /* Create the sound manager channel */ |
270 channel = (SndChannelPtr)malloc(sizeof(*channel)); | 270 channel = (SndChannelPtr)SDL_malloc(sizeof(*channel)); |
271 if ( channel == NULL ) { | 271 if ( channel == NULL ) { |
272 SDL_OutOfMemory(); | 272 SDL_OutOfMemory(); |
273 return(-1); | 273 return(-1); |
274 } | 274 } |
275 if ( spec->channels >= 2 ) { | 275 if ( spec->channels >= 2 ) { |
279 } | 279 } |
280 channel->userInfo = (long)this; | 280 channel->userInfo = (long)this; |
281 channel->qLength = 128; | 281 channel->qLength = 128; |
282 if ( SndNewChannel(&channel, sampledSynth, initOptions, callback) != noErr ) { | 282 if ( SndNewChannel(&channel, sampledSynth, initOptions, callback) != noErr ) { |
283 SDL_SetError("Unable to create audio channel"); | 283 SDL_SetError("Unable to create audio channel"); |
284 free(channel); | 284 SDL_free(channel); |
285 channel = NULL; | 285 channel = NULL; |
286 return(-1); | 286 return(-1); |
287 } | 287 } |
288 | 288 |
289 /* start playback */ | 289 /* start playback */ |
309 channel = NULL; | 309 channel = NULL; |
310 } | 310 } |
311 | 311 |
312 for ( i=0; i<2; ++i ) { | 312 for ( i=0; i<2; ++i ) { |
313 if ( buffer[i] ) { | 313 if ( buffer[i] ) { |
314 free(buffer[i]); | 314 SDL_free(buffer[i]); |
315 buffer[i] = NULL; | 315 buffer[i] = NULL; |
316 } | 316 } |
317 } | 317 } |
318 } | 318 } |
319 | 319 |
353 #if 0 | 353 #if 0 |
354 if ( audio->convert.len_cvt != audio->spec.size ) { | 354 if ( audio->convert.len_cvt != audio->spec.size ) { |
355 /* Uh oh... probably crashes here */; | 355 /* Uh oh... probably crashes here */; |
356 } | 356 } |
357 #endif | 357 #endif |
358 memcpy(newbuf->dbSoundData, audio->convert.buf, | 358 SDL_memcpy(newbuf->dbSoundData, audio->convert.buf, |
359 audio->convert.len_cvt); | 359 audio->convert.len_cvt); |
360 } else { | 360 } else { |
361 audio->spec.callback(audio->spec.userdata, | 361 audio->spec.callback(audio->spec.userdata, |
362 (Uint8 *)newbuf->dbSoundData, audio->spec.size); | 362 (Uint8 *)newbuf->dbSoundData, audio->spec.size); |
363 } | 363 } |
398 SndDisposeChannel(channel, true); | 398 SndDisposeChannel(channel, true); |
399 channel = NULL; | 399 channel = NULL; |
400 } | 400 } |
401 for ( i=0; i<2; ++i ) { | 401 for ( i=0; i<2; ++i ) { |
402 if ( audio_buf[i] ) { | 402 if ( audio_buf[i] ) { |
403 free(audio_buf[i]); | 403 SDL_free(audio_buf[i]); |
404 audio_buf[i] = NULL; | 404 audio_buf[i] = NULL; |
405 } | 405 } |
406 } | 406 } |
407 } | 407 } |
408 | 408 |
433 break; | 433 break; |
434 } | 434 } |
435 SDL_CalculateAudioSpec(spec); | 435 SDL_CalculateAudioSpec(spec); |
436 | 436 |
437 /* initialize the double-back header */ | 437 /* initialize the double-back header */ |
438 memset(&audio_dbh, 0, sizeof(audio_dbh)); | 438 SDL_memset(&audio_dbh, 0, sizeof(audio_dbh)); |
439 doubleBackProc = NewSndDoubleBackProc (sndDoubleBackProc); | 439 doubleBackProc = NewSndDoubleBackProc (sndDoubleBackProc); |
440 sample_bits = spec->size / spec->samples / spec->channels * 8; | 440 sample_bits = spec->size / spec->samples / spec->channels * 8; |
441 | 441 |
442 audio_dbh.dbhNumChannels = spec->channels; | 442 audio_dbh.dbhNumChannels = spec->channels; |
443 audio_dbh.dbhSampleSize = sample_bits; | 443 audio_dbh.dbhSampleSize = sample_bits; |
465 audio_buf[i]->dbUserInfo[0] = (long)this; | 465 audio_buf[i]->dbUserInfo[0] = (long)this; |
466 audio_dbh.dbhBufferPtr[i] = audio_buf[i]; | 466 audio_dbh.dbhBufferPtr[i] = audio_buf[i]; |
467 } | 467 } |
468 | 468 |
469 /* Create the sound manager channel */ | 469 /* Create the sound manager channel */ |
470 channel = (SndChannelPtr)malloc(sizeof(*channel)); | 470 channel = (SndChannelPtr)SDL_malloc(sizeof(*channel)); |
471 if ( channel == NULL ) { | 471 if ( channel == NULL ) { |
472 SDL_OutOfMemory(); | 472 SDL_OutOfMemory(); |
473 return(-1); | 473 return(-1); |
474 } | 474 } |
475 if ( spec->channels >= 2 ) { | 475 if ( spec->channels >= 2 ) { |
479 } | 479 } |
480 channel->userInfo = 0; | 480 channel->userInfo = 0; |
481 channel->qLength = 128; | 481 channel->qLength = 128; |
482 if ( SndNewChannel(&channel, sampledSynth, initOptions, 0L) != noErr ) { | 482 if ( SndNewChannel(&channel, sampledSynth, initOptions, 0L) != noErr ) { |
483 SDL_SetError("Unable to create audio channel"); | 483 SDL_SetError("Unable to create audio channel"); |
484 free(channel); | 484 SDL_free(channel); |
485 channel = NULL; | 485 channel = NULL; |
486 return(-1); | 486 return(-1); |
487 } | 487 } |
488 | 488 |
489 /* Start playback */ | 489 /* Start playback */ |