diff --git a/src/cdrom/macosx/AudioFilePlayer.cpp b/src/cdrom/macosx/AudioFilePlayer.cpp index 465823458..de1774087 100644 --- a/src/cdrom/macosx/AudioFilePlayer.cpp +++ b/src/cdrom/macosx/AudioFilePlayer.cpp @@ -352,7 +352,7 @@ void AudioFilePlayer::OpenFile (const FSRef *inRef, SInt64& outFileDataSize) THROW_RESULT("AudioFilePlayer::OpenFile(): FSSetForkPosition") // Data size - outFileDataSize = chunk.ckSize - ssndData.offset; + outFileDataSize = chunk.ckSize - ssndData.offset - 8; // File format mFileDescription.mSampleRate = 44100; diff --git a/src/cdrom/macosx/AudioFileReaderThread.cpp b/src/cdrom/macosx/AudioFileReaderThread.cpp index 48961acd8..a79ab9a8d 100644 --- a/src/cdrom/macosx/AudioFileReaderThread.cpp +++ b/src/cdrom/macosx/AudioFileReaderThread.cpp @@ -241,7 +241,7 @@ void FileReaderThread::ReadNextChunk () dataChunkSize = theItem->mChunkSize; // this is the exit condition for the thread - if (dataChunkSize == 0) { + if (dataChunkSize <= 0) { theItem->mFinishedReadingData = true; continue; } @@ -249,14 +249,9 @@ void FileReaderThread::ReadNextChunk () char* writePtr = const_cast(theItem->GetFileBuffer() + (theItem->mWriteToFirstBuffer ? 0 : theItem->mChunkSize)); -/* - printf ("AudioFileReadBytes: theItem=%.8X fileID=%.8X pos=%.8X sz=%.8X flen=%.8X ptr=%.8X\n", - (unsigned int)theItem, (unsigned int)theItem->GetFileID(), - (unsigned int)theItem->mReadFilePosition, (unsigned int)dataChunkSize, - (unsigned int)theItem->mFileLength, (unsigned int)writePtr); -*/ + // read data result = theItem->Read(writePtr, &dataChunkSize); - if (result) { + if (result != noErr && result != eofErr) { theItem->GetParent().DoNotification(result); continue; } @@ -271,7 +266,10 @@ void FileReaderThread::ReadNextChunk () theItem->mWriteToFirstBuffer = !theItem->mWriteToFirstBuffer; // switch buffers - theItem->mReadFilePosition += dataChunkSize; // increment count + if (result == eofErr) + theItem->mReadFilePosition = theItem->mFileLength; + else + theItem->mReadFilePosition += dataChunkSize; // increment count } }