comparison src/audio/baudio/SDL_beaudio.cc @ 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
52 return(1); 52 return(1);
53 } 53 }
54 54
55 static void Audio_DeleteDevice(SDL_AudioDevice *device) 55 static void Audio_DeleteDevice(SDL_AudioDevice *device)
56 { 56 {
57 free(device->hidden); 57 SDL_free(device->hidden);
58 free(device); 58 SDL_free(device);
59 } 59 }
60 60
61 static SDL_AudioDevice *Audio_CreateDevice(int devindex) 61 static SDL_AudioDevice *Audio_CreateDevice(int devindex)
62 { 62 {
63 SDL_AudioDevice *device; 63 SDL_AudioDevice *device;
64 64
65 /* Initialize all variables that we clean on shutdown */ 65 /* Initialize all variables that we clean on shutdown */
66 device = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); 66 device = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
67 if ( device ) { 67 if ( device ) {
68 memset(device, 0, (sizeof *device)); 68 SDL_memset(device, 0, (sizeof *device));
69 device->hidden = (struct SDL_PrivateAudioData *) 69 device->hidden = (struct SDL_PrivateAudioData *)
70 malloc((sizeof *device->hidden)); 70 SDL_malloc((sizeof *device->hidden));
71 } 71 }
72 if ( (device == NULL) || (device->hidden == NULL) ) { 72 if ( (device == NULL) || (device->hidden == NULL) ) {
73 SDL_OutOfMemory(); 73 SDL_OutOfMemory();
74 if ( device ) { 74 if ( device ) {
75 free(device); 75 SDL_free(device);
76 } 76 }
77 return(0); 77 return(0);
78 } 78 }
79 memset(device->hidden, 0, (sizeof *device->hidden)); 79 SDL_memset(device->hidden, 0, (sizeof *device->hidden));
80 80
81 /* Set the function pointers */ 81 /* Set the function pointers */
82 device->OpenAudio = BE_OpenAudio; 82 device->OpenAudio = BE_OpenAudio;
83 device->WaitAudio = BE_WaitAudio; 83 device->WaitAudio = BE_WaitAudio;
84 device->PlayAudio = BE_PlayAudio; 84 device->PlayAudio = BE_PlayAudio;
100 const media_raw_audio_format &format) 100 const media_raw_audio_format &format)
101 { 101 {
102 SDL_AudioDevice *audio = (SDL_AudioDevice *)device; 102 SDL_AudioDevice *audio = (SDL_AudioDevice *)device;
103 103
104 /* Silence the buffer, since it's ours */ 104 /* Silence the buffer, since it's ours */
105 memset(stream, audio->spec.silence, len); 105 SDL_memset(stream, audio->spec.silence, len);
106 106
107 /* Only do soemthing if audio is enabled */ 107 /* Only do soemthing if audio is enabled */
108 if ( ! audio->enabled ) 108 if ( ! audio->enabled )
109 return; 109 return;
110 110
113 SDL_mutexP(audio->mixer_lock); 113 SDL_mutexP(audio->mixer_lock);
114 (*audio->spec.callback)(audio->spec.userdata, 114 (*audio->spec.callback)(audio->spec.userdata,
115 (Uint8 *)audio->convert.buf,audio->convert.len); 115 (Uint8 *)audio->convert.buf,audio->convert.len);
116 SDL_mutexV(audio->mixer_lock); 116 SDL_mutexV(audio->mixer_lock);
117 SDL_ConvertAudio(&audio->convert); 117 SDL_ConvertAudio(&audio->convert);
118 memcpy(stream,audio->convert.buf,audio->convert.len_cvt); 118 SDL_memcpy(stream,audio->convert.buf,audio->convert.len_cvt);
119 } else { 119 } else {
120 SDL_mutexP(audio->mixer_lock); 120 SDL_mutexP(audio->mixer_lock);
121 (*audio->spec.callback)(audio->spec.userdata, 121 (*audio->spec.callback)(audio->spec.userdata,
122 (Uint8 *)stream, len); 122 (Uint8 *)stream, len);
123 SDL_mutexV(audio->mixer_lock); 123 SDL_mutexV(audio->mixer_lock);