PipeWire: SPA Utils

PipeWire 0.3.34

Data Structures | Macros | Enumerations | Functions
SPA Utils

## Data Structures
struct | spa_rectangle
struct | spa_point
struct | spa_region
struct | spa_fraction
struct | spa_dict_item
struct | spa_dict
struct | spa_list
struct | spa_ringbuffer
| A ringbuffer type. More...

## Macros
#define | SPA_ANSI_RESET "\x1B[0m"
| Ansi escape sequences. More...
#define | SPA_ANSI_BOLD "\x1B[1m"
#define | SPA_ANSI_ITALIC "\x1B[3m"
#define | SPA_ANSI_UNDERLINE "\x1B[4m"
#define | SPA_ANSI_BLACK "\x1B[0;30m"
#define | SPA_ANSI_RED "\x1B[0;31m"
#define | SPA_ANSI_GREEN "\x1B[0;32m"
#define | SPA_ANSI_YELLOW "\x1B[0;33m"
#define | SPA_ANSI_BLUE "\x1B[0;34m"
#define | SPA_ANSI_MAGENTA "\x1B[0;35m"
#define | SPA_ANSI_CYAN "\x1B[0;36m"
#define | SPA_ANSI_WHITE "\x1B[0;37m"
#define | SPA_ANSI_BRIGHT_BLACK "\x1B[90m"
#define | SPA_ANSI_BRIGHT_RED "\x1B[91m"
#define | SPA_ANSI_BRIGHT_GREEN "\x1B[92m"
#define | SPA_ANSI_BRIGHT_YELLOW "\x1B[93m"
#define | SPA_ANSI_BRIGHT_BLUE "\x1B[94m"
#define | SPA_ANSI_BRIGHT_MAGENTA "\x1B[95m"
#define | SPA_ANSI_BRIGHT_CYAN "\x1B[96m"
#define | SPA_ANSI_BRIGHT_WHITE "\x1B[97m"
#define | SPA_ANSI_BOLD_BLACK "\x1B[1;30m"
#define | SPA_ANSI_BOLD_RED "\x1B[1;31m"
#define | SPA_ANSI_BOLD_GREEN "\x1B[1;32m"
#define | SPA_ANSI_BOLD_YELLOW "\x1B[1;33m"
#define | SPA_ANSI_BOLD_BLUE "\x1B[1;34m"
#define | SPA_ANSI_BOLD_MAGENTA "\x1B[1;35m"
#define | SPA_ANSI_BOLD_CYAN "\x1B[1;36m"
#define | SPA_ANSI_BOLD_WHITE "\x1B[1;37m"
#define | SPA_ANSI_DARK_BLACK "\x1B[2;30m"
#define | SPA_ANSI_DARK_RED "\x1B[2;31m"
#define | SPA_ANSI_DARK_GREEN "\x1B[2;32m"
#define | SPA_ANSI_DARK_YELLOW "\x1B[2;33m"
#define | SPA_ANSI_DARK_BLUE "\x1B[2;34m"
#define | SPA_ANSI_DARK_MAGENTA "\x1B[2;35m"
#define | SPA_ANSI_DARK_CYAN "\x1B[2;36m"
#define | SPA_ANSI_DARK_WHITE "\x1B[2;37m"
#define | SPA_ANSI_BG_BLACK "\x1B[0;40m"
#define | SPA_ANSI_BG_RED "\x1B[0;41m"
#define | SPA_ANSI_BG_GREEN "\x1B[0;42m"
#define | SPA_ANSI_BG_YELLOW "\x1B[0;43m"
#define | SPA_ANSI_BG_BLUE "\x1B[0;44m"
#define | SPA_ANSI_BG_MAGENTA "\x1B[0;45m"
#define | SPA_ANSI_BG_CYAN "\x1B[0;46m"
#define | SPA_ANSI_BG_WHITE "\x1B[0;47m"
#define | SPA_ANSI_BG_BRIGHT_BLACK "\x1B[100m"
#define | SPA_ANSI_BG_BRIGHT_RED "\x1B[101m"
#define | SPA_ANSI_BG_BRIGHT_GREEN "\x1B[102m"
#define | SPA_ANSI_BG_BRIGHT_YELLOW "\x1B[103m"
#define | SPA_ANSI_BG_BRIGHT_BLUE "\x1B[104m"
#define | SPA_ANSI_BG_BRIGHT_MAGENTA "\x1B[105m"
#define | SPA_ANSI_BG_BRIGHT_CYAN "\x1B[106m"
#define | SPA_ANSI_BG_BRIGHT_WHITE "\x1B[107m"
#define | SPA_FALLTHROUGH /* FALLTHROUGH */
| SPA_FALLTHROUGH is an annotation to suppress compiler warnings about switch cases that fall through without a break or return statement. More...
#define | SPA_FLAG_MASK(field, mask, flag) (((field) & (mask)) == (flag))
#define | SPA_FLAG_IS_SET(field, flag) SPA_FLAG_MASK(field,flag,flag)
#define | SPA_FLAG_SET(field, flag) ((field) |= (flag))
#define | SPA_FLAG_CLEAR(field, flag) ((field) &= ~(flag))
#define | SPA_FLAG_UPDATE(field, flag, val) ((val) ? SPA_FLAG_SET(field,flag) : SPA_FLAG_CLEAR(field,flag))
#define | SPA_DIRECTION_REVERSE(d) ((d) ^ 1)
#define | SPA_RECTANGLE(width, height) (struct spa_rectangle){ width, height }
#define | SPA_POINT(x, y) (struct spa_point){ x, y }
#define | SPA_REGION(x, y, width, height) (struct spa_region){ SPA_POINT(x,y), SPA_RECTANGLE(width,height) }
#define | SPA_FRACTION(num, denom) (struct spa_fraction){ num, denom }
#define | SPA_N_ELEMENTS(arr) (sizeof(arr) / sizeof((arr)[0]))
#define | SPA_FOR_EACH_ELEMENT(arr, ptr) for (ptr = arr; (void*)ptr < SPA_PTROFF(arr, sizeof(arr), void); ptr++)
| Array iterator macro. More...
#define | SPA_MIN(a, b)
#define | SPA_MAX(a, b)
#define | SPA_CLAMP(v, low, high)
#define | SPA_SWAP(a, b)
#define | SPA_TYPECHECK(type, x)
#define | SPA_PTROFF(ptr_, offset_, type_) ((type_*)((uint8_t*)(ptr_) + (int)(offset_)))
| Return the address (buffer + offset) as pointer of type. More...
#define | SPA_PTROFF_ALIGN(ptr_, offset_, alignment_, type_) SPA_PTR_ALIGN(SPA_PTROFF(ptr_,offset_,type_),alignment_,type_)
#define | SPA_MEMBER(b, o, t) SPA_PTROFF(b,o,t)
| Deprecated, use SPA_PTROFF and SPA_PTROFF_ALIGN instead. More...
#define | SPA_MEMBER_ALIGN(b, o, a, t) SPA_PTROFF_ALIGN(b,o,a,t)
#define | SPA_CONTAINER_OF(p, t, m) (t*)((uint8_t*)p - offsetof (t,m))
#define | SPA_PTRDIFF(p1, p2) ((uint8_t*)(p1) - (uint8_t*)(p2))
#define | SPA_PTR_TO_INT(p) ((int) ((intptr_t) (p)))
#define | SPA_INT_TO_PTR(u) ((void*) ((intptr_t) (u)))
#define | SPA_PTR_TO_UINT32(p) ((uint32_t) ((uintptr_t) (p)))
#define | SPA_UINT32_TO_PTR(u) ((void*) ((uintptr_t) (u)))
#define | SPA_TIME_INVALID ((int64_t)INT64_MIN)
#define | SPA_IDX_INVALID ((unsigned int)-1)
#define | SPA_ID_INVALID ((uint32_t)0xffffffff)
#define | SPA_NSEC_PER_SEC (1000000000ll)
#define | SPA_NSEC_PER_MSEC (1000000ll)
#define | SPA_NSEC_PER_USEC (1000ll)
#define | SPA_USEC_PER_SEC (1000000ll)
#define | SPA_USEC_PER_MSEC (1000ll)
#define | SPA_MSEC_PER_SEC (1000ll)
#define | SPA_TIMESPEC_TO_NSEC(ts) ((ts)->tv_sec * SPA_NSEC_PER_SEC + (ts)->tv_nsec)
#define | SPA_TIMESPEC_TO_USEC(ts) ((ts)->tv_sec * SPA_USEC_PER_SEC + (ts)->tv_nsec / SPA_NSEC_PER_USEC)
#define | SPA_TIMEVAL_TO_NSEC(tv) ((tv)->tv_sec * SPA_NSEC_PER_SEC + (tv)->tv_usec * SPA_NSEC_PER_USEC)
#define | SPA_TIMEVAL_TO_USEC(tv) ((tv)->tv_sec * SPA_USEC_PER_SEC + (tv)->tv_usec)
#define | SPA_PRINTF_FUNC(fmt, arg1)
#define | SPA_ALIGNED(align)
#define | SPA_DEPRECATED
#define | SPA_EXPORT
#define | SPA_SENTINEL
#define | SPA_UNUSED
#define | SPA_NORETURN
#define | SPA_RESTRICT
#define | SPA_ROUND_DOWN_N(num, align) ((num) & ~((align) - 1))
#define | SPA_ROUND_UP_N(num, align) SPA_ROUND_DOWN_N((num) + ((align) - 1),align)
#define | SPA_PTR_ALIGNMENT(p, align) ((intptr_t)(p) & ((align)-1))
#define | SPA_IS_ALIGNED(p, align) (SPA_PTR_ALIGNMENT(p,align) == 0)
#define | SPA_PTR_ALIGN(p, align, type) (type*)SPA_ROUND_UP_N((intptr_t)(p), (intptr_t)(align))
#define | SPA_LIKELY(x) (x)
#define | SPA_UNLIKELY(x) (x)
#define | SPA_STRINGIFY_1(...) #__VA_ARGS__
#define | SPA_STRINGIFY(...) SPA_STRINGIFY_1(__VA_ARGS__)
#define | spa_return_if_fail(expr)
#define | spa_return_val_if_fail(expr, val)
#define | spa_assert_se(expr)
#define | spa_nop() do {} while (false)
#define | spa_assert(expr) spa_assert_se(expr)
#define | spa_assert_not_reached()
#define | spa_memzero(x, l) (memset((x), 0, (l)))
#define | spa_zero(x) (spa_memzero(&(x), sizeof(x)))
#define | spa_memcpy(d, s, n) memcpy(d,s,n)
#define | spa_memmove(d, s, n) memmove(d,s,n)
#define | spa_aprintf(_fmt, ...)
#define | SPA_DICT_ITEM_INIT(key, value) (struct spa_dict_item) { key, value }
#define | SPA_DICT_INIT(items, n_items) (struct spa_dict) { 0, n_items, items }
#define | SPA_DICT_INIT_ARRAY(items) (struct spa_dict) { 0, SPA_N_ELEMENTS(items), items }
#define | spa_dict_for_each(item, dict)
#define | SPA_LIST_INIT(list) (struct spa_list){ list, list }
#define | spa_list_is_empty(l) ((l)->next == (l))
#define | spa_list_first(head, type, member) SPA_CONTAINER_OF((head)->next, type, member)
#define | spa_list_last(head, type, member) SPA_CONTAINER_OF((head)->prev, type, member)
#define | spa_list_append(list, item) spa_list_insert((list)->prev, item)
#define | spa_list_prepend(list, item) spa_list_insert(list, item)
#define | spa_list_is_end(pos, head, member) (&(pos)->member == (head))
#define | spa_list_next(pos, member) SPA_CONTAINER_OF((pos)->member.next, __typeof__(*pos), member)
#define | spa_list_prev(pos, member) SPA_CONTAINER_OF((pos)->member.prev, __typeof__(*pos), member)
#define | spa_list_consume(pos, head, member)
#define | spa_list_for_each_next(pos, head, curr, member)
#define | spa_list_for_each_prev(pos, head, curr, member)
#define | spa_list_for_each(pos, head, member) spa_list_for_each_next(pos, head, head, member)
#define | spa_list_for_each_reverse(pos, head, member) spa_list_for_each_prev(pos, head, head, member)
#define | spa_list_for_each_safe_next(pos, tmp, head, curr, member)
#define | spa_list_for_each_safe_prev(pos, tmp, head, curr, member)
#define | spa_list_for_each_safe(pos, tmp, head, member) spa_list_for_each_safe_next(pos, tmp, head, head, member)
#define | spa_list_for_each_safe_reverse(pos, tmp, head, member) spa_list_for_each_safe_prev(pos, tmp, head, head, member)
#define | spa_list_cursor_start(cursor, head, member) spa_list_prepend(head, &(cursor).member)
#define | spa_list_for_each_cursor(pos, cursor, head, member)
#define | spa_list_cursor_end(cursor, member) spa_list_remove(&(cursor).member)
#define | SPA_ASYNC_BIT (1 << 30)
#define | SPA_ASYNC_SEQ_MASK (SPA_ASYNC_BIT - 1)
#define | SPA_ASYNC_MASK (~SPA_ASYNC_SEQ_MASK)
#define | SPA_RESULT_IS_OK(res) ((res) >= 0)
#define | SPA_RESULT_IS_ERROR(res) ((res) < 0)
#define | SPA_RESULT_IS_ASYNC(res) (((res) & SPA_ASYNC_MASK) == SPA_ASYNC_BIT)
#define | SPA_RESULT_ASYNC_SEQ(res) ((res) & SPA_ASYNC_SEQ_MASK)
#define | SPA_RESULT_RETURN_ASYNC(seq) (SPA_ASYNC_BIT | SPA_RESULT_ASYNC_SEQ(seq))
#define | spa_strerror(err)
#define | SPA_RINGBUFFER_INIT() (struct spa_ringbuffer) { 0, 0 }

## Enumerations
enum | spa_direction { SPA_DIRECTION_INPUT = 0 , SPA_DIRECTION_OUTPUT = 1 }

## Functions
int | spa_dict_item_compare (const void *i1, const void *i2)
void | spa_dict_qsort (struct spa_dict *dict)
const struct spa_dict_item * | spa_dict_lookup_item (const struct spa_dict *dict, const char *key)
const char * | spa_dict_lookup (const struct spa_dict *dict, const char *key)
void | spa_list_init (struct spa_list *list)
void | spa_list_insert (struct spa_list *list, struct spa_list *elem)
void | spa_list_insert_list (struct spa_list *list, struct spa_list *other)
void | spa_list_remove (struct spa_list *elem)
void | spa_ringbuffer_init (struct spa_ringbuffer *rbuf)
| Initialize a spa_ringbuffer with size. More...
void | spa_ringbuffer_set_avail (struct spa_ringbuffer *rbuf, uint32_t size)
| Sets the pointers so that the ringbuffer contains size bytes. More...
int32_t | spa_ringbuffer_get_read_index (struct spa_ringbuffer *rbuf, uint32_t *index)
| Get the read index and available bytes for reading. More...
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. More...
void | spa_ringbuffer_read_update (struct spa_ringbuffer *rbuf, int32_t index)
| Update the read pointer to index. More...
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...
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. More...
void | spa_ringbuffer_write_update (struct spa_ringbuffer *rbuf, int32_t index)
| Update the write pointer to index. More...
bool | spa_streq (const char *s1, const char *s2)
bool | spa_strneq (const char *s1, const char *s2, size_t len)
bool | spa_strstartswith (const char *s, const char *prefix)
bool | spa_strendswith (const char *s, const char *suffix)
bool | spa_atoi32 (const char *str, int32_t *val, int base)
| Convert str to an int32_t with the given base and store the result in val. More...
bool | spa_atou32 (const char *str, uint32_t *val, int base)
| Convert str to an uint32_t with the given base and store the result in val. More...
bool | spa_atoi64 (const char *str, int64_t *val, int base)
| Convert str to an int64_t with the given base and store the result in val. More...
bool | spa_atou64 (const char *str, uint64_t *val, int base)
| Convert str to an uint64_t with the given base and store the result in val. More...
bool | spa_atob (const char *str)
| Convert str to a boolean. More...
int | spa_vscnprintf (char *buffer, size_t size, const char *format, va_list args)
int | spa_scnprintf (char *buffer, size_t size, const char *format,...)
bool | spa_atof (const char *str, float *val)
| Convert str to a float and store the result in val. More...
bool | spa_atod (const char *str, double *val)
| Convert str to a double and store the result in val. More...

## Detailed Description

## Macro Definition Documentation

## ◆ SPA_ALIGNED

#define SPA_ALIGNED | ( |  | align | ) |

## ◆ SPA_ANSI_BG_BLACK

#define SPA_ANSI_BG_BLACK "\x1B[0;40m"

## ◆ SPA_ANSI_BG_BLUE

#define SPA_ANSI_BG_BLUE "\x1B[0;44m"

## ◆ SPA_ANSI_BG_BRIGHT_BLACK

#define SPA_ANSI_BG_BRIGHT_BLACK "\x1B[100m"

## ◆ SPA_ANSI_BG_BRIGHT_BLUE

#define SPA_ANSI_BG_BRIGHT_BLUE "\x1B[104m"

## ◆ SPA_ANSI_BG_BRIGHT_CYAN

#define SPA_ANSI_BG_BRIGHT_CYAN "\x1B[106m"

## ◆ SPA_ANSI_BG_BRIGHT_GREEN

#define SPA_ANSI_BG_BRIGHT_GREEN "\x1B[102m"

## ◆ SPA_ANSI_BG_BRIGHT_MAGENTA

#define SPA_ANSI_BG_BRIGHT_MAGENTA "\x1B[105m"

## ◆ SPA_ANSI_BG_BRIGHT_RED

#define SPA_ANSI_BG_BRIGHT_RED "\x1B[101m"

## ◆ SPA_ANSI_BG_BRIGHT_WHITE

#define SPA_ANSI_BG_BRIGHT_WHITE "\x1B[107m"

## ◆ SPA_ANSI_BG_BRIGHT_YELLOW

#define SPA_ANSI_BG_BRIGHT_YELLOW "\x1B[103m"

## ◆ SPA_ANSI_BG_CYAN

#define SPA_ANSI_BG_CYAN "\x1B[0;46m"

## ◆ SPA_ANSI_BG_GREEN

#define SPA_ANSI_BG_GREEN "\x1B[0;42m"

## ◆ SPA_ANSI_BG_MAGENTA

#define SPA_ANSI_BG_MAGENTA "\x1B[0;45m"

## ◆ SPA_ANSI_BG_RED

#define SPA_ANSI_BG_RED "\x1B[0;41m"

## ◆ SPA_ANSI_BG_WHITE

#define SPA_ANSI_BG_WHITE "\x1B[0;47m"

## ◆ SPA_ANSI_BG_YELLOW

#define SPA_ANSI_BG_YELLOW "\x1B[0;43m"

## ◆ SPA_ANSI_BLACK

#define SPA_ANSI_BLACK "\x1B[0;30m"

## ◆ SPA_ANSI_BLUE

#define SPA_ANSI_BLUE "\x1B[0;34m"

## ◆ SPA_ANSI_BOLD

#define SPA_ANSI_BOLD "\x1B[1m"

## ◆ SPA_ANSI_BOLD_BLACK

#define SPA_ANSI_BOLD_BLACK "\x1B[1;30m"

## ◆ SPA_ANSI_BOLD_BLUE

#define SPA_ANSI_BOLD_BLUE "\x1B[1;34m"

## ◆ SPA_ANSI_BOLD_CYAN

#define SPA_ANSI_BOLD_CYAN "\x1B[1;36m"

## ◆ SPA_ANSI_BOLD_GREEN

#define SPA_ANSI_BOLD_GREEN "\x1B[1;32m"

## ◆ SPA_ANSI_BOLD_MAGENTA

#define SPA_ANSI_BOLD_MAGENTA "\x1B[1;35m"

## ◆ SPA_ANSI_BOLD_RED

#define SPA_ANSI_BOLD_RED "\x1B[1;31m"

## ◆ SPA_ANSI_BOLD_WHITE

#define SPA_ANSI_BOLD_WHITE "\x1B[1;37m"

## ◆ SPA_ANSI_BOLD_YELLOW

#define SPA_ANSI_BOLD_YELLOW "\x1B[1;33m"

## ◆ SPA_ANSI_BRIGHT_BLACK

#define SPA_ANSI_BRIGHT_BLACK "\x1B[90m"

## ◆ SPA_ANSI_BRIGHT_BLUE

#define SPA_ANSI_BRIGHT_BLUE "\x1B[94m"

## ◆ SPA_ANSI_BRIGHT_CYAN

#define SPA_ANSI_BRIGHT_CYAN "\x1B[96m"

## ◆ SPA_ANSI_BRIGHT_GREEN

#define SPA_ANSI_BRIGHT_GREEN "\x1B[92m"

## ◆ SPA_ANSI_BRIGHT_MAGENTA

#define SPA_ANSI_BRIGHT_MAGENTA "\x1B[95m"

## ◆ SPA_ANSI_BRIGHT_RED

#define SPA_ANSI_BRIGHT_RED "\x1B[91m"

## ◆ SPA_ANSI_BRIGHT_WHITE

#define SPA_ANSI_BRIGHT_WHITE "\x1B[97m"

## ◆ SPA_ANSI_BRIGHT_YELLOW

#define SPA_ANSI_BRIGHT_YELLOW "\x1B[93m"

## ◆ SPA_ANSI_CYAN

#define SPA_ANSI_CYAN "\x1B[0;36m"

## ◆ SPA_ANSI_DARK_BLACK

#define SPA_ANSI_DARK_BLACK "\x1B[2;30m"

## ◆ SPA_ANSI_DARK_BLUE

#define SPA_ANSI_DARK_BLUE "\x1B[2;34m"

## ◆ SPA_ANSI_DARK_CYAN

#define SPA_ANSI_DARK_CYAN "\x1B[2;36m"

## ◆ SPA_ANSI_DARK_GREEN

#define SPA_ANSI_DARK_GREEN "\x1B[2;32m"

## ◆ SPA_ANSI_DARK_MAGENTA

#define SPA_ANSI_DARK_MAGENTA "\x1B[2;35m"

## ◆ SPA_ANSI_DARK_RED

#define SPA_ANSI_DARK_RED "\x1B[2;31m"

## ◆ SPA_ANSI_DARK_WHITE

#define SPA_ANSI_DARK_WHITE "\x1B[2;37m"

## ◆ SPA_ANSI_DARK_YELLOW

#define SPA_ANSI_DARK_YELLOW "\x1B[2;33m"

## ◆ SPA_ANSI_GREEN

#define SPA_ANSI_GREEN "\x1B[0;32m"

## ◆ SPA_ANSI_ITALIC

#define SPA_ANSI_ITALIC "\x1B[3m"

## ◆ SPA_ANSI_MAGENTA

#define SPA_ANSI_MAGENTA "\x1B[0;35m"

## ◆ SPA_ANSI_RED

#define SPA_ANSI_RED "\x1B[0;31m"

## ◆ SPA_ANSI_RESET

#define SPA_ANSI_RESET "\x1B[0m"

Ansi escape sequences.

Note that the color names are approximate only and the actual rendering of the color depends on the terminal.

## ◆ SPA_ANSI_UNDERLINE

#define SPA_ANSI_UNDERLINE "\x1B[4m"

## ◆ SPA_ANSI_WHITE

#define SPA_ANSI_WHITE "\x1B[0;37m"

## ◆ SPA_ANSI_YELLOW

#define SPA_ANSI_YELLOW "\x1B[0;33m"

## ◆ spa_aprintf

#define spa_aprintf | ( |  | _fmt,
|  |  | ...
| ) |  |

Value:
({ \
char *_strp; \
if (asprintf(&(_strp), (_fmt), ## __VA_ARGS__ ) == -1) \
_strp = NULL; \
_strp; \
})

## ◆ spa_assert

#define spa_assert | ( |  | expr | ) | spa_assert_se(expr)

## ◆ spa_assert_not_reached

#define spa_assert_not_reached | ( |  | ) |

Value:
do { \
fprintf(stderr, "Code should not be reached at %s:%u %s()\n", \
__FILE__, __LINE__, __func__); \
abort(); \
} while (false)

## ◆ spa_assert_se

#define spa_assert_se | ( |  | expr | ) |

Value:
do { \
if (SPA_UNLIKELY(!(expr))) { \
fprintf(stderr, "'%s' failed at %s:%u %s()\n", \
#expr , __FILE__, __LINE__, __func__); \
abort(); \
} \
} while (false)
SPA_UNLIKELY
#define SPA_UNLIKELY(x)
Definition: defs.h:235

## ◆ SPA_ASYNC_BIT

#define SPA_ASYNC_BIT (1 << 30)

## ◆ SPA_ASYNC_MASK

#define SPA_ASYNC_MASK (~SPA_ASYNC_SEQ_MASK)

## ◆ SPA_ASYNC_SEQ_MASK

#define SPA_ASYNC_SEQ_MASK (SPA_ASYNC_BIT - 1)

## ◆ SPA_CLAMP

#define SPA_CLAMP | ( |  | v,
|  |  | low,
|  |  | high
| ) |  |

Value:
({ \
__typeof__(v) _v = (v); \
__typeof__(low) _low = (low); \
__typeof__(high) _high = (high); \
SPA_MIN(SPA_MAX(_v, _low), _high); \
})
SPA_MAX
#define SPA_MAX(a, b)
Definition: defs.h:129

## ◆ SPA_CONTAINER_OF

#define SPA_CONTAINER_OF | ( |  | p,
|  |  | t,
|  |  | m
| ) |  | (t*)((uint8_t*)p - offsetof (t,m))

## ◆ SPA_DEPRECATED

#define SPA_DEPRECATED

## ◆ spa_dict_for_each

#define spa_dict_for_each | ( |  | item,
|  |  | dict
| ) |  |

Value:
for ((item) = (dict)->items; \
(item) < &(dict)->items[(dict)->n_items]; \
(item)++)
item
Definition: impl-metadata.c:49

## ◆ SPA_DICT_INIT

#define SPA_DICT_INIT | ( |  | items,
|  |  | n_items
| ) |  | (struct spa_dict) { 0, n_items, items }

## ◆ SPA_DICT_INIT_ARRAY

#define SPA_DICT_INIT_ARRAY | ( |  | items | ) | (struct spa_dict) { 0, SPA_N_ELEMENTS(items), items }

## ◆ SPA_DICT_ITEM_INIT

#define SPA_DICT_ITEM_INIT | ( |  | key,
|  |  | value
| ) |  | (struct spa_dict_item) { key, value }

## ◆ SPA_DIRECTION_REVERSE

#define SPA_DIRECTION_REVERSE | ( |  | d | ) | ((d) ^ 1)

## ◆ SPA_EXPORT

#define SPA_EXPORT

## ◆ SPA_FALLTHROUGH

#define SPA_FALLTHROUGH /* FALLTHROUGH */

SPA_FALLTHROUGH is an annotation to suppress compiler warnings about switch cases that fall through without a break or return statement.

SPA_FALLTHROUGH is only needed on cases that have code:

switch (foo) { case 1: // These cases have no code. No fallthrough annotations are needed. case 2: case 3: foo = 4; // This case has code, so a fallthrough annotation is needed: SPA_FALLTHROUGH; default: return foo; }

## ◆ SPA_FLAG_CLEAR

#define SPA_FLAG_CLEAR | ( |  | field,
|  |  | flag
| ) |  | ((field) &= ~(flag))

## ◆ SPA_FLAG_IS_SET

#define SPA_FLAG_IS_SET | ( |  | field,
|  |  | flag
| ) |  | SPA_FLAG_MASK(field,flag,flag)

## ◆ SPA_FLAG_MASK

#define SPA_FLAG_MASK | ( |  | field,
|  |  | mask,
|  |  | flag
| ) |  | (((field) & (mask)) == (flag))

## ◆ SPA_FLAG_SET

#define SPA_FLAG_SET | ( |  | field,
|  |  | flag
| ) |  | ((field) |= (flag))

## ◆ SPA_FLAG_UPDATE

#define SPA_FLAG_UPDATE | ( |  | field,
|  |  | flag,
|  |  | val
| ) |  | ((val) ? SPA_FLAG_SET(field,flag) : SPA_FLAG_CLEAR(field,flag))

## ◆ SPA_FOR_EACH_ELEMENT

#define SPA_FOR_EACH_ELEMENT | ( |  | arr,
|  |  | ptr
| ) |  | for (ptr = arr; (void*)ptr < SPA_PTROFF(arr, sizeof(arr), void); ptr++)

Array iterator macro.

Usage:

struct foo array[16];
struct foo *f;
SPA_FOR_EACH_ELEMENT(array, f) {
f->bar = baz;
}
SPA_FOR_EACH_ELEMENT
#define SPA_FOR_EACH_ELEMENT(arr, ptr)
Array iterator macro.
Definition: defs.h:120

## ◆ SPA_FRACTION

#define SPA_FRACTION | ( |  | num,
|  |  | denom
| ) |  | (struct spa_fraction){ num, denom }

## ◆ SPA_ID_INVALID

#define SPA_ID_INVALID ((uint32_t)0xffffffff)

## ◆ SPA_IDX_INVALID

#define SPA_IDX_INVALID ((unsigned int)-1)

## ◆ SPA_INT_TO_PTR

#define SPA_INT_TO_PTR | ( |  | u | ) | ((void*) ((intptr_t) (u)))

## ◆ SPA_IS_ALIGNED

#define SPA_IS_ALIGNED | ( |  | p,
|  |  | align
| ) |  | (SPA_PTR_ALIGNMENT(p,align) == 0)

## ◆ SPA_LIKELY

#define SPA_LIKELY | ( |  | x | ) | (x)

## ◆ spa_list_append

#define spa_list_append | ( |  | list,
|  |  | item
| ) |  | spa_list_insert((list)->prev, item)

## ◆ spa_list_consume

#define spa_list_consume | ( |  | pos,
|  |  | head,
|  |  | member
| ) |  |

Value:
for (pos = spa_list_first(head, __typeof__(*pos), member); \
!spa_list_is_empty(head); \
pos = spa_list_first(head, __typeof__(*pos), member))
spa_list_first
#define spa_list_first(head, type, member)
Definition: list.h:75
spa_list_is_empty
#define spa_list_is_empty(l)
Definition: list.h:49

## ◆ spa_list_cursor_end

#define spa_list_cursor_end | ( |  | cursor,
|  |  | member
| ) |  | spa_list_remove(&(cursor).member)

## ◆ spa_list_cursor_start

#define spa_list_cursor_start | ( |  | cursor,
|  |  | head,
|  |  | member
| ) |  | spa_list_prepend(head, &(cursor).member)

## ◆ spa_list_first

#define spa_list_first | ( |  | head,
|  |  | type,
|  |  | member
| ) |  | SPA_CONTAINER_OF((head)->next, type, member)

## ◆ spa_list_for_each

#define spa_list_for_each | ( |  | pos,
|  |  | head,
|  |  | member
| ) |  | spa_list_for_each_next(pos, head, head, member)

## ◆ spa_list_for_each_cursor

#define spa_list_for_each_cursor | ( |  | pos,
|  |  | cursor,
|  |  | head,
|  |  | member
| ) |  |

Value:
for(pos = spa_list_first(&(cursor).member, __typeof__(*(pos)), member); \
spa_list_remove(&(pos)->member), \
spa_list_append(&(cursor).member, &(pos)->member), \
!spa_list_is_end(pos, head, member); \
pos = spa_list_next(&cursor, member))
spa_list_next
#define spa_list_next(pos, member)
Definition: list.h:90
spa_list_is_end
#define spa_list_is_end(pos, head, member)
Definition: list.h:87

## ◆ spa_list_for_each_next

#define spa_list_for_each_next | ( |  | pos,
|  |  | head,
|  |  | curr,
|  |  | member
| ) |  |

Value:
for (pos = spa_list_first(curr, __typeof__(*pos), member); \
!spa_list_is_end(pos, head, member); \
pos = spa_list_next(pos, member))

## ◆ spa_list_for_each_prev

#define spa_list_for_each_prev | ( |  | pos,
|  |  | head,
|  |  | curr,
|  |  | member
| ) |  |

Value:
for (pos = spa_list_last(curr, __typeof__(*pos), member); \
!spa_list_is_end(pos, head, member); \
pos = spa_list_prev(pos, member))
spa_list_prev
#define spa_list_prev(pos, member)
Definition: list.h:93
spa_list_last
#define spa_list_last(head, type, member)
Definition: list.h:78

## ◆ spa_list_for_each_reverse

#define spa_list_for_each_reverse | ( |  | pos,
|  |  | head,
|  |  | member
| ) |  | spa_list_for_each_prev(pos, head, head, member)

## ◆ spa_list_for_each_safe

#define spa_list_for_each_safe | ( |  | pos,
|  |  | tmp,
|  |  | head,
|  |  | member
| ) |  | spa_list_for_each_safe_next(pos, tmp, head, head, member)

## ◆ spa_list_for_each_safe_next

#define spa_list_for_each_safe_next | ( |  | pos,
|  |  | tmp,
|  |  | head,
|  |  | curr,
|  |  | member
| ) |  |

Value:
for (pos = spa_list_first(curr, __typeof__(*pos), member); \
tmp = spa_list_next(pos, member), \
!spa_list_is_end(pos, head, member); \
pos = tmp)

## ◆ spa_list_for_each_safe_prev

#define spa_list_for_each_safe_prev | ( |  | pos,
|  |  | tmp,
|  |  | head,
|  |  | curr,
|  |  | member
| ) |  |

Value:
for (pos = spa_list_last(curr, __typeof__(*pos), member); \
tmp = spa_list_prev(pos, member), \
!spa_list_is_end(pos, head, member); \
pos = tmp)

## ◆ spa_list_for_each_safe_reverse

#define spa_list_for_each_safe_reverse | ( |  | pos,
|  |  | tmp,
|  |  | head,
|  |  | member
| ) |  | spa_list_for_each_safe_prev(pos, tmp, head, head, member)

## ◆ SPA_LIST_INIT

#define SPA_LIST_INIT | ( |  | list | ) | (struct spa_list){ list, list }

## ◆ spa_list_is_empty

#define spa_list_is_empty | ( |  | l | ) | ((l)->next == (l))

## ◆ spa_list_is_end

#define spa_list_is_end | ( |  | pos,
|  |  | head,
|  |  | member
| ) |  | (&(pos)->member == (head))

## ◆ spa_list_last

#define spa_list_last | ( |  | head,
|  |  | type,
|  |  | member
| ) |  | SPA_CONTAINER_OF((head)->prev, type, member)

## ◆ spa_list_next

#define spa_list_next | ( |  | pos,
|  |  | member
| ) |  | SPA_CONTAINER_OF((pos)->member.next, __typeof__(*pos), member)

## ◆ spa_list_prepend

#define spa_list_prepend | ( |  | list,
|  |  | item
| ) |  | spa_list_insert(list, item)

## ◆ spa_list_prev

#define spa_list_prev | ( |  | pos,
|  |  | member
| ) |  | SPA_CONTAINER_OF((pos)->member.prev, __typeof__(*pos), member)

## ◆ SPA_MAX

#define SPA_MAX | ( |  | a,
|  |  | b
| ) |  |

Value:
({ \
__typeof__(a) _max_a = (a); \
__typeof__(b) _max_b = (b); \
SPA_LIKELY(_max_a > _max_b) ? _max_a : _max_b; \
})

## ◆ SPA_MEMBER

#define SPA_MEMBER | ( |  | b,
|  |  | o,
|  |  | t
| ) |  | SPA_PTROFF(b,o,t)

Deprecated, use SPA_PTROFF and SPA_PTROFF_ALIGN instead.

## ◆ SPA_MEMBER_ALIGN

#define SPA_MEMBER_ALIGN | ( |  | b,
|  |  | o,
|  |  | a,
|  |  | t
| ) |  | SPA_PTROFF_ALIGN(b,o,a,t)

## ◆ spa_memcpy

#define spa_memcpy | ( |  | d,
|  |  | s,
|  |  | n
| ) |  | memcpy(d,s,n)

## ◆ spa_memmove

#define spa_memmove | ( |  | d,
|  |  | s,
|  |  | n
| ) |  | memmove(d,s,n)

## ◆ spa_memzero

#define spa_memzero | ( |  | x,
|  |  | l
| ) |  | (memset((x), 0, (l)))

## ◆ SPA_MIN

#define SPA_MIN | ( |  | a,
|  |  | b
| ) |  |

Value:
({ \
__typeof__(a) _min_a = (a); \
__typeof__(b) _min_b = (b); \
SPA_LIKELY(_min_a < _min_b) ? _min_a : _min_b; \
})

## ◆ SPA_MSEC_PER_SEC

#define SPA_MSEC_PER_SEC (1000ll)

## ◆ SPA_N_ELEMENTS

#define SPA_N_ELEMENTS | ( |  | arr | ) | (sizeof(arr) / sizeof((arr)[0]))

## ◆ spa_nop

#define spa_nop | ( |  | ) | do {} while (false)

## ◆ SPA_NORETURN

#define SPA_NORETURN

## ◆ SPA_NSEC_PER_MSEC

#define SPA_NSEC_PER_MSEC (1000000ll)

## ◆ SPA_NSEC_PER_SEC

#define SPA_NSEC_PER_SEC (1000000000ll)

## ◆ SPA_NSEC_PER_USEC

#define SPA_NSEC_PER_USEC (1000ll)

## ◆ SPA_POINT

#define SPA_POINT | ( |  | x,
|  |  | y
| ) |  | (struct spa_point){ x, y }

## ◆ SPA_PRINTF_FUNC

#define SPA_PRINTF_FUNC | ( |  | fmt,
|  |  | arg1
| ) |  |

## ◆ SPA_PTR_ALIGN

#define SPA_PTR_ALIGN | ( |  | p,
|  |  | align,
|  |  | type
| ) |  | (type*)SPA_ROUND_UP_N((intptr_t)(p), (intptr_t)(align))

## ◆ SPA_PTR_ALIGNMENT

#define SPA_PTR_ALIGNMENT | ( |  | p,
|  |  | align
| ) |  | ((intptr_t)(p) & ((align)-1))

## ◆ SPA_PTR_TO_INT

#define SPA_PTR_TO_INT | ( |  | p | ) | ((int) ((intptr_t) (p)))

## ◆ SPA_PTR_TO_UINT32

#define SPA_PTR_TO_UINT32 | ( |  | p | ) | ((uint32_t) ((uintptr_t) (p)))

## ◆ SPA_PTRDIFF

#define SPA_PTRDIFF | ( |  | p1,
|  |  | p2
| ) |  | ((uint8_t*)(p1) - (uint8_t*)(p2))

## ◆ SPA_PTROFF

#define SPA_PTROFF | ( |  | ptr_,
|  |  | offset_,
|  |  | type_
| ) |  | ((type_*)((uint8_t*)(ptr_) + (int)(offset_)))

Return the address (buffer + offset) as pointer of type.

## ◆ SPA_PTROFF_ALIGN

#define SPA_PTROFF_ALIGN | ( |  | ptr_,
|  |  | offset_,
|  |  | alignment_,
|  |  | type_
| ) |  | SPA_PTR_ALIGN(SPA_PTROFF(ptr_,offset_,type_),alignment_,type_)

## ◆ SPA_RECTANGLE

#define SPA_RECTANGLE | ( |  | width,
|  |  | height
| ) |  | (struct spa_rectangle){ width, height }

## ◆ SPA_REGION

#define SPA_REGION | ( |  | x,
|  |  | y,
|  |  | width,
|  |  | height
| ) |  | (struct spa_region){ SPA_POINT(x,y), SPA_RECTANGLE(width,height) }

## ◆ SPA_RESTRICT

#define SPA_RESTRICT

## ◆ SPA_RESULT_ASYNC_SEQ

#define SPA_RESULT_ASYNC_SEQ | ( |  | res | ) | ((res) & SPA_ASYNC_SEQ_MASK)

## ◆ SPA_RESULT_IS_ASYNC

#define SPA_RESULT_IS_ASYNC | ( |  | res | ) | (((res) & SPA_ASYNC_MASK) == SPA_ASYNC_BIT)

## ◆ SPA_RESULT_IS_ERROR

#define SPA_RESULT_IS_ERROR | ( |  | res | ) | ((res) < 0)

## ◆ SPA_RESULT_IS_OK

#define SPA_RESULT_IS_OK | ( |  | res | ) | ((res) >= 0)

## ◆ SPA_RESULT_RETURN_ASYNC

#define SPA_RESULT_RETURN_ASYNC | ( |  | seq | ) | (SPA_ASYNC_BIT | SPA_RESULT_ASYNC_SEQ(seq))

## ◆ spa_return_if_fail

#define spa_return_if_fail | ( |  | expr | ) |

Value:
do { \
if (SPA_UNLIKELY(!(expr))) { \
fprintf(stderr, "'%s' failed at %s:%u %s()\n", \
#expr , __FILE__, __LINE__, __func__); \
return; \
} \
} while(false)

## ◆ spa_return_val_if_fail

#define spa_return_val_if_fail | ( |  | expr,
|  |  | val
| ) |  |

Value:
do { \
if (SPA_UNLIKELY(!(expr))) { \
fprintf(stderr, "'%s' failed at %s:%u %s()\n", \
#expr , __FILE__, __LINE__, __func__); \
return (val); \
} \
} while(false)

## ◆ SPA_RINGBUFFER_INIT

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

## ◆ SPA_ROUND_DOWN_N

#define SPA_ROUND_DOWN_N | ( |  | num,
|  |  | align
| ) |  | ((num) & ~((align) - 1))

## ◆ SPA_ROUND_UP_N

#define SPA_ROUND_UP_N | ( |  | num,
|  |  | align
| ) |  | SPA_ROUND_DOWN_N((num) + ((align) - 1),align)

## ◆ SPA_SENTINEL

#define SPA_SENTINEL

## ◆ spa_strerror

#define spa_strerror | ( |  | err | ) |

Value:
({ \
int _err = -err; \
if (SPA_RESULT_IS_ASYNC(err)) \
_err = EINPROGRESS; \
strerror(_err); \
})
SPA_RESULT_IS_ASYNC
#define SPA_RESULT_IS_ASYNC(res)
Definition: result.h:46

## ◆ SPA_STRINGIFY

#define SPA_STRINGIFY | ( |  | ... | ) | SPA_STRINGIFY_1(__VA_ARGS__)

## ◆ SPA_STRINGIFY_1

#define SPA_STRINGIFY_1 | ( |  | ... | ) | #__VA_ARGS__

## ◆ SPA_SWAP

#define SPA_SWAP | ( |  | a,
|  |  | b
| ) |  |

Value:
({ \
__typeof__(a) _t = (a); \
a = b; b = _t; \
})

## ◆ SPA_TIME_INVALID

#define SPA_TIME_INVALID ((int64_t)INT64_MIN)

## ◆ SPA_TIMESPEC_TO_NSEC

#define SPA_TIMESPEC_TO_NSEC | ( |  | ts | ) | ((ts)->tv_sec * SPA_NSEC_PER_SEC + (ts)->tv_nsec)

## ◆ SPA_TIMESPEC_TO_USEC

#define SPA_TIMESPEC_TO_USEC | ( |  | ts | ) | ((ts)->tv_sec * SPA_USEC_PER_SEC + (ts)->tv_nsec / SPA_NSEC_PER_USEC)

## ◆ SPA_TIMEVAL_TO_NSEC

#define SPA_TIMEVAL_TO_NSEC | ( |  | tv | ) | ((tv)->tv_sec * SPA_NSEC_PER_SEC + (tv)->tv_usec * SPA_NSEC_PER_USEC)

## ◆ SPA_TIMEVAL_TO_USEC

#define SPA_TIMEVAL_TO_USEC | ( |  | tv | ) | ((tv)->tv_sec * SPA_USEC_PER_SEC + (tv)->tv_usec)

## ◆ SPA_TYPECHECK

#define SPA_TYPECHECK | ( |  | type,
|  |  | x
| ) |  |

Value:
({ type _dummy; \
typeof(x) _dummy2; \
(void)(&_dummy == &_dummy2); \
x; \
})

## ◆ SPA_UINT32_TO_PTR

#define SPA_UINT32_TO_PTR | ( |  | u | ) | ((void*) ((uintptr_t) (u)))

## ◆ SPA_UNLIKELY

#define SPA_UNLIKELY | ( |  | x | ) | (x)

## ◆ SPA_UNUSED

#define SPA_UNUSED

## ◆ SPA_USEC_PER_MSEC

#define SPA_USEC_PER_MSEC (1000ll)

## ◆ SPA_USEC_PER_SEC

#define SPA_USEC_PER_SEC (1000000ll)

## ◆ spa_zero

#define spa_zero | ( |  | x | ) | (spa_memzero(&(x), sizeof(x)))

## Enumeration Type Documentation

## ◆ spa_direction

enum spa_direction

Enumerator
SPA_DIRECTION_INPUT |
SPA_DIRECTION_OUTPUT |

## Function Documentation

## ◆ spa_atob()

bool spa_atob | ( | const char * | str | ) |
| inline

Convert str to a boolean.

Allowed boolean values are "true" and a literal "1", anything else is false.

Returns
  true on success, false otherwise

References spa_streq().

Referenced by get_pending_save().

## ◆ spa_atod()

bool spa_atod | ( | const char * | str,
|  | double * | val
| ) |  |
| inline

Convert str to a double and store the result in val.

On failure, the value of val is unmodified.

Returns
  true on success, false otherwise

## ◆ spa_atof()

bool spa_atof | ( | const char * | str,
|  | float * | val
| ) |  |
| inline

Convert str to a float and store the result in val.

On failure, the value of val is unmodified.

Returns
  true on success, false otherwise

## ◆ spa_atoi32()

bool spa_atoi32 | ( | const char * | str,
|  | int32_t * | val,
|  | int | base
| ) |  |
| inline

Convert str to an int32_t with the given base and store the result in val.

On failure, the value of val is unmodified.

Returns
  true on success, false otherwise

## ◆ spa_atoi64()

bool spa_atoi64 | ( | const char * | str,
|  | int64_t * | val,
|  | int | base
| ) |  |
| inline

Convert str to an int64_t with the given base and store the result in val.

On failure, the value of val is unmodified.

Returns
  true on success, false otherwise

## ◆ spa_atou32()

bool spa_atou32 | ( | const char * | str,
|  | uint32_t * | val,
|  | int | base
| ) |  |
| inline

Convert str to an uint32_t with the given base and store the result in val.

On failure, the value of val is unmodified.

Returns
  true on success, false otherwise

## ◆ spa_atou64()

bool spa_atou64 | ( | const char * | str,
|  | uint64_t * | val,
|  | int | base
| ) |  |
| inline

Convert str to an uint64_t with the given base and store the result in val.

On failure, the value of val is unmodified.

Returns
  true on success, false otherwise

## ◆ spa_dict_item_compare()

int spa_dict_item_compare | ( | const void * | i1,
|  | const void * | i2
| ) |  |
| inline

References spa_dict_item::key.

Referenced by spa_dict_lookup_item(), and spa_dict_qsort().

## ◆ spa_dict_lookup()

const char* spa_dict_lookup | ( | const struct spa_dict * | dict,
|  | const char * | key
| ) |  |
| inline

References spa_dict_item::key, spa_dict_lookup_item(), and item::value.

Referenced by pw_context_load_spa_handle(), pw_loop_new(), pw_properties_add_keys(), pw_properties_update_keys(), sm_media_session_create_links(), and sm_media_session_remove_links().

## ◆ spa_dict_lookup_item()

const struct spa_dict_item* spa_dict_lookup_item | ( | const struct spa_dict * | dict,
|  | const char * | key
| ) |  |
| inline

References spa_dict::flags, spa_dict::items, spa_dict_item::key, item::key, spa_dict::n_items, SPA_DICT_FLAG_SORTED, spa_dict_for_each, spa_dict_item_compare(), SPA_DICT_ITEM_INIT, and SPA_FLAG_IS_SET.

Referenced by spa_dict_lookup().

## ◆ spa_dict_qsort()

void spa_dict_qsort | ( | struct spa_dict * | dict | ) |
| inline

References spa_dict::flags, spa_dict::items, spa_dict::n_items, SPA_DICT_FLAG_SORTED, spa_dict_item_compare(), and SPA_FLAG_SET.

## ◆ spa_list_init()

void spa_list_init | ( | struct spa_list * | list | ) |
| inline

References SPA_LIST_INIT.

Referenced by pipewire__module_init(), pw_context_create_device(), pw_context_create_node(), pw_context_create_port(), pw_control_new(), pw_mempool_alloc(), pw_protocol_new(), sm_access_flatpak_start(), sm_access_portal_start(), sm_bluez5_monitor_start(), sm_libcamera_monitor_start(), sm_policy_ep_start(), sm_suspend_node_start(), sm_v4l2_monitor_start(), spa_graph_init(), spa_graph_node_init(), spa_graph_run(), and spa_hook_list_init().

## ◆ spa_list_insert()

void spa_list_insert | ( | struct spa_list * | list,
|  | struct spa_list * | elem
| ) |  |
| inline

References spa_list::next, and spa_list::prev.

## ◆ spa_list_insert_list()

void spa_list_insert_list | ( | struct spa_list * | list,
|  | struct spa_list * | other
| ) |  |
| inline

References spa_list::next, spa_list::prev, and spa_list_is_empty.

Referenced by spa_hook_list_isolate(), and spa_hook_list_join().

## ◆ spa_list_remove()

void spa_list_remove | ( | struct spa_list * | elem | ) |
| inline

References spa_list::next, and spa_list::prev.

Referenced by pw_control_destroy(), pw_filter_destroy(), pw_filter_disconnect(), pw_filter_remove_port(), pw_impl_client_destroy(), pw_impl_core_destroy(), pw_impl_factory_destroy(), pw_impl_link_destroy(), pw_impl_metadata_destroy(), pw_impl_module_destroy(), pw_impl_node_set_driver(), pw_memmap_free(), pw_protocol_destroy(), pw_resource_destroy(), pw_stream_destroy(), pw_stream_disconnect(), pw_work_queue_add(), spa_graph_link_remove(), spa_graph_node_remove(), spa_graph_port_remove(), and spa_hook_remove().

## ◆ spa_ringbuffer_get_read_index()

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

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.

References spa_ringbuffer::readindex, and spa_ringbuffer::writeindex.

## ◆ spa_ringbuffer_get_write_index()

int32_t spa_ringbuffer_get_write_index | ( | struct spa_ringbuffer * | rbuf,
|  | uint32_t * | index
| ) |  |
| inline

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.

References spa_ringbuffer::readindex, and spa_ringbuffer::writeindex.

## ◆ spa_ringbuffer_init()

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

Initialize a spa_ringbuffer with size.

Parameters

  rbuf | a spa_ringbuffer

References SPA_RINGBUFFER_INIT.

Referenced by pipewire__module_init().

## ◆ spa_ringbuffer_read_data()

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

Read len bytes from rbuf starting offset.

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

Parameters

  rbuf | a struct spa_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

References spa_memcpy, SPA_MIN, SPA_PTROFF, and SPA_UNLIKELY.

## ◆ spa_ringbuffer_read_update()

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

Update the read pointer to index.

Parameters

  rbuf | a spa_ringbuffer
  index | new index

References spa_ringbuffer::readindex.

## ◆ spa_ringbuffer_set_avail()

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

Sets the pointers so that the ringbuffer contains size bytes.

Parameters

  rbuf | a spa_ringbuffer
  size | the target size of rbuf

References spa_ringbuffer::readindex, and spa_ringbuffer::writeindex.

## ◆ spa_ringbuffer_write_data()

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

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

References spa_memcpy, SPA_MIN, SPA_PTROFF, and SPA_UNLIKELY.

## ◆ spa_ringbuffer_write_update()

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

Update the write pointer to index.

Parameters

  rbuf | a spa_ringbuffer
  index | new index

References spa_ringbuffer::writeindex.

## ◆ spa_scnprintf()

int spa_scnprintf | ( | char * | buffer,
|  | size_t | size,
|  | const char * | format,
|  |  | ...
| ) |  |
| inline

References spa_vscnprintf().

Referenced by get_pending_save(), get_saved_headset_profile(), get_saved_profile(), set_pending_save(), set_saved_headset_profile(), and set_saved_profile().

## ◆ spa_strendswith()

bool spa_strendswith | ( | const char * | s,
|  | const char * | suffix
| ) |  |
| inline

Returns
  true if s ends with the suffix or false otherwise. A s is NULL, it never ends with the given suffix. A suffix of NULL is a bug in the caller.

References spa_assert_se, spa_streq(), and SPA_UNLIKELY.

## ◆ spa_streq()

bool spa_streq | ( | const char * | s1,
|  | const char * | s2
| ) |  |
| inline

Returns
  true if the two strings are equal, false otherwise

If both a and b are NULL, the two are considered equal.

References SPA_LIKELY.

Referenced by pipewire__module_init(), pw_check_option(), pw_context_find_export_type(), pw_context_find_factory(), pw_context_find_protocol(), pw_context_parse_conf_section(), pw_global_is_type(), pw_protocol_get_marshal(), sm_media_session_match_rules(), spa_atob(), and spa_strendswith().

## ◆ spa_strneq()

bool spa_strneq | ( | const char * | s1,
|  | const char * | s2,
|  | size_t | len
| ) |  |
| inline

Returns
  true if the two strings are equal, false otherwise

If both a and b are NULL, the two are considered equal.

References SPA_LIKELY.

## ◆ spa_strstartswith()

bool spa_strstartswith | ( | const char * | s,
|  | const char * | prefix
| ) |  |
| inline

Returns
  true if s starts with the prefix or false otherwise. A s is NULL, it never starts with the given prefix. A prefix of NULL is a bug in the caller.

References spa_assert_se, and SPA_UNLIKELY.

## ◆ spa_vscnprintf()

int spa_vscnprintf | ( | char * | buffer,
|  | size_t | size,
|  | const char * | format,
|  | va_list | args
| ) |  |
| inline

References spa_assert_se, SPA_LIKELY, and SPA_UNLIKELY.

Referenced by spa_scnprintf().