Go to the documentation of this file.
25 #ifndef SPA_RINGBUFFER_H
26 #define SPA_RINGBUFFER_H
51 #define SPA_RINGBUFFER_INIT() (struct spa_ringbuffer) { 0, 0 }
87 *index = __atomic_load_n(&rbuf->
readindex, __ATOMIC_RELAXED);
88 return (int32_t) (__atomic_load_n(&rbuf->
writeindex, __ATOMIC_ACQUIRE) - *index);
104 const void *
buffer, uint32_t size,
105 uint32_t offset,
void *
data, uint32_t len)
107 uint32_t l0 =
SPA_MIN(len, size - offset), l1 = len - l0;
121 __atomic_store_n(&rbuf->
readindex, index, __ATOMIC_RELEASE);
137 *index = __atomic_load_n(&rbuf->
writeindex, __ATOMIC_RELAXED);
138 return (int32_t) (*index - __atomic_load_n(&rbuf->
readindex, __ATOMIC_ACQUIRE));
154 void *
buffer, uint32_t size,
155 uint32_t offset,
const void *
data, uint32_t len)
157 uint32_t l0 =
SPA_MIN(len, size - offset), l1 = len - l0;
171 __atomic_store_n(&rbuf->
writeindex, index, __ATOMIC_RELEASE);
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.
Definition: ringbuffer.h:103
user data to add to an object
Definition: filter.c:75
#define spa_memcpy(d, s, n)
Definition: defs.h:319
#define SPA_PTROFF(ptr_, offset_, type_)
Return the address (buffer + offset) as pointer of type.
Definition: defs.h:159
A ringbuffer type.
Definition: ringbuffer.h:46
int32_t spa_ringbuffer_get_read_index(struct spa_ringbuffer *rbuf, uint32_t *index)
Get the read index and available bytes for reading.
Definition: ringbuffer.h:85
uint32_t writeindex
Definition: ringbuffer.h:48
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.
Definition: ringbuffer.h:135
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.
Definition: ringbuffer.h:153
void spa_ringbuffer_set_avail(struct spa_ringbuffer *rbuf, uint32_t size)
Sets the pointers so that the ringbuffer contains size bytes.
Definition: ringbuffer.h:69
#define SPA_MIN(a, b)
Definition: defs.h:123
void spa_ringbuffer_write_update(struct spa_ringbuffer *rbuf, int32_t index)
Update the write pointer to index.
Definition: ringbuffer.h:169
void spa_ringbuffer_read_update(struct spa_ringbuffer *rbuf, int32_t index)
Update the read pointer to index.
Definition: ringbuffer.h:119
#define SPA_RINGBUFFER_INIT()
Definition: ringbuffer.h:51
void spa_ringbuffer_init(struct spa_ringbuffer *rbuf)
Initialize a spa_ringbuffer with size.
Definition: ringbuffer.h:58
#define SPA_UNLIKELY(x)
Definition: defs.h:235
uint32_t readindex
Definition: ringbuffer.h:47