comparison src/audio/macosx/SDL_coreaudio.c @ 2016:72fa74928062

Compile fixes.
author Ryan C. Gordon <icculus@icculus.org>
date Sat, 02 Sep 2006 21:19:00 +0000
parents 506851d3efa4
children df06e6eb65c6
comparison
equal deleted inserted replaced
2015:152dcc2f089f 2016:72fa74928062
205 { 205 {
206 OSStatus result = noErr; 206 OSStatus result = noErr;
207 Component comp; 207 Component comp;
208 ComponentDescription desc; 208 ComponentDescription desc;
209 struct AudioUnitInputCallback callback; 209 struct AudioUnitInputCallback callback;
210 AudioStreamBasicDescription desc; 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(&desc, '\0', sizeof (AudioStreamBasicDescription)); 215 memset(&strdesc, '\0', sizeof (AudioStreamBasicDescription));
216 desc.mFormatID = kAudioFormatLinearPCM; 216 strdesc.mFormatID = kAudioFormatLinearPCM;
217 desc.mFormatFlags = kLinearPCMFormatFlagIsPacked; 217 strdesc.mFormatFlags = kLinearPCMFormatFlagIsPacked;
218 desc.mChannelsPerFrame = spec->channels; 218 strdesc.mChannelsPerFrame = spec->channels;
219 desc.mSampleRate = spec->freq; 219 strdesc.mSampleRate = spec->freq;
220 desc.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 desc.mFormatFlags = 0;
225 /* 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. */
226 switch (test_format) { 225 switch (test_format) {
227 case AUDIO_U8: 226 case AUDIO_U8:
228 case AUDIO_S8: 227 case AUDIO_S8:
229 case AUDIO_U16LSB: 228 case AUDIO_U16LSB:
233 case AUDIO_S32LSB: 232 case AUDIO_S32LSB:
234 case AUDIO_S32MSB: 233 case AUDIO_S32MSB:
235 case AUDIO_F32LSB: 234 case AUDIO_F32LSB:
236 case AUDIO_F32MSB: 235 case AUDIO_F32MSB:
237 valid_datatype = 1; 236 valid_datatype = 1;
238 desc.mBitsPerChannel = SDL_AUDIO_BITSIZE(spec->format); 237 strdesc.mBitsPerChannel = SDL_AUDIO_BITSIZE(spec->format);
238 if (SDL_AUDIO_ISBIGENDIAN(spec->format))
239 strdesc.mFormatFlags |= kLinearPCMFormatFlagIsBigEndian;
239 240
240 if (SDL_AUDIO_ISFLOAT(spec->format)) 241 if (SDL_AUDIO_ISFLOAT(spec->format))
241 desc.mFormatFlags |= kLinearPCMFormatFlagIsFloat; 242 strdesc.mFormatFlags |= kLinearPCMFormatFlagIsFloat;
242 else if (SDL_AUDIO_ISSIGNED(spec->format)) 243 else if (SDL_AUDIO_ISSIGNED(spec->format))
243 desc.mFormatFlags |= kLinearPCMFormatFlagIsSignedInteger; 244 strdesc.mFormatFlags |= kLinearPCMFormatFlagIsSignedInteger;
244
245 if (SDL_AUDIO_ISBIGENDIAN(spec->format))
246 desc.mFormatFlags |= kLinearPCMFormatFlagIsBigEndian;
247 break; 245 break;
248 } 246 }
249 } 247 }
250 248
251 if (!valid_datatype) { /* shouldn't happen, but just in case... */ 249 if (!valid_datatype) { /* shouldn't happen, but just in case... */
252 SDL_SetError("Unsupported audio format"); 250 SDL_SetError("Unsupported audio format");
253 return (-1); 251 return (-1);
254 } 252 }
255 253
256 desc.mBytesPerFrame = 254 strdesc.mBytesPerFrame =
257 desc.mBitsPerChannel * desc.mChannelsPerFrame / 8; 255 strdesc.mBitsPerChannel * strdesc.mChannelsPerFrame / 8;
258 desc.mBytesPerPacket = 256 strdesc.mBytesPerPacket =
259 desc.mBytesPerFrame * desc.mFramesPerPacket; 257 strdesc.mBytesPerFrame * strdesc.mFramesPerPacket;
260
261 258
262 /* Locate the default output audio unit */ 259 /* Locate the default output audio unit */
260 memset(&desc, '\0', sizeof (ComponentDescription));
263 desc.componentType = kAudioUnitComponentType; 261 desc.componentType = kAudioUnitComponentType;
264 desc.componentSubType = kAudioUnitSubType_Output; 262 desc.componentSubType = kAudioUnitSubType_Output;
265 desc.componentManufacturer = kAudioUnitID_DefaultOutput; 263 desc.componentManufacturer = kAudioUnitID_DefaultOutput;
266 desc.componentFlags = 0; 264 desc.componentFlags = 0;
267 desc.componentFlagsMask = 0; 265 desc.componentFlagsMask = 0;