| 180 | } |
| 181 | |
| 182 | void BufferPlayerNode::process( Buffer *buffer ) |
| 183 | { |
| 184 | const auto &frameRange = getProcessFramesRange(); |
| 185 | |
| 186 | size_t readPos = mReadPos; |
| 187 | size_t numFrames = frameRange.second - frameRange.first; |
| 188 | size_t readEnd = mLoop ? mLoopEnd.load() : mNumFrames; |
| 189 | |
| 190 | size_t readCount = 0; |
| 191 | if( readPos <= readEnd ) { |
| 192 | readCount = min( readEnd - readPos, numFrames ); |
| 193 | buffer->copyOffset( *mBuffer, readCount, frameRange.first, readPos ); |
| 194 | } |
| 195 | |
| 196 | if( readCount < numFrames ) { |
| 197 | // End of File. If looping copy from beginning, otherwise disable and mark mIsEof. |
| 198 | if( mLoop ) { |
| 199 | size_t readBegin = mLoopBegin; |
| 200 | size_t readLeft = min( numFrames - readCount, mNumFrames - readBegin ); |
| 201 | |
| 202 | buffer->copyOffset( *mBuffer, readLeft, readCount, readBegin ); |
| 203 | mReadPos.store( readBegin + readLeft ); |
| 204 | } |
| 205 | else { |
| 206 | mIsEof = true; |
| 207 | mReadPos = mNumFrames; |
| 208 | disable(); |
| 209 | } |
| 210 | } |
| 211 | else |
| 212 | mReadPos += readCount; |
| 213 | } |
| 214 | |
| 215 | // ---------------------------------------------------------------------------------------------------- |
| 216 | // FilePlayerNode |
nothing calls this directly
no test coverage detected