comparison src/cdrom/macosx/AudioFilePlayer.c @ 4190:386181851388 SDL-1.2

Fixed CD-ROM code to work with Mac OS X 10.6 SDK and 64-bit targets.
author Ryan C. Gordon <icculus@icculus.org>
date Sat, 12 Sep 2009 15:06:16 +0000
parents a1b03ba2fcd0
children
comparison
equal deleted inserted replaced
4189:95213cf5efcc 4190:386181851388
21 21
22 This file based on Apple sample code. We haven't changed the file name, 22 This file based on Apple sample code. We haven't changed the file name,
23 so if you want to see the original search for it on apple.com/developer 23 so if you want to see the original search for it on apple.com/developer
24 */ 24 */
25 #include "SDL_config.h" 25 #include "SDL_config.h"
26 #include "SDL_endian.h"
26 27
27 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 28 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
28 AudioFilePlayer.cpp 29 AudioFilePlayer.cpp
29 */ 30 */
30 #include "AudioFilePlayer.h" 31 #include "AudioFilePlayer.h"
76 if (result) return 0; /*THROW_RESULT("GetComponentInfo")*/ 77 if (result) return 0; /*THROW_RESULT("GetComponentInfo")*/
77 78
78 /* we're going to use this to know which convert routine to call 79 /* we're going to use this to know which convert routine to call
79 a v1 audio unit will have a type of 'aunt' 80 a v1 audio unit will have a type of 'aunt'
80 a v2 audio unit will have one of several different types. */ 81 a v2 audio unit will have one of several different types. */
81 if (desc.componentType != kAudioUnitComponentType) { 82 if (desc.componentType != kAudioUnitType_Output) {
82 result = badComponentInstance; 83 result = badComponentInstance;
83 /*THROW_RESULT("BAD COMPONENT")*/ 84 /*THROW_RESULT("BAD COMPONENT")*/
84 if (result) return 0; 85 if (result) return 0;
85 } 86 }
86 87
173 /* set the render callback for the file data to be supplied to the sound converter AU */ 174 /* set the render callback for the file data to be supplied to the sound converter AU */
174 afp->mInputCallback.inputProc = afp->mAudioFileManager->FileInputProc; 175 afp->mInputCallback.inputProc = afp->mAudioFileManager->FileInputProc;
175 afp->mInputCallback.inputProcRefCon = afp->mAudioFileManager; 176 afp->mInputCallback.inputProcRefCon = afp->mAudioFileManager;
176 177
177 OSStatus result = AudioUnitSetProperty (afp->mPlayUnit, 178 OSStatus result = AudioUnitSetProperty (afp->mPlayUnit,
178 kAudioUnitProperty_SetInputCallback, 179 kAudioUnitProperty_SetRenderCallback,
179 kAudioUnitScope_Input, 180 kAudioUnitScope_Input,
180 0, 181 0,
181 &afp->mInputCallback, 182 &afp->mInputCallback,
182 sizeof(afp->mInputCallback)); 183 sizeof(afp->mInputCallback));
183 if (result) return 0; /*THROW_RESULT("AudioUnitSetProperty")*/ 184 if (result) return 0; /*THROW_RESULT("AudioUnitSetProperty")*/
213 afp->mConnected = 0; 214 afp->mConnected = 0;
214 215
215 afp->mInputCallback.inputProc = 0; 216 afp->mInputCallback.inputProc = 0;
216 afp->mInputCallback.inputProcRefCon = 0; 217 afp->mInputCallback.inputProcRefCon = 0;
217 OSStatus result = AudioUnitSetProperty (afp->mPlayUnit, 218 OSStatus result = AudioUnitSetProperty (afp->mPlayUnit,
218 kAudioUnitProperty_SetInputCallback, 219 kAudioUnitProperty_SetRenderCallback,
219 kAudioUnitScope_Input, 220 kAudioUnitScope_Input,
220 0, 221 0,
221 &afp->mInputCallback, 222 &afp->mInputCallback,
222 sizeof(afp->mInputCallback)); 223 sizeof(afp->mInputCallback));
223 if (result) 224 if (result)
252 253
253 /* Read the file header, and check if it's indeed an AIFC file */ 254 /* Read the file header, and check if it's indeed an AIFC file */
254 result = FSReadFork(afp->mForkRefNum, fsAtMark, 0, sizeof(chunkHeader), &chunkHeader, &actual); 255 result = FSReadFork(afp->mForkRefNum, fsAtMark, 0, sizeof(chunkHeader), &chunkHeader, &actual);
255 if (result) return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSReadFork")*/ 256 if (result) return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSReadFork")*/
256 257
257 if (chunkHeader.ckID != 'FORM') { 258 if (SDL_SwapBE32(chunkHeader.ckID) != 'FORM') {
258 result = -1; 259 result = -1;
259 if (result) return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): chunk id is not 'FORM'");*/ 260 if (result) return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): chunk id is not 'FORM'");*/
260 } 261 }
261 262
262 if (chunkHeader.formType != 'AIFC') { 263 if (SDL_SwapBE32(chunkHeader.formType) != 'AIFC') {
263 result = -1; 264 result = -1;
264 if (result) return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): file format is not 'AIFC'");*/ 265 if (result) return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): file format is not 'AIFC'");*/
265 } 266 }
266 267
267 /* Search for the SSND chunk. We ignore all compression etc. information 268 /* Search for the SSND chunk. We ignore all compression etc. information
270 TODO: Parse the COMM chunk we currently skip to fill in mFileDescription. 271 TODO: Parse the COMM chunk we currently skip to fill in mFileDescription.
271 */ 272 */
272 offset = 0; 273 offset = 0;
273 do { 274 do {
274 result = FSReadFork(afp->mForkRefNum, fsFromMark, offset, sizeof(chunk), &chunk, &actual); 275 result = FSReadFork(afp->mForkRefNum, fsFromMark, offset, sizeof(chunk), &chunk, &actual);
275 if (result) return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSReadFork")*/ 276 if (result) return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSReadFork")*/
276 277
278 chunk.ckID = SDL_SwapBE32(chunk.ckID);
279 chunk.ckSize = SDL_SwapBE32(chunk.ckSize);
280
277 /* Skip the chunk data */ 281 /* Skip the chunk data */
278 offset = chunk.ckSize; 282 offset = chunk.ckSize;
279 } while (chunk.ckID != 'SSND'); 283 } while (chunk.ckID != 'SSND');
280 284
281 /* Read the header of the SSND chunk. After this, we are positioned right 285 /* Read the header of the SSND chunk. After this, we are positioned right
282 at the start of the audio data. */ 286 at the start of the audio data. */
283 result = FSReadFork(afp->mForkRefNum, fsAtMark, 0, sizeof(ssndData), &ssndData, &actual); 287 result = FSReadFork(afp->mForkRefNum, fsAtMark, 0, sizeof(ssndData), &ssndData, &actual);
284 if (result) return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSReadFork")*/ 288 if (result) return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSReadFork")*/
289
290 ssndData.offset = SDL_SwapBE32(ssndData.offset);
285 291
286 result = FSSetForkPosition(afp->mForkRefNum, fsFromMark, ssndData.offset); 292 result = FSSetForkPosition(afp->mForkRefNum, fsFromMark, ssndData.offset);
287 if (result) return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSSetForkPosition")*/ 293 if (result) return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSSetForkPosition")*/
288 294
289 /* Data size */ 295 /* Data size */
290 *outFileDataSize = chunk.ckSize - ssndData.offset - 8; 296 *outFileDataSize = chunk.ckSize - ssndData.offset - 8;
291 297
292 /* File format */ 298 /* File format */