Mercurial > sdl-ios-xcode
comparison src/cdrom/macosx/AudioFileReaderThread.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 |
---|---|
243 } | 243 } |
244 | 244 |
245 static void FileReaderThread_ReadNextChunk (FileReaderThread *frt) | 245 static void FileReaderThread_ReadNextChunk (FileReaderThread *frt) |
246 { | 246 { |
247 OSStatus result; | 247 OSStatus result; |
248 UInt32 dataChunkSize; | 248 ByteCount dataChunkSize; |
249 AudioFileManager* theItem = 0; | 249 AudioFileManager* theItem = 0; |
250 | 250 |
251 for (;;) | 251 for (;;) |
252 { | 252 { |
253 { /* this is a scoped based lock */ | 253 { /* this is a scoped based lock */ |
378 afm->mFinishedReadingData = 0; | 378 afm->mFinishedReadingData = 0; |
379 | 379 |
380 afm->mNumTimesAskedSinceFinished = 0; | 380 afm->mNumTimesAskedSinceFinished = 0; |
381 afm->mLockUnsuccessful = 0; | 381 afm->mLockUnsuccessful = 0; |
382 | 382 |
383 UInt32 dataChunkSize; | 383 ByteCount dataChunkSize; |
384 | 384 |
385 if ((afm->mFileLength - afm->mReadFilePosition) < afm->mChunkSize) | 385 if ((afm->mFileLength - afm->mReadFilePosition) < afm->mChunkSize) |
386 dataChunkSize = afm->mFileLength - afm->mReadFilePosition; | 386 dataChunkSize = afm->mFileLength - afm->mReadFilePosition; |
387 else | 387 else |
388 dataChunkSize = afm->mChunkSize; | 388 dataChunkSize = afm->mChunkSize; |
413 sReaderThread->RemoveReader (sReaderThread, afm); | 413 sReaderThread->RemoveReader (sReaderThread, afm); |
414 afm->mIsEngaged = 0; | 414 afm->mIsEngaged = 0; |
415 } | 415 } |
416 } | 416 } |
417 | 417 |
418 static OSStatus AudioFileManager_Read(AudioFileManager *afm, char *buffer, UInt32 *len) | 418 static OSStatus AudioFileManager_Read(AudioFileManager *afm, char *buffer, ByteCount *len) |
419 { | 419 { |
420 return FSReadFork (afm->mForkRefNum, | 420 return FSReadFork (afm->mForkRefNum, |
421 fsFromStart, | 421 fsFromStart, |
422 afm->mReadFilePosition + afm->mAudioDataOffset, | 422 afm->mReadFilePosition + afm->mAudioDataOffset, |
423 *len, | 423 *len, |
506 static int AudioFileManager_GetByteCounter(AudioFileManager *afm) | 506 static int AudioFileManager_GetByteCounter(AudioFileManager *afm) |
507 { | 507 { |
508 return afm->mByteCounter; | 508 return afm->mByteCounter; |
509 } | 509 } |
510 | 510 |
511 | 511 static OSStatus AudioFileManager_FileInputProc (void *inRefCon, |
512 static OSStatus AudioFileManager_FileInputProc (void *inRefCon, | 512 AudioUnitRenderActionFlags *ioActionFlags, |
513 AudioUnitRenderActionFlags inActionFlags, | 513 const AudioTimeStamp *inTimeStamp, |
514 const AudioTimeStamp *inTimeStamp, | 514 UInt32 inBusNumber, |
515 UInt32 inBusNumber, | 515 UInt32 inNumberFrames, |
516 AudioBuffer *ioData) | 516 AudioBufferList *ioData) |
517 { | 517 { |
518 AudioFileManager* afm = (AudioFileManager*)inRefCon; | 518 AudioFileManager* afm = (AudioFileManager*)inRefCon; |
519 return afm->Render(afm, ioData); | 519 return afm->Render(afm, ioData); |
520 } | 520 } |
521 | 521 |
522 static OSStatus AudioFileManager_Render (AudioFileManager *afm, AudioBuffer *ioData) | 522 static OSStatus AudioFileManager_Render (AudioFileManager *afm, AudioBufferList *ioData) |
523 { | 523 { |
524 OSStatus result = noErr; | 524 OSStatus result = noErr; |
525 | 525 AudioBuffer *abuf; |
526 if (afm->mBufferOffset >= afm->mBufferSize) { | 526 UInt32 i; |
527 result = afm->GetFileData(afm, &afm->mTmpBuffer, &afm->mBufferSize); | 527 |
528 if (result) { | 528 for (i = 0; i < ioData->mNumberBuffers; i++) { |
529 SDL_SetError ("AudioConverterFillBuffer:%ld\n", result); | 529 abuf = &ioData->mBuffers[i]; |
530 afm->mParent->DoNotification(afm->mParent, result); | 530 if (afm->mBufferOffset >= afm->mBufferSize) { |
531 return result; | 531 result = afm->GetFileData(afm, &afm->mTmpBuffer, &afm->mBufferSize); |
532 } | 532 if (result) { |
533 | 533 SDL_SetError ("AudioConverterFillBuffer:%ld\n", result); |
534 afm->mBufferOffset = 0; | 534 afm->mParent->DoNotification(afm->mParent, result); |
535 } | 535 return result; |
536 | 536 } |
537 if (ioData->mDataByteSize > afm->mBufferSize - afm->mBufferOffset) | 537 |
538 ioData->mDataByteSize = afm->mBufferSize - afm->mBufferOffset; | 538 afm->mBufferOffset = 0; |
539 ioData->mData = (char *)afm->mTmpBuffer + afm->mBufferOffset; | 539 } |
540 afm->mBufferOffset += ioData->mDataByteSize; | 540 |
541 | 541 if (abuf->mDataByteSize > afm->mBufferSize - afm->mBufferOffset) |
542 afm->mByteCounter += ioData->mDataByteSize; | 542 abuf->mDataByteSize = afm->mBufferSize - afm->mBufferOffset; |
543 afm->AfterRender(afm); | 543 abuf->mData = (char *)afm->mTmpBuffer + afm->mBufferOffset; |
544 afm->mBufferOffset += abuf->mDataByteSize; | |
545 | |
546 afm->mByteCounter += abuf->mDataByteSize; | |
547 afm->AfterRender(afm); | |
548 } | |
544 return result; | 549 return result; |
545 } | 550 } |
546 | 551 |
547 | 552 |
548 void delete_AudioFileManager (AudioFileManager *afm) | 553 void delete_AudioFileManager (AudioFileManager *afm) |