comparison src/audio/sun/SDL_sunaudio.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
73 return(available); 73 return(available);
74 } 74 }
75 75
76 static void Audio_DeleteDevice(SDL_AudioDevice *device) 76 static void Audio_DeleteDevice(SDL_AudioDevice *device)
77 { 77 {
78 free(device->hidden); 78 SDL_free(device->hidden);
79 free(device); 79 SDL_free(device);
80 } 80 }
81 81
82 static SDL_AudioDevice *Audio_CreateDevice(int devindex) 82 static SDL_AudioDevice *Audio_CreateDevice(int devindex)
83 { 83 {
84 SDL_AudioDevice *this; 84 SDL_AudioDevice *this;
85 85
86 /* Initialize all variables that we clean on shutdown */ 86 /* Initialize all variables that we clean on shutdown */
87 this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); 87 this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
88 if ( this ) { 88 if ( this ) {
89 memset(this, 0, (sizeof *this)); 89 SDL_memset(this, 0, (sizeof *this));
90 this->hidden = (struct SDL_PrivateAudioData *) 90 this->hidden = (struct SDL_PrivateAudioData *)
91 malloc((sizeof *this->hidden)); 91 SDL_malloc((sizeof *this->hidden));
92 } 92 }
93 if ( (this == NULL) || (this->hidden == NULL) ) { 93 if ( (this == NULL) || (this->hidden == NULL) ) {
94 SDL_OutOfMemory(); 94 SDL_OutOfMemory();
95 if ( this ) { 95 if ( this ) {
96 free(this); 96 SDL_free(this);
97 } 97 }
98 return(0); 98 return(0);
99 } 99 }
100 memset(this->hidden, 0, (sizeof *this->hidden)); 100 SDL_memset(this->hidden, 0, (sizeof *this->hidden));
101 audio_fd = -1; 101 audio_fd = -1;
102 102
103 /* Set the function pointers */ 103 /* Set the function pointers */
104 this->OpenAudio = DSP_OpenAudio; 104 this->OpenAudio = DSP_OpenAudio;
105 this->WaitAudio = DSP_WaitAudio; 105 this->WaitAudio = DSP_WaitAudio;
234 if ( mixbuf != NULL ) { 234 if ( mixbuf != NULL ) {
235 SDL_FreeAudioMem(mixbuf); 235 SDL_FreeAudioMem(mixbuf);
236 mixbuf = NULL; 236 mixbuf = NULL;
237 } 237 }
238 if ( ulaw_buf != NULL ) { 238 if ( ulaw_buf != NULL ) {
239 free(ulaw_buf); 239 SDL_free(ulaw_buf);
240 ulaw_buf = NULL; 240 ulaw_buf = NULL;
241 } 241 }
242 close(audio_fd); 242 close(audio_fd);
243 } 243 }
244 244
347 /* We can actually convert on-the-fly to U-Law */ 347 /* We can actually convert on-the-fly to U-Law */
348 if ( ulaw_only ) { 348 if ( ulaw_only ) {
349 spec->freq = desired_freq; 349 spec->freq = desired_freq;
350 fragsize = (spec->samples*1000)/(spec->freq/8); 350 fragsize = (spec->samples*1000)/(spec->freq/8);
351 frequency = 8; 351 frequency = 8;
352 ulaw_buf = (Uint8 *)malloc(fragsize); 352 ulaw_buf = (Uint8 *)SDL_malloc(fragsize);
353 if ( ulaw_buf == NULL ) { 353 if ( ulaw_buf == NULL ) {
354 SDL_OutOfMemory(); 354 SDL_OutOfMemory();
355 return(-1); 355 return(-1);
356 } 356 }
357 spec->channels = 1; 357 spec->channels = 1;
373 mixbuf = (Uint8 *)SDL_AllocAudioMem(spec->size); 373 mixbuf = (Uint8 *)SDL_AllocAudioMem(spec->size);
374 if ( mixbuf == NULL ) { 374 if ( mixbuf == NULL ) {
375 SDL_OutOfMemory(); 375 SDL_OutOfMemory();
376 return(-1); 376 return(-1);
377 } 377 }
378 memset(mixbuf, spec->silence, spec->size); 378 SDL_memset(mixbuf, spec->silence, spec->size);
379 379
380 /* We're ready to rock and roll. :-) */ 380 /* We're ready to rock and roll. :-) */
381 return(0); 381 return(0);
382 } 382 }
383 383