| 162 | } |
| 163 | |
| 164 | size_t RingBuffer::Clear(sampleFormat format, size_t samplesToClear) |
| 165 | { |
| 166 | auto start = mStart.load( std::memory_order_acquire ); |
| 167 | auto end = mWritten; |
| 168 | samplesToClear = std::min( samplesToClear, Free( start, end ) ); |
| 169 | size_t cleared = 0; |
| 170 | auto pos = end; |
| 171 | |
| 172 | while(samplesToClear) { |
| 173 | auto block = std::min( samplesToClear, mBufferSize - pos ); |
| 174 | |
| 175 | ClearSamples(mBuffer.ptr(), format, pos, block); |
| 176 | |
| 177 | pos = (pos + block) % mBufferSize; |
| 178 | samplesToClear -= block; |
| 179 | cleared += block; |
| 180 | } |
| 181 | |
| 182 | mWritten = pos; |
| 183 | |
| 184 | return cleared; |
| 185 | } |
| 186 | |
| 187 | std::pair<samplePtr, size_t> RingBuffer::GetUnflushed(unsigned iBlock) |
| 188 | { |
no test coverage detected