PipeWire 1.6.5

Loading...
Searching...
No Matches
Ringbuffer
SPA » Utilities

Ring buffer implementation. More...

## Files
file | ringbuffer.h
| spa/utils/ringbuffer.h

## Data Structures
struct | spa_ringbuffer
| A ringbuffer type. More...

## Macros
#define | SPA_API_RINGBUFFER static inline
#define | SPA_RINGBUFFER_INIT()

## Functions
SPA_API_RINGBUFFER void | spa_ringbuffer_init (struct spa_ringbuffer *rbuf)
| Initialize a spa_ringbuffer with size.
SPA_API_RINGBUFFER void | spa_ringbuffer_set_avail (struct spa_ringbuffer *rbuf, uint32_t size)
| Sets the pointers so that the ringbuffer contains size bytes.
SPA_API_RINGBUFFER int32_t | spa_ringbuffer_get_read_index (struct spa_ringbuffer *rbuf, uint32_t *index)
| Get the read index and available bytes for reading.
SPA_API_RINGBUFFER void | spa_ringbuffer_read_data (struct spa_ringbuffer *rbuf, const void *buffer, uint32_t size, uint32_t offset, void *data, uint32_t len)
| Read len bytes from rbuf starting offset.
SPA_API_RINGBUFFER void | spa_ringbuffer_read_update (struct spa_ringbuffer *rbuf, int32_t index)
| Update the read pointer to index.
SPA_API_RINGBUFFER 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.
SPA_API_RINGBUFFER void | spa_ringbuffer_write_data (struct spa_ringbuffer *rbuf, void *buffer, uint32_t size, uint32_t offset, const void *data, uint32_t len)
| Write len bytes to buffer starting offset.
SPA_API_RINGBUFFER void | spa_ringbuffer_write_update (struct spa_ringbuffer *rbuf, int32_t index)
| Update the write pointer to index.

## Detailed Description

Ring buffer implementation.

## Macro Definition Documentation

## ◆ SPA_API_RINGBUFFER

#define SPA_API_RINGBUFFER static inline

## ◆ SPA_RINGBUFFER_INIT

#define SPA_RINGBUFFER_INIT | ( |  | ) |

Value:
((struct spa_ringbuffer) { 0, 0 })
spa_ringbuffer
A ringbuffer type.
Definition ringbuffer.h:47

## Function Documentation

## ◆ spa_ringbuffer_init()

SPA_API_RINGBUFFER void spa_ringbuffer_init | ( | struct spa_ringbuffer * | rbuf | ) |

Initialize a spa_ringbuffer with size.

Parameters

  rbuf | a spa_ringbuffer

Examples
  audio-src-ring.c, and audio-src-ring2.c.

## ◆ spa_ringbuffer_set_avail()

SPA_API_RINGBUFFER void spa_ringbuffer_set_avail | ( | struct spa_ringbuffer * | rbuf,
|  | uint32_t | size )

Sets the pointers so that the ringbuffer contains size bytes.

Parameters

  rbuf | a spa_ringbuffer
  size | the target size of rbuf

## ◆ spa_ringbuffer_get_read_index()

SPA_API_RINGBUFFER int32_t spa_ringbuffer_get_read_index | ( | struct spa_ringbuffer * | rbuf,
|  | uint32_t * | index )

Get the read index and available bytes for reading.

Parameters

  rbuf | a spa_ringbuffer
  index | the 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.

Examples
  audio-src-ring.c, and audio-src-ring2.c.

## ◆ spa_ringbuffer_read_data()

SPA_API_RINGBUFFER void spa_ringbuffer_read_data | ( | struct spa_ringbuffer * | rbuf,
|  | const void * | buffer,
|  | uint32_t | size,
|  | uint32_t | offset,
|  | void * | data,
|  | uint32_t | len )

Read len bytes from rbuf starting offset.

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

Parameters

  rbuf | a struct Ringbuffer
  buffer | memory to read from
  size | the size of buffer
  offset | offset in buffer to read from
  data | destination memory
  len | number of bytes to read

Examples
  audio-src-ring.c, and audio-src-ring2.c.

## ◆ spa_ringbuffer_read_update()

SPA_API_RINGBUFFER void spa_ringbuffer_read_update | ( | struct spa_ringbuffer * | rbuf,
|  | int32_t | index )

Update the read pointer to index.

Parameters

  rbuf | a spa_ringbuffer
  index | new index

Examples
  audio-src-ring.c, and audio-src-ring2.c.

## ◆ spa_ringbuffer_get_write_index()

SPA_API_RINGBUFFER 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.

Parameters

  rbuf | a spa_ringbuffer
  index | the 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.

Examples
  audio-src-ring.c, and audio-src-ring2.c.

## ◆ spa_ringbuffer_write_data()

SPA_API_RINGBUFFER void spa_ringbuffer_write_data | ( | struct spa_ringbuffer * | rbuf,
|  | void * | buffer,
|  | uint32_t | size,
|  | uint32_t | offset,
|  | const void * | data,
|  | uint32_t | len )

Write len bytes to buffer starting offset.

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

Parameters

  rbuf | a spa_ringbuffer
  buffer | memory to write to
  size | the size of buffer
  offset | offset in buffer to write to
  data | source memory
  len | number of bytes to write

Examples
  audio-src-ring2.c.

## ◆ spa_ringbuffer_write_update()

SPA_API_RINGBUFFER void spa_ringbuffer_write_update | ( | struct spa_ringbuffer * | rbuf,
|  | int32_t | index )

Update the write pointer to index.

Parameters

  rbuf | a spa_ringbuffer
  index | new index

Examples
  audio-src-ring.c, and audio-src-ring2.c.