32 : mBufferSize{
std::max<size_t>(
size, 64) }
34 , mBuffer{ mBufferSize, mFormat }
65 auto start =
mStart.load( std::memory_order_relaxed );
73 size_t samplesToCopy,
size_t padding)
75 auto start =
mStart.load( std::memory_order_acquire );
77 const auto free =
Free( start,
end );
78 samplesToCopy =
std::min( samplesToCopy, free );
79 padding =
std::min( padding, free - samplesToCopy );
84 while ( samplesToCopy ) {
93 samplesToCopy -= block;
112 auto start =
mStart.load( std::memory_order_acquire );
118 while(samplesToClear) {
124 samplesToClear -= block;
138 auto end =
mEnd.load(std::memory_order_relaxed);
144 const size_t size1 =
size - size0;
173 auto end =
mEnd.load( std::memory_order_relaxed );
174 auto start =
mStart.load( std::memory_order_relaxed );
182 size_t samplesToCopy)
186 auto end =
mEnd.load( std::memory_order_acquire );
187 auto start =
mStart.load( std::memory_order_relaxed );
192 while(samplesToCopy) {
201 samplesToCopy -= block;
207 mStart.store( start, std::memory_order_release );
214 auto end =
mEnd.load( std::memory_order_relaxed );
215 auto start =
mStart.load( std::memory_order_relaxed );
220 std::memory_order_relaxed);
222 return samplesToDiscard;
size_t Put(constSamplePtr buffer, sampleFormat format, size_t samples, size_t padding=0)
Does not apply dithering.
std::pair< samplePtr, size_t > GetUnflushed(unsigned iBlock)
Get access to written but unflushed data, which is in at most two blocks.
NonInterfering< std::atomic< size_t > > mEnd
size_t Filled(size_t start, size_t end)
size_t Free(size_t start, size_t end)
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)
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.