33 : mBufferSize{
std::max<size_t>(
size, 64) }
35 , mBuffer{ mBufferSize, mFormat }
66 auto start =
mStart.load( std::memory_order_relaxed );
75 auto start =
mStart.load( std::memory_order_relaxed );
80 size_t samplesToCopy,
size_t padding)
83 auto start =
mStart.load( std::memory_order_acquire );
92 while ( samplesToCopy ) {
101 samplesToCopy -= block;
124 auto end =
mEnd.load(std::memory_order_relaxed);
126 const auto result =
size;
133 auto count = limit - source;
134 auto pDst = buffer +
end * sampleSize;
135 auto pSrc = buffer + source * sampleSize;
136 memmove(pDst, pSrc, count * sampleSize);
143 auto pDst = buffer +
end * sampleSize;
147 pSrc = buffer +
size * sampleSize;
150 auto toMove2 = toMove - toMove1;
151 memmove(pDst, pSrc, toMove1 * sampleSize);
152 memmove(buffer, pSrc + toMove1 * sampleSize, toMove2 * sampleSize);
166 auto start =
mStart.load( std::memory_order_acquire );
172 while(samplesToClear) {
178 samplesToClear -= block;
192 auto end =
mEnd.load(std::memory_order_relaxed);
198 const size_t size1 =
size - size0;
228 auto end =
mEnd.load( std::memory_order_relaxed );
229 auto start =
mStart.load( std::memory_order_relaxed );
237 size_t samplesToCopy)
241 auto end =
mEnd.load( std::memory_order_acquire );
242 auto start =
mStart.load( std::memory_order_relaxed );
247 while(samplesToCopy) {
256 samplesToCopy -= block;
262 mStart.store( start, std::memory_order_release );
269 auto end =
mEnd.load( std::memory_order_relaxed );
270 auto start =
mStart.load( std::memory_order_relaxed );
275 std::memory_order_relaxed);
277 return samplesToDiscard;
size_t WrittenForGet() const
Reader may concurrently cause a decrease of what this returns.
size_t AvailForPut() const
size_t Unput(size_t size)
Remove an initial segment of data that has been Put but not Flushed yet.
size_t Put(constSamplePtr buffer, sampleFormat format, size_t samples, size_t padding=0)
Does not apply dithering.
size_t Free(size_t start, size_t end) const
std::pair< samplePtr, size_t > GetUnflushed(unsigned iBlock)
NonInterfering< std::atomic< size_t > > mEnd
size_t Filled(size_t start, size_t end) const
void Flush()
Flush after a sequence of Put (and/or Clear) calls to let consumer see.
size_t Clear(sampleFormat format, size_t samples)
size_t Get(samplePtr buffer, sampleFormat format, size_t samples)
Does not apply dithering.
const sampleFormat mFormat
NonInterfering< std::atomic< size_t > > mStart
const SampleBuffer mBuffer
size_t Discard(size_t samples)
RingBuffer(sampleFormat format, size_t size)
size_t AvailForGet() const
const char * end(const char *str) noexcept