PipeWire 0.3.77
Loading...
Searching...
No Matches
Ringbuffer

Ring buffer implementation. More...

Files

file  ringbuffer.h
 spa/utils/ringbuffer.h
 

Data Structures

struct  spa_ringbuffer
 A ringbuffer type. More...
 

Macros

#define SPA_RINGBUFFER_INIT()   ((struct spa_ringbuffer) { 0, 0 })
 

Functions

static void spa_ringbuffer_init (struct spa_ringbuffer *rbuf)
 Initialize a spa_ringbuffer with size. More...
 
static void spa_ringbuffer_set_avail (struct spa_ringbuffer *rbuf, uint32_t size)
 Sets the pointers so that the ringbuffer contains size bytes. More...
 
static int32_t spa_ringbuffer_get_read_index (struct spa_ringbuffer *rbuf, uint32_t *index)
 Get the read index and available bytes for reading. More...
 
static void spa_ringbuffer_read_data (struct spa_ringbuffer *rbuf 1, const void *buffer, uint32_t size, uint32_t offset, void *data, uint32_t len)
 Read len bytes from rbuf starting offset. More...
 
static void spa_ringbuffer_read_update (struct spa_ringbuffer *rbuf, int32_t index)
 Update the read pointer to index. More...
 
static int32_t spa_ringbuffer_get_write_index (struct spa_ringbuffer *rbuf, uint32_t *index)
 Get the write index and the number of bytes inside the ringbuffer. More...
 
static void spa_ringbuffer_write_data (struct spa_ringbuffer *rbuf 1, void *buffer, uint32_t size, uint32_t offset, const void *data, uint32_t len)
 Write len bytes to buffer starting offset. More...
 
static void spa_ringbuffer_write_update (struct spa_ringbuffer *rbuf, int32_t index)
 Update the write pointer to index. More...
 

Detailed Description

Ring buffer implementation.

Macro Definition Documentation

◆ SPA_RINGBUFFER_INIT

#define SPA_RINGBUFFER_INIT ( )    ((struct spa_ringbuffer) { 0, 0 })

Function Documentation

◆ spa_ringbuffer_init()

static void spa_ringbuffer_init ( struct spa_ringbuffer rbuf)
inlinestatic

Initialize a spa_ringbuffer with size.

Parameters
rbufa spa_ringbuffer

◆ spa_ringbuffer_set_avail()

static void spa_ringbuffer_set_avail ( struct spa_ringbuffer rbuf,
uint32_t  size 
)
inlinestatic

Sets the pointers so that the ringbuffer contains size bytes.

Parameters
rbufa spa_ringbuffer
sizethe target size of rbuf

◆ spa_ringbuffer_get_read_index()

static int32_t spa_ringbuffer_get_read_index ( struct spa_ringbuffer rbuf,
uint32_t *  index 
)
inlinestatic

Get the read index and available bytes for reading.

Parameters
rbufa spa_ringbuffer
indexthe value of readindex, should be taken modulo the size of the ringbuffer memory to get the offset in the ringbuffer memory
Returns
number of available bytes to read. values < 0 mean there was an underrun. values > rbuf->size means there was an overrun.

◆ spa_ringbuffer_read_data()

static void spa_ringbuffer_read_data ( struct spa_ringbuffer *rbuf  1,
const void *  buffer,
uint32_t  size,
uint32_t  offset,
void *  data,
uint32_t  len 
)
inlinestatic

Read len bytes from rbuf starting offset.

offset must be taken modulo size and len should be smaller than size.

Parameters
rbufa struct Ringbuffer
buffermemory to read from
sizethe size of buffer
offsetoffset in buffer to read from
datadestination memory
lennumber of bytes to read

◆ spa_ringbuffer_read_update()

static void spa_ringbuffer_read_update ( struct spa_ringbuffer rbuf,
int32_t  index 
)
inlinestatic

Update the read pointer to index.

Parameters
rbufa spa_ringbuffer
indexnew index

◆ spa_ringbuffer_get_write_index()

static int32_t spa_ringbuffer_get_write_index ( struct spa_ringbuffer rbuf,
uint32_t *  index 
)
inlinestatic

Get the write index and the number of bytes inside the ringbuffer.

Parameters
rbufa spa_ringbuffer
indexthe value of writeindex, should be taken modulo the size of the ringbuffer memory to get the offset in the ringbuffer memory
Returns
the fill level of rbuf. values < 0 mean there was an underrun. values > rbuf->size means there was an overrun. Subtract from the buffer size to get the number of bytes available for writing.

◆ spa_ringbuffer_write_data()

static void spa_ringbuffer_write_data ( struct spa_ringbuffer *rbuf  1,
void *  buffer,
uint32_t  size,
uint32_t  offset,
const void *  data,
uint32_t  len 
)
inlinestatic

Write len bytes to buffer starting offset.

offset must be taken modulo size and len should be smaller than size.

Parameters
rbufa spa_ringbuffer
buffermemory to write to
sizethe size of buffer
offsetoffset in buffer to write to
datasource memory
lennumber of bytes to write

◆ spa_ringbuffer_write_update()

static void spa_ringbuffer_write_update ( struct spa_ringbuffer rbuf,
int32_t  index 
)
inlinestatic

Update the write pointer to index.

Parameters
rbufa spa_ringbuffer
indexnew index