MCPcopy Create free account
hub / github.com/cinder/Cinder / readImpl

Method readImpl

src/cinder/audio/SamplePlayerNode.cpp:422–449  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

420}
421
422void 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
451void FilePlayerNode::seekImpl( size_t readPos )
452{

Callers

nothing calls this directly

Calls 10

getContextFunction · 0.85
getAvailableWriteMethod · 0.80
getChannelMethod · 0.80
minFunction · 0.50
getNumChannelsFunction · 0.50
loadMethod · 0.45
seekMethod · 0.45
setNumFramesMethod · 0.45
readMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected