Mercurial > sdl-ios-xcode
comparison src/audio/macosx/SDL_coreaudio.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 |
---|---|
50 return(1); | 50 return(1); |
51 } | 51 } |
52 | 52 |
53 static void Audio_DeleteDevice(SDL_AudioDevice *device) | 53 static void Audio_DeleteDevice(SDL_AudioDevice *device) |
54 { | 54 { |
55 free(device->hidden); | 55 SDL_free(device->hidden); |
56 free(device); | 56 SDL_free(device); |
57 } | 57 } |
58 | 58 |
59 static SDL_AudioDevice *Audio_CreateDevice(int devindex) | 59 static SDL_AudioDevice *Audio_CreateDevice(int devindex) |
60 { | 60 { |
61 SDL_AudioDevice *this; | 61 SDL_AudioDevice *this; |
62 | 62 |
63 /* Initialize all variables that we clean on shutdown */ | 63 /* Initialize all variables that we clean on shutdown */ |
64 this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); | 64 this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice)); |
65 if ( this ) { | 65 if ( this ) { |
66 memset(this, 0, (sizeof *this)); | 66 SDL_memset(this, 0, (sizeof *this)); |
67 this->hidden = (struct SDL_PrivateAudioData *) | 67 this->hidden = (struct SDL_PrivateAudioData *) |
68 malloc((sizeof *this->hidden)); | 68 SDL_malloc((sizeof *this->hidden)); |
69 } | 69 } |
70 if ( (this == NULL) || (this->hidden == NULL) ) { | 70 if ( (this == NULL) || (this->hidden == NULL) ) { |
71 SDL_OutOfMemory(); | 71 SDL_OutOfMemory(); |
72 if ( this ) { | 72 if ( this ) { |
73 free(this); | 73 SDL_free(this); |
74 } | 74 } |
75 return(0); | 75 return(0); |
76 } | 76 } |
77 memset(this->hidden, 0, (sizeof *this->hidden)); | 77 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); |
78 | 78 |
79 /* Set the function pointers */ | 79 /* Set the function pointers */ |
80 this->OpenAudio = Core_OpenAudio; | 80 this->OpenAudio = Core_OpenAudio; |
81 this->WaitAudio = Core_WaitAudio; | 81 this->WaitAudio = Core_WaitAudio; |
82 this->PlayAudio = Core_PlayAudio; | 82 this->PlayAudio = Core_PlayAudio; |
104 UInt32 remaining, len; | 104 UInt32 remaining, len; |
105 void *ptr; | 105 void *ptr; |
106 | 106 |
107 /* Only do anything if audio is enabled and not paused */ | 107 /* Only do anything if audio is enabled and not paused */ |
108 if ( ! this->enabled || this->paused ) { | 108 if ( ! this->enabled || this->paused ) { |
109 memset(ioData->mData, this->spec.silence, ioData->mDataByteSize); | 109 SDL_memset(ioData->mData, this->spec.silence, ioData->mDataByteSize); |
110 return 0; | 110 return 0; |
111 } | 111 } |
112 | 112 |
113 /* No SDL conversion should be needed here, ever, since we accept | 113 /* No SDL conversion should be needed here, ever, since we accept |
114 any input format in OpenAudio, and leave the conversion to CoreAudio. | 114 any input format in OpenAudio, and leave the conversion to CoreAudio. |
119 remaining = ioData->mDataByteSize; | 119 remaining = ioData->mDataByteSize; |
120 ptr = ioData->mData; | 120 ptr = ioData->mData; |
121 while (remaining > 0) { | 121 while (remaining > 0) { |
122 if (bufferOffset >= bufferSize) { | 122 if (bufferOffset >= bufferSize) { |
123 /* Generate the data */ | 123 /* Generate the data */ |
124 memset(buffer, this->spec.silence, bufferSize); | 124 SDL_memset(buffer, this->spec.silence, bufferSize); |
125 SDL_mutexP(this->mixer_lock); | 125 SDL_mutexP(this->mixer_lock); |
126 (*this->spec.callback)(this->spec.userdata, | 126 (*this->spec.callback)(this->spec.userdata, |
127 buffer, bufferSize); | 127 buffer, bufferSize); |
128 SDL_mutexV(this->mixer_lock); | 128 SDL_mutexV(this->mixer_lock); |
129 bufferOffset = 0; | 129 bufferOffset = 0; |
130 } | 130 } |
131 | 131 |
132 len = bufferSize - bufferOffset; | 132 len = bufferSize - bufferOffset; |
133 if (len > remaining) | 133 if (len > remaining) |
134 len = remaining; | 134 len = remaining; |
135 memcpy(ptr, buffer + bufferOffset, len); | 135 SDL_memcpy(ptr, buffer + bufferOffset, len); |
136 ptr += len; | 136 ptr += len; |
137 remaining -= len; | 137 remaining -= len; |
138 bufferOffset += len; | 138 bufferOffset += len; |
139 } | 139 } |
140 | 140 |
187 if (result != noErr) { | 187 if (result != noErr) { |
188 SDL_SetError("Core_CloseAudio: CloseComponent"); | 188 SDL_SetError("Core_CloseAudio: CloseComponent"); |
189 return; | 189 return; |
190 } | 190 } |
191 | 191 |
192 free(buffer); | 192 SDL_free(buffer); |
193 } | 193 } |
194 | 194 |
195 #define CHECK_RESULT(msg) \ | 195 #define CHECK_RESULT(msg) \ |
196 if (result != noErr) { \ | 196 if (result != noErr) { \ |
197 SDL_SetError("Failed to start CoreAudio: " msg); \ | 197 SDL_SetError("Failed to start CoreAudio: " msg); \ |
267 /* Calculate the final parameters for this audio specification */ | 267 /* Calculate the final parameters for this audio specification */ |
268 SDL_CalculateAudioSpec(spec); | 268 SDL_CalculateAudioSpec(spec); |
269 | 269 |
270 /* Allocate a sample buffer */ | 270 /* Allocate a sample buffer */ |
271 bufferOffset = bufferSize = this->spec.size; | 271 bufferOffset = bufferSize = this->spec.size; |
272 buffer = malloc(bufferSize); | 272 buffer = SDL_malloc(bufferSize); |
273 assert(buffer); | 273 assert(buffer); |
274 | 274 |
275 /* Finally, start processing of the audio unit */ | 275 /* Finally, start processing of the audio unit */ |
276 result = AudioOutputUnitStart (outputAudioUnit); | 276 result = AudioOutputUnitStart (outputAudioUnit); |
277 CHECK_RESULT("AudioOutputUnitStart") | 277 CHECK_RESULT("AudioOutputUnitStart") |