| 420 | } |
| 421 | |
| 422 | void FilePlayerNode::readImpl() |
| 423 | { |
| 424 | size_t readPos = mReadPos; |
| 425 | size_t availableWrite = mRingBuffers[0].getAvailableWrite(); |
| 426 | size_t readEnd = mLoop ? mLoopEnd.load() : mNumFrames; |
| 427 | size_t numFramesToRead = readEnd < readPos ? 0 : min( availableWrite, readEnd - readPos ); |
| 428 | |
| 429 | if( ! numFramesToRead ) { |
| 430 | mLastOverrun = getContext()->getNumProcessedFrames(); |
| 431 | return; |
| 432 | } |
| 433 | |
| 434 | // safety check that the SourceFile is on the correct read position, which could happen if two users are simultaneously reading from the same file. |
| 435 | if( readPos != mSourceFile->getReadPosition() ) |
| 436 | mSourceFile->seek( readPos ); |
| 437 | |
| 438 | mIoBuffer.setNumFrames( numFramesToRead ); |
| 439 | |
| 440 | size_t numRead = mSourceFile->read( &mIoBuffer ); |
| 441 | mReadPos += numRead; |
| 442 | |
| 443 | for( size_t ch = 0; ch < getNumChannels(); ch++ ) { |
| 444 | if( ! mRingBuffers[ch].write( mIoBuffer.getChannel( ch ), numRead ) ) { |
| 445 | mLastOverrun = getContext()->getNumProcessedFrames(); |
| 446 | return; |
| 447 | } |
| 448 | } |
| 449 | } |
| 450 | |
| 451 | void FilePlayerNode::seekImpl( size_t readPos ) |
| 452 | { |
nothing calls this directly
no test coverage detected