Mercurial > sdl-ios-xcode
comparison src/audio/macosx/SDL_coreaudio.c @ 2043:adf732f1f016
Formatting update
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 24 Sep 2006 15:56:55 +0000 |
parents | df06e6eb65c6 |
children | 5f6550e5184f 37c9c4590689 |
comparison
equal
deleted
inserted
replaced
2042:3908e1f808e1 | 2043:adf732f1f016 |
---|---|
210 AudioStreamBasicDescription strdesc; | 210 AudioStreamBasicDescription strdesc; |
211 SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format); | 211 SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format); |
212 int valid_datatype = 0; | 212 int valid_datatype = 0; |
213 | 213 |
214 /* Setup a AudioStreamBasicDescription with the requested format */ | 214 /* Setup a AudioStreamBasicDescription with the requested format */ |
215 memset(&strdesc, '\0', sizeof (AudioStreamBasicDescription)); | 215 memset(&strdesc, '\0', sizeof(AudioStreamBasicDescription)); |
216 strdesc.mFormatID = kAudioFormatLinearPCM; | 216 strdesc.mFormatID = kAudioFormatLinearPCM; |
217 strdesc.mFormatFlags = kLinearPCMFormatFlagIsPacked; | 217 strdesc.mFormatFlags = kLinearPCMFormatFlagIsPacked; |
218 strdesc.mChannelsPerFrame = spec->channels; | 218 strdesc.mChannelsPerFrame = spec->channels; |
219 strdesc.mSampleRate = spec->freq; | 219 strdesc.mSampleRate = spec->freq; |
220 strdesc.mFramesPerPacket = 1; | 220 strdesc.mFramesPerPacket = 1; |
221 | 221 |
222 while ((!valid_datatype) && (test_format)) { | 222 while ((!valid_datatype) && (test_format)) { |
223 spec->format = test_format; | 223 spec->format = test_format; |
224 /* Just a list of valid SDL formats, so people don't pass junk here. */ | 224 /* Just a list of valid SDL formats, so people don't pass junk here. */ |
225 switch (test_format) { | 225 switch (test_format) { |
226 case AUDIO_U8: | 226 case AUDIO_U8: |
227 case AUDIO_S8: | 227 case AUDIO_S8: |
228 case AUDIO_U16LSB: | 228 case AUDIO_U16LSB: |
229 case AUDIO_S16LSB: | 229 case AUDIO_S16LSB: |
230 case AUDIO_U16MSB: | 230 case AUDIO_U16MSB: |
231 case AUDIO_S16MSB: | 231 case AUDIO_S16MSB: |
232 case AUDIO_S32LSB: | 232 case AUDIO_S32LSB: |
233 case AUDIO_S32MSB: | 233 case AUDIO_S32MSB: |
234 case AUDIO_F32LSB: | 234 case AUDIO_F32LSB: |
235 case AUDIO_F32MSB: | 235 case AUDIO_F32MSB: |
236 valid_datatype = 1; | 236 valid_datatype = 1; |
237 strdesc.mBitsPerChannel = SDL_AUDIO_BITSIZE(spec->format); | 237 strdesc.mBitsPerChannel = SDL_AUDIO_BITSIZE(spec->format); |
238 if (SDL_AUDIO_ISBIGENDIAN(spec->format)) | 238 if (SDL_AUDIO_ISBIGENDIAN(spec->format)) |
239 strdesc.mFormatFlags |= kLinearPCMFormatFlagIsBigEndian; | 239 strdesc.mFormatFlags |= kLinearPCMFormatFlagIsBigEndian; |
240 | 240 |
241 if (SDL_AUDIO_ISFLOAT(spec->format)) | 241 if (SDL_AUDIO_ISFLOAT(spec->format)) |
242 strdesc.mFormatFlags |= kLinearPCMFormatFlagIsFloat; | 242 strdesc.mFormatFlags |= kLinearPCMFormatFlagIsFloat; |
243 else if (SDL_AUDIO_ISSIGNED(spec->format)) | 243 else if (SDL_AUDIO_ISSIGNED(spec->format)) |
244 strdesc.mFormatFlags |= kLinearPCMFormatFlagIsSignedInteger; | 244 strdesc.mFormatFlags |= kLinearPCMFormatFlagIsSignedInteger; |
245 break; | 245 break; |
246 } | 246 } |
247 } | 247 } |
248 | 248 |
249 if (!valid_datatype) { /* shouldn't happen, but just in case... */ | 249 if (!valid_datatype) { /* shouldn't happen, but just in case... */ |
250 SDL_SetError("Unsupported audio format"); | 250 SDL_SetError("Unsupported audio format"); |
251 return (-1); | 251 return (-1); |
252 } | 252 } |
253 | 253 |
254 strdesc.mBytesPerFrame = | 254 strdesc.mBytesPerFrame = |
255 strdesc.mBitsPerChannel * strdesc.mChannelsPerFrame / 8; | 255 strdesc.mBitsPerChannel * strdesc.mChannelsPerFrame / 8; |
256 strdesc.mBytesPerPacket = | 256 strdesc.mBytesPerPacket = |
257 strdesc.mBytesPerFrame * strdesc.mFramesPerPacket; | 257 strdesc.mBytesPerFrame * strdesc.mFramesPerPacket; |
258 | 258 |
259 /* Locate the default output audio unit */ | 259 /* Locate the default output audio unit */ |
260 memset(&desc, '\0', sizeof (ComponentDescription)); | 260 memset(&desc, '\0', sizeof(ComponentDescription)); |
261 desc.componentType = kAudioUnitComponentType; | 261 desc.componentType = kAudioUnitComponentType; |
262 desc.componentSubType = kAudioUnitSubType_Output; | 262 desc.componentSubType = kAudioUnitSubType_Output; |
263 desc.componentManufacturer = kAudioUnitID_DefaultOutput; | 263 desc.componentManufacturer = kAudioUnitID_DefaultOutput; |
264 desc.componentFlags = 0; | 264 desc.componentFlags = 0; |
265 desc.componentFlagsMask = 0; | 265 desc.componentFlagsMask = 0; |
278 CHECK_RESULT("AudioUnitInitialize") | 278 CHECK_RESULT("AudioUnitInitialize") |
279 /* Set the input format of the audio unit. */ | 279 /* Set the input format of the audio unit. */ |
280 result = AudioUnitSetProperty(outputAudioUnit, | 280 result = AudioUnitSetProperty(outputAudioUnit, |
281 kAudioUnitProperty_StreamFormat, | 281 kAudioUnitProperty_StreamFormat, |
282 kAudioUnitScope_Input, | 282 kAudioUnitScope_Input, |
283 0, | 283 0, &strdesc, sizeof(strdesc)); |
284 &strdesc, sizeof (strdesc)); | |
285 CHECK_RESULT("AudioUnitSetProperty (kAudioUnitProperty_StreamFormat)") | 284 CHECK_RESULT("AudioUnitSetProperty (kAudioUnitProperty_StreamFormat)") |
286 /* Set the audio callback */ | 285 /* Set the audio callback */ |
287 callback.inputProc = audioCallback; | 286 callback.inputProc = audioCallback; |
288 callback.inputProcRefCon = this; | 287 callback.inputProcRefCon = this; |
289 result = AudioUnitSetProperty(outputAudioUnit, | 288 result = AudioUnitSetProperty(outputAudioUnit, |