Skip to main content

Module ping_pong_buffer

Module ping_pong_buffer 

Source
Expand description

Ping-pong (double) buffer: one buffer fills with incoming samples while the other, already full, is processed, so a producer and a consumer never touch the same memory.

The producer pushes samples; when the active buffer holds block_len samples the roles swap and that block becomes available to the consumer. If the producer fills a second block before the consumer has released the first, the new block cannot be stored: the push reports an overrun and the samples are dropped (and counted) rather than corrupting the block being read.

See the book entry DSP: synchronisation, communications, radar and controls.

Structsยง

PingPongBuffer
A double buffer of two block_len-sample blocks.
PushOutcome
The outcome of pushing samples.