The most recent samples of a multichannel signal, written by the execution thread and read by the GUI without lock or allocation on the writing side.
The writer never waits: it overwrites the oldest samples. It announces the end of the block it is about to write before writing it, and publishes it once written; the reader copies the span it wants and checks afterwards that no block announced meanwhile reached it, as in a seqlock. A copy the writer may have overwritten is reported as unavailable rather than returned torn.
Only what was written as one continuous stream is returned: the frames of a channel from before its buffer existed or from before the writer skipped it, and the frames from before a pause of the writer (see restart()), are reported as unavailable.
Channel buffers are allocated by the reader (provision()) when the writer reports more channels than are allocated; until then the writer skips the extra channels. Buffers are freed only with the ring.
|
|
| SampleRing (int capacity=1<< 16) |
| |
|
| SampleRing (const SampleRing &)=delete |
| |
|
SampleRing & | operator= (const SampleRing &)=delete |
| |
|
uint64_t | capacity () const noexcept |
| |
| template<typename F > |
| void | write (int channel_count, int frames, F &&channel) noexcept |
| |
|
void | restart () noexcept |
| | Writer: what was written so far is not continuous with what comes next.
|
| |
|
void | set_rate (double rate) noexcept |
| |
|
void | provision () |
| | Reader: allocates the buffers of the channels the writer reported.
|
| |
|
int | channels () const noexcept |
| |
|
double | rate () const noexcept |
| |
|
uint64_t | written () const noexcept |
| | Absolute index one past the last frame written so far.
|
| |
| bool | read (int c, uint64_t start, std::span< float > dst) const noexcept |
| |
| bool | read_latest (int c, std::span< float > dst, uint64_t &first) const noexcept |
| |