Mercurial > sdl-ios-xcode
comparison src/cdrom/macosx/AudioFilePlayer.c @ 1668:4da1ee79c9af SDL-1.3
more tweaking indent options
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 29 May 2006 04:04:35 +0000 |
parents | 782fd950bd46 |
children |
comparison
equal
deleted
inserted
replaced
1667:1fddae038bc8 | 1668:4da1ee79c9af |
---|---|
37 } | 37 } |
38 */ | 38 */ |
39 | 39 |
40 #if DEBUG | 40 #if DEBUG |
41 static void | 41 static void |
42 PrintStreamDesc (AudioStreamBasicDescription * inDesc) | 42 PrintStreamDesc(AudioStreamBasicDescription * inDesc) |
43 { | 43 { |
44 if (!inDesc) { | 44 if (!inDesc) { |
45 printf ("Can't print a NULL desc!\n"); | 45 printf("Can't print a NULL desc!\n"); |
46 return; | 46 return; |
47 } | 47 } |
48 | 48 |
49 printf ("- - - - - - - - - - - - - - - - - - - -\n"); | 49 printf("- - - - - - - - - - - - - - - - - - - -\n"); |
50 printf (" Sample Rate:%f\n", inDesc->mSampleRate); | 50 printf(" Sample Rate:%f\n", inDesc->mSampleRate); |
51 printf (" Format ID:%s\n", (char *) &inDesc->mFormatID); | 51 printf(" Format ID:%s\n", (char *) &inDesc->mFormatID); |
52 printf (" Format Flags:%lX\n", inDesc->mFormatFlags); | 52 printf(" Format Flags:%lX\n", inDesc->mFormatFlags); |
53 printf (" Bytes per Packet:%ld\n", inDesc->mBytesPerPacket); | 53 printf(" Bytes per Packet:%ld\n", inDesc->mBytesPerPacket); |
54 printf (" Frames per Packet:%ld\n", inDesc->mFramesPerPacket); | 54 printf(" Frames per Packet:%ld\n", inDesc->mFramesPerPacket); |
55 printf (" Bytes per Frame:%ld\n", inDesc->mBytesPerFrame); | 55 printf(" Bytes per Frame:%ld\n", inDesc->mBytesPerFrame); |
56 printf (" Channels per Frame:%ld\n", inDesc->mChannelsPerFrame); | 56 printf(" Channels per Frame:%ld\n", inDesc->mChannelsPerFrame); |
57 printf (" Bits per Channel:%ld\n", inDesc->mBitsPerChannel); | 57 printf(" Bits per Channel:%ld\n", inDesc->mBitsPerChannel); |
58 printf ("- - - - - - - - - - - - - - - - - - - -\n"); | 58 printf("- - - - - - - - - - - - - - - - - - - -\n"); |
59 } | 59 } |
60 #endif | 60 #endif |
61 | 61 |
62 | 62 |
63 static int | 63 static int |
64 AudioFilePlayer_SetDestination (AudioFilePlayer * afp, AudioUnit * inDestUnit) | 64 AudioFilePlayer_SetDestination(AudioFilePlayer * afp, AudioUnit * inDestUnit) |
65 { | 65 { |
66 /*if (afp->mConnected) throw static_cast<OSStatus>(-1); *//* can't set dest if already engaged */ | 66 /*if (afp->mConnected) throw static_cast<OSStatus>(-1); *//* can't set dest if already engaged */ |
67 if (afp->mConnected) | 67 if (afp->mConnected) |
68 return 0; | 68 return 0; |
69 | 69 |
70 SDL_memcpy (&afp->mPlayUnit, inDestUnit, sizeof (afp->mPlayUnit)); | 70 SDL_memcpy(&afp->mPlayUnit, inDestUnit, sizeof(afp->mPlayUnit)); |
71 | 71 |
72 OSStatus result = noErr; | 72 OSStatus result = noErr; |
73 | 73 |
74 | 74 |
75 /* we can "down" cast a component instance to a component */ | 75 /* we can "down" cast a component instance to a component */ |
76 ComponentDescription desc; | 76 ComponentDescription desc; |
77 result = GetComponentInfo ((Component) * inDestUnit, &desc, 0, 0, 0); | 77 result = GetComponentInfo((Component) * inDestUnit, &desc, 0, 0, 0); |
78 if (result) | 78 if (result) |
79 return 0; /*THROW_RESULT("GetComponentInfo") */ | 79 return 0; /*THROW_RESULT("GetComponentInfo") */ |
80 | 80 |
81 /* we're going to use this to know which convert routine to call | 81 /* we're going to use this to know which convert routine to call |
82 a v1 audio unit will have a type of 'aunt' | 82 a v1 audio unit will have a type of 'aunt' |
87 if (result) | 87 if (result) |
88 return 0; | 88 return 0; |
89 } | 89 } |
90 | 90 |
91 /* Set the input format of the audio unit. */ | 91 /* Set the input format of the audio unit. */ |
92 result = AudioUnitSetProperty (*inDestUnit, | 92 result = AudioUnitSetProperty(*inDestUnit, |
93 kAudioUnitProperty_StreamFormat, | 93 kAudioUnitProperty_StreamFormat, |
94 kAudioUnitScope_Input, | 94 kAudioUnitScope_Input, |
95 0, | 95 0, |
96 &afp->mFileDescription, | 96 &afp->mFileDescription, |
97 sizeof (afp->mFileDescription)); | 97 sizeof(afp->mFileDescription)); |
98 /*THROW_RESULT("AudioUnitSetProperty") */ | 98 /*THROW_RESULT("AudioUnitSetProperty") */ |
99 if (result) | 99 if (result) |
100 return 0; | 100 return 0; |
101 return 1; | 101 return 1; |
102 } | 102 } |
103 | 103 |
104 static void | 104 static void |
105 AudioFilePlayer_SetNotifier (AudioFilePlayer * afp, | 105 AudioFilePlayer_SetNotifier(AudioFilePlayer * afp, |
106 AudioFilePlayNotifier inNotifier, void *inRefCon) | 106 AudioFilePlayNotifier inNotifier, void *inRefCon) |
107 { | 107 { |
108 afp->mNotifier = inNotifier; | 108 afp->mNotifier = inNotifier; |
109 afp->mRefCon = inRefCon; | 109 afp->mRefCon = inRefCon; |
110 } | 110 } |
111 | 111 |
112 static int | 112 static int |
113 AudioFilePlayer_IsConnected (AudioFilePlayer * afp) | 113 AudioFilePlayer_IsConnected(AudioFilePlayer * afp) |
114 { | 114 { |
115 return afp->mConnected; | 115 return afp->mConnected; |
116 } | 116 } |
117 | 117 |
118 static AudioUnit | 118 static AudioUnit |
119 AudioFilePlayer_GetDestUnit (AudioFilePlayer * afp) | 119 AudioFilePlayer_GetDestUnit(AudioFilePlayer * afp) |
120 { | 120 { |
121 return afp->mPlayUnit; | 121 return afp->mPlayUnit; |
122 } | 122 } |
123 | 123 |
124 static void | 124 static void |
125 AudioFilePlayer_Print (AudioFilePlayer * afp) | 125 AudioFilePlayer_Print(AudioFilePlayer * afp) |
126 { | 126 { |
127 #if DEBUG | 127 #if DEBUG |
128 printf ("Is Connected:%s\n", (IsConnected ()? "true" : "false")); | 128 printf("Is Connected:%s\n", (IsConnected()? "true" : "false")); |
129 printf ("- - - - - - - - - - - - - - \n"); | 129 printf("- - - - - - - - - - - - - - \n"); |
130 #endif | 130 #endif |
131 } | 131 } |
132 | 132 |
133 static void | 133 static void |
134 AudioFilePlayer_SetStartFrame (AudioFilePlayer * afp, int frame) | 134 AudioFilePlayer_SetStartFrame(AudioFilePlayer * afp, int frame) |
135 { | 135 { |
136 SInt64 position = frame * 2352; | 136 SInt64 position = frame * 2352; |
137 | 137 |
138 afp->mStartFrame = frame; | 138 afp->mStartFrame = frame; |
139 afp->mAudioFileManager->SetPosition (afp->mAudioFileManager, position); | 139 afp->mAudioFileManager->SetPosition(afp->mAudioFileManager, position); |
140 } | 140 } |
141 | 141 |
142 | 142 |
143 static int | 143 static int |
144 AudioFilePlayer_GetCurrentFrame (AudioFilePlayer * afp) | 144 AudioFilePlayer_GetCurrentFrame(AudioFilePlayer * afp) |
145 { | 145 { |
146 return afp->mStartFrame + | 146 return afp->mStartFrame + |
147 (afp->mAudioFileManager->GetByteCounter (afp->mAudioFileManager) / | 147 (afp->mAudioFileManager->GetByteCounter(afp->mAudioFileManager) / |
148 2352); | 148 2352); |
149 } | 149 } |
150 | 150 |
151 static void | 151 static void |
152 AudioFilePlayer_SetStopFrame (AudioFilePlayer * afp, int frame) | 152 AudioFilePlayer_SetStopFrame(AudioFilePlayer * afp, int frame) |
153 { | 153 { |
154 SInt64 position = frame * 2352; | 154 SInt64 position = frame * 2352; |
155 | 155 |
156 afp->mAudioFileManager->SetEndOfFile (afp->mAudioFileManager, position); | 156 afp->mAudioFileManager->SetEndOfFile(afp->mAudioFileManager, position); |
157 } | 157 } |
158 | 158 |
159 void | 159 void |
160 delete_AudioFilePlayer (AudioFilePlayer * afp) | 160 delete_AudioFilePlayer(AudioFilePlayer * afp) |
161 { | 161 { |
162 if (afp != NULL) { | 162 if (afp != NULL) { |
163 afp->Disconnect (afp); | 163 afp->Disconnect(afp); |
164 | 164 |
165 if (afp->mAudioFileManager) { | 165 if (afp->mAudioFileManager) { |
166 delete_AudioFileManager (afp->mAudioFileManager); | 166 delete_AudioFileManager(afp->mAudioFileManager); |
167 afp->mAudioFileManager = 0; | 167 afp->mAudioFileManager = 0; |
168 } | 168 } |
169 | 169 |
170 if (afp->mForkRefNum) { | 170 if (afp->mForkRefNum) { |
171 FSCloseFork (afp->mForkRefNum); | 171 FSCloseFork(afp->mForkRefNum); |
172 afp->mForkRefNum = 0; | 172 afp->mForkRefNum = 0; |
173 } | 173 } |
174 SDL_free (afp); | 174 SDL_free(afp); |
175 } | 175 } |
176 } | 176 } |
177 | 177 |
178 static int | 178 static int |
179 AudioFilePlayer_Connect (AudioFilePlayer * afp) | 179 AudioFilePlayer_Connect(AudioFilePlayer * afp) |
180 { | 180 { |
181 #if DEBUG | 181 #if DEBUG |
182 printf ("Connect:%x, engaged=%d\n", (int) afp->mPlayUnit, | 182 printf("Connect:%x, engaged=%d\n", (int) afp->mPlayUnit, |
183 (afp->mConnected ? 1 : 0)); | 183 (afp->mConnected ? 1 : 0)); |
184 #endif | 184 #endif |
185 if (!afp->mConnected) { | 185 if (!afp->mConnected) { |
186 if (!afp->mAudioFileManager->DoConnect (afp->mAudioFileManager)) | 186 if (!afp->mAudioFileManager->DoConnect(afp->mAudioFileManager)) |
187 return 0; | 187 return 0; |
188 | 188 |
189 /* set the render callback for the file data to be supplied to the sound converter AU */ | 189 /* set the render callback for the file data to be supplied to the sound converter AU */ |
190 afp->mInputCallback.inputProc = afp->mAudioFileManager->FileInputProc; | 190 afp->mInputCallback.inputProc = afp->mAudioFileManager->FileInputProc; |
191 afp->mInputCallback.inputProcRefCon = afp->mAudioFileManager; | 191 afp->mInputCallback.inputProcRefCon = afp->mAudioFileManager; |
192 | 192 |
193 OSStatus result = AudioUnitSetProperty (afp->mPlayUnit, | 193 OSStatus result = AudioUnitSetProperty(afp->mPlayUnit, |
194 kAudioUnitProperty_SetInputCallback, | 194 kAudioUnitProperty_SetInputCallback, |
195 kAudioUnitScope_Input, | 195 kAudioUnitScope_Input, |
196 0, | 196 0, |
197 &afp->mInputCallback, | 197 &afp->mInputCallback, |
198 sizeof (afp->mInputCallback)); | 198 sizeof(afp->mInputCallback)); |
199 if (result) | 199 if (result) |
200 return 0; /*THROW_RESULT("AudioUnitSetProperty") */ | 200 return 0; /*THROW_RESULT("AudioUnitSetProperty") */ |
201 afp->mConnected = 1; | 201 afp->mConnected = 1; |
202 } | 202 } |
203 | 203 |
205 } | 205 } |
206 | 206 |
207 /* warning noted, now please go away ;-) */ | 207 /* warning noted, now please go away ;-) */ |
208 /* #warning This should redirect the calling of notification code to some other thread */ | 208 /* #warning This should redirect the calling of notification code to some other thread */ |
209 static void | 209 static void |
210 AudioFilePlayer_DoNotification (AudioFilePlayer * afp, OSStatus inStatus) | 210 AudioFilePlayer_DoNotification(AudioFilePlayer * afp, OSStatus inStatus) |
211 { | 211 { |
212 if (afp->mNotifier) { | 212 if (afp->mNotifier) { |
213 (*afp->mNotifier) (afp->mRefCon, inStatus); | 213 (*afp->mNotifier) (afp->mRefCon, inStatus); |
214 } else { | 214 } else { |
215 SDL_SetError ("Notification posted with no notifier in place"); | 215 SDL_SetError("Notification posted with no notifier in place"); |
216 | 216 |
217 if (inStatus == kAudioFilePlay_FileIsFinished) | 217 if (inStatus == kAudioFilePlay_FileIsFinished) |
218 afp->Disconnect (afp); | 218 afp->Disconnect(afp); |
219 else if (inStatus != kAudioFilePlayErr_FilePlayUnderrun) | 219 else if (inStatus != kAudioFilePlayErr_FilePlayUnderrun) |
220 afp->Disconnect (afp); | 220 afp->Disconnect(afp); |
221 } | 221 } |
222 } | 222 } |
223 | 223 |
224 static void | 224 static void |
225 AudioFilePlayer_Disconnect (AudioFilePlayer * afp) | 225 AudioFilePlayer_Disconnect(AudioFilePlayer * afp) |
226 { | 226 { |
227 #if DEBUG | 227 #if DEBUG |
228 printf ("Disconnect:%x,%ld, engaged=%d\n", (int) afp->mPlayUnit, 0, | 228 printf("Disconnect:%x,%ld, engaged=%d\n", (int) afp->mPlayUnit, 0, |
229 (afp->mConnected ? 1 : 0)); | 229 (afp->mConnected ? 1 : 0)); |
230 #endif | 230 #endif |
231 if (afp->mConnected) { | 231 if (afp->mConnected) { |
232 afp->mConnected = 0; | 232 afp->mConnected = 0; |
233 | 233 |
234 afp->mInputCallback.inputProc = 0; | 234 afp->mInputCallback.inputProc = 0; |
235 afp->mInputCallback.inputProcRefCon = 0; | 235 afp->mInputCallback.inputProcRefCon = 0; |
236 OSStatus result = AudioUnitSetProperty (afp->mPlayUnit, | 236 OSStatus result = AudioUnitSetProperty(afp->mPlayUnit, |
237 kAudioUnitProperty_SetInputCallback, | 237 kAudioUnitProperty_SetInputCallback, |
238 kAudioUnitScope_Input, | 238 kAudioUnitScope_Input, |
239 0, | 239 0, |
240 &afp->mInputCallback, | 240 &afp->mInputCallback, |
241 sizeof (afp->mInputCallback)); | 241 sizeof(afp->mInputCallback)); |
242 if (result) | 242 if (result) |
243 SDL_SetError ("AudioUnitSetProperty:RemoveInputCallback:%ld", | 243 SDL_SetError("AudioUnitSetProperty:RemoveInputCallback:%ld", |
244 result); | 244 result); |
245 | 245 |
246 afp->mAudioFileManager->Disconnect (afp->mAudioFileManager); | 246 afp->mAudioFileManager->Disconnect(afp->mAudioFileManager); |
247 } | 247 } |
248 } | 248 } |
249 | 249 |
250 typedef struct | 250 typedef struct |
251 { | 251 { |
252 UInt32 offset; | 252 UInt32 offset; |
253 UInt32 blockSize; | 253 UInt32 blockSize; |
254 } SSNDData; | 254 } SSNDData; |
255 | 255 |
256 static int | 256 static int |
257 AudioFilePlayer_OpenFile (AudioFilePlayer * afp, const FSRef * inRef, | 257 AudioFilePlayer_OpenFile(AudioFilePlayer * afp, const FSRef * inRef, |
258 SInt64 * outFileDataSize) | 258 SInt64 * outFileDataSize) |
259 { | 259 { |
260 ContainerChunk chunkHeader; | 260 ContainerChunk chunkHeader; |
261 ChunkHeader chunk; | 261 ChunkHeader chunk; |
262 SSNDData ssndData; | 262 SSNDData ssndData; |
263 | 263 |
265 HFSUniStr255 dfName; | 265 HFSUniStr255 dfName; |
266 ByteCount actual; | 266 ByteCount actual; |
267 SInt64 offset; | 267 SInt64 offset; |
268 | 268 |
269 /* Open the data fork of the input file */ | 269 /* Open the data fork of the input file */ |
270 result = FSGetDataForkName (&dfName); | 270 result = FSGetDataForkName(&dfName); |
271 if (result) | 271 if (result) |
272 return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSGetDataForkName") */ | 272 return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSGetDataForkName") */ |
273 | 273 |
274 result = | 274 result = |
275 FSOpenFork (inRef, dfName.length, dfName.unicode, fsRdPerm, | 275 FSOpenFork(inRef, dfName.length, dfName.unicode, fsRdPerm, |
276 &afp->mForkRefNum); | 276 &afp->mForkRefNum); |
277 if (result) | 277 if (result) |
278 return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSOpenFork") */ | 278 return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSOpenFork") */ |
279 | 279 |
280 /* Read the file header, and check if it's indeed an AIFC file */ | 280 /* Read the file header, and check if it's indeed an AIFC file */ |
281 result = | 281 result = |
282 FSReadFork (afp->mForkRefNum, fsAtMark, 0, sizeof (chunkHeader), | 282 FSReadFork(afp->mForkRefNum, fsAtMark, 0, sizeof(chunkHeader), |
283 &chunkHeader, &actual); | 283 &chunkHeader, &actual); |
284 if (result) | 284 if (result) |
285 return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSReadFork") */ | 285 return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSReadFork") */ |
286 | 286 |
287 if (chunkHeader.ckID != 'FORM') { | 287 if (chunkHeader.ckID != 'FORM') { |
288 result = -1; | 288 result = -1; |
302 TODO: Parse the COMM chunk we currently skip to fill in mFileDescription. | 302 TODO: Parse the COMM chunk we currently skip to fill in mFileDescription. |
303 */ | 303 */ |
304 offset = 0; | 304 offset = 0; |
305 do { | 305 do { |
306 result = | 306 result = |
307 FSReadFork (afp->mForkRefNum, fsFromMark, offset, | 307 FSReadFork(afp->mForkRefNum, fsFromMark, offset, |
308 sizeof (chunk), &chunk, &actual); | 308 sizeof(chunk), &chunk, &actual); |
309 if (result) | 309 if (result) |
310 return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSReadFork") */ | 310 return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSReadFork") */ |
311 | 311 |
312 /* Skip the chunk data */ | 312 /* Skip the chunk data */ |
313 offset = chunk.ckSize; | 313 offset = chunk.ckSize; |
315 while (chunk.ckID != 'SSND'); | 315 while (chunk.ckID != 'SSND'); |
316 | 316 |
317 /* Read the header of the SSND chunk. After this, we are positioned right | 317 /* Read the header of the SSND chunk. After this, we are positioned right |
318 at the start of the audio data. */ | 318 at the start of the audio data. */ |
319 result = | 319 result = |
320 FSReadFork (afp->mForkRefNum, fsAtMark, 0, sizeof (ssndData), | 320 FSReadFork(afp->mForkRefNum, fsAtMark, 0, sizeof(ssndData), |
321 &ssndData, &actual); | 321 &ssndData, &actual); |
322 if (result) | 322 if (result) |
323 return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSReadFork") */ | 323 return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSReadFork") */ |
324 | 324 |
325 result = | 325 result = FSSetForkPosition(afp->mForkRefNum, fsFromMark, ssndData.offset); |
326 FSSetForkPosition (afp->mForkRefNum, fsFromMark, ssndData.offset); | |
327 if (result) | 326 if (result) |
328 return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSSetForkPosition") */ | 327 return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSSetForkPosition") */ |
329 | 328 |
330 /* Data size */ | 329 /* Data size */ |
331 *outFileDataSize = chunk.ckSize - ssndData.offset - 8; | 330 *outFileDataSize = chunk.ckSize - ssndData.offset - 8; |
343 | 342 |
344 return 1; | 343 return 1; |
345 } | 344 } |
346 | 345 |
347 AudioFilePlayer * | 346 AudioFilePlayer * |
348 new_AudioFilePlayer (const FSRef * inFileRef) | 347 new_AudioFilePlayer(const FSRef * inFileRef) |
349 { | 348 { |
350 SInt64 fileDataSize = 0; | 349 SInt64 fileDataSize = 0; |
351 | 350 |
352 AudioFilePlayer *afp = | 351 AudioFilePlayer *afp = |
353 (AudioFilePlayer *) SDL_malloc (sizeof (AudioFilePlayer)); | 352 (AudioFilePlayer *) SDL_malloc(sizeof(AudioFilePlayer)); |
354 if (afp == NULL) | 353 if (afp == NULL) |
355 return NULL; | 354 return NULL; |
356 SDL_memset (afp, '\0', sizeof (*afp)); | 355 SDL_memset(afp, '\0', sizeof(*afp)); |
357 | 356 |
358 #define SET_AUDIOFILEPLAYER_METHOD(m) afp->m = AudioFilePlayer_##m | 357 #define SET_AUDIOFILEPLAYER_METHOD(m) afp->m = AudioFilePlayer_##m |
359 SET_AUDIOFILEPLAYER_METHOD (SetDestination); | 358 SET_AUDIOFILEPLAYER_METHOD(SetDestination); |
360 SET_AUDIOFILEPLAYER_METHOD (SetNotifier); | 359 SET_AUDIOFILEPLAYER_METHOD(SetNotifier); |
361 SET_AUDIOFILEPLAYER_METHOD (SetStartFrame); | 360 SET_AUDIOFILEPLAYER_METHOD(SetStartFrame); |
362 SET_AUDIOFILEPLAYER_METHOD (GetCurrentFrame); | 361 SET_AUDIOFILEPLAYER_METHOD(GetCurrentFrame); |
363 SET_AUDIOFILEPLAYER_METHOD (SetStopFrame); | 362 SET_AUDIOFILEPLAYER_METHOD(SetStopFrame); |
364 SET_AUDIOFILEPLAYER_METHOD (Connect); | 363 SET_AUDIOFILEPLAYER_METHOD(Connect); |
365 SET_AUDIOFILEPLAYER_METHOD (Disconnect); | 364 SET_AUDIOFILEPLAYER_METHOD(Disconnect); |
366 SET_AUDIOFILEPLAYER_METHOD (DoNotification); | 365 SET_AUDIOFILEPLAYER_METHOD(DoNotification); |
367 SET_AUDIOFILEPLAYER_METHOD (IsConnected); | 366 SET_AUDIOFILEPLAYER_METHOD(IsConnected); |
368 SET_AUDIOFILEPLAYER_METHOD (GetDestUnit); | 367 SET_AUDIOFILEPLAYER_METHOD(GetDestUnit); |
369 SET_AUDIOFILEPLAYER_METHOD (Print); | 368 SET_AUDIOFILEPLAYER_METHOD(Print); |
370 SET_AUDIOFILEPLAYER_METHOD (OpenFile); | 369 SET_AUDIOFILEPLAYER_METHOD(OpenFile); |
371 #undef SET_AUDIOFILEPLAYER_METHOD | 370 #undef SET_AUDIOFILEPLAYER_METHOD |
372 | 371 |
373 if (!afp->OpenFile (afp, inFileRef, &fileDataSize)) { | 372 if (!afp->OpenFile(afp, inFileRef, &fileDataSize)) { |
374 SDL_free (afp); | 373 SDL_free(afp); |
375 return NULL; | 374 return NULL; |
376 } | 375 } |
377 | 376 |
378 /* we want about 4 seconds worth of data for the buffer */ | 377 /* we want about 4 seconds worth of data for the buffer */ |
379 int bytesPerSecond = | 378 int bytesPerSecond = |
380 (UInt32) (4 * afp->mFileDescription.mSampleRate * | 379 (UInt32) (4 * afp->mFileDescription.mSampleRate * |
381 afp->mFileDescription.mBytesPerFrame); | 380 afp->mFileDescription.mBytesPerFrame); |
382 | 381 |
383 #if DEBUG | 382 #if DEBUG |
384 printf ("File format:\n"); | 383 printf("File format:\n"); |
385 PrintStreamDesc (&afp->mFileDescription); | 384 PrintStreamDesc(&afp->mFileDescription); |
386 #endif | 385 #endif |
387 | 386 |
388 afp->mAudioFileManager = new_AudioFileManager (afp, afp->mForkRefNum, | 387 afp->mAudioFileManager = new_AudioFileManager(afp, afp->mForkRefNum, |
389 fileDataSize, | 388 fileDataSize, |
390 bytesPerSecond); | 389 bytesPerSecond); |
391 if (afp->mAudioFileManager == NULL) { | 390 if (afp->mAudioFileManager == NULL) { |
392 delete_AudioFilePlayer (afp); | 391 delete_AudioFilePlayer(afp); |
393 return NULL; | 392 return NULL; |
394 } | 393 } |
395 | 394 |
396 return afp; | 395 return afp; |
397 } | 396 } |