| Maestro Audio Framework v 1.0 NXP Semiconductors

Data Structures | Functions
ringbuffer.h File Reference

Implements a data ringbuffer. More...

`#include <stdint.h>`

## Data Structures
struct | ringbuf_t

## Functions
ringbuf_t * | ringbuf_create (uint32_t size)
| Create and initialize a ring buffer structure. More...
void | ringbuf_destroy (ringbuf_t *rb)
| Destroy and free ring buffer structure. More...
void | ringbuf_clear (ringbuf_t *rb)
| Empty ring buffer structure. More...
uint32_t | ringbuf_get_occupancy (ringbuf_t *rb)
| Return the number of bytes stored in the ringbuffer. More...
uint32_t | ringbuf_write (ringbuf_t *rb, uint8_t *data, uint32_t size)
| Write data to ring buffer. More...
uint32_t | ringbuf_read (ringbuf_t *rb, uint8_t *data, uint32_t size)
| Read data from ring buffer. More...
uint32_t | ringbuf_peek (ringbuf_t *rb, uint8_t *data, uint32_t size)
| Peak data from ring buffer without removing it. More...

## Function Documentation

## ◆ ringbuf_create()

ringbuf_t* ringbuf_create | ( | uint32_t | size | ) |

Parameters

  size | Buffer size to be malloc'd

Returns
  Initialized and allocated pointer to ring buffer object

## ◆ ringbuf_destroy()

void ringbuf_destroy | ( | ringbuf_t * | rb | ) |

Parameters

  rb | Pointer to ring buffer object created with ringbuf_create

## ◆ ringbuf_clear()

void ringbuf_clear | ( | ringbuf_t * | rb | ) |

Parameters

  rb | Pointer to ring buffer object created with ringbuf_create

## ◆ ringbuf_get_occupancy()

uint32_t ringbuf_get_occupancy | ( | ringbuf_t * | rb | ) |

Parameters

  rb | Pointer to ring buffer object created with ringbuf_create

Returns
  Number of bytes of data currently occupying space in the buffer

## ◆ ringbuf_write()

uint32_t ringbuf_write | ( | ringbuf_t * | rb,
|  | uint8_t * | data,
|  | uint32_t | size
| ) |  |

Parameters

  rb | Pointer to ring buffer object created with ringbuf_create
  data | Input buffer of data to write to ring buffer
  size | Number of bytes to write to ring buffer, from 'data'

Returns
  Number of bytes successfully written to buffer

## ◆ ringbuf_read()

uint32_t ringbuf_read | ( | ringbuf_t * | rb,
|  | uint8_t * | data,
|  | uint32_t | size
| ) |  |

Parameters

  rb | Pointer to ring buffer object created with ringbuf_create
  data | Output buffer of data to write from ring buffer. Can be NULL, in which case data is discarded.
  size | Number of bytes to read from ring buffer, to store in 'data'

Returns
  Number of bytes successfully read to buffer or discarded

## ◆ ringbuf_peek()

uint32_t ringbuf_peek | ( | ringbuf_t * | rb,
|  | uint8_t * | data,
|  | uint32_t | size
| ) |  |

Parameters

  rb | Pointer to ring buffer object created with ringbuf_create
  data | Output buffer of data to write from ring buffer.
  size | Number of bytes to read from ring buffer, to store in 'data'

Returns
  Number of bytes successfully read to buffer