PipeWire 1.2.6
Loading...
Searching...
No Matches
Miscellaneous

Helper macros and functions More...

Files

file  defs.h
 spa/utils/defs.h
 

Data Structures

struct  spa_rectangle
 
struct  spa_point
 
struct  spa_region
 
struct  spa_fraction
 
struct  spa_error_location
 

Enumerations

enum  spa_direction { SPA_DIRECTION_INPUT = 0 , SPA_DIRECTION_OUTPUT = 1 }
 

Macros

#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.
 
#define SPA_FLAG_MASK(field, mask, flag)
 
#define SPA_FLAG_IS_SET(field, flag)
 
#define SPA_FLAG_SET(field, flag)
 
#define SPA_FLAG_CLEAR(field, flag)
 
#define SPA_FLAG_UPDATE(field, flag, val)
 
#define SPA_DIRECTION_REVERSE(d)
 
#define SPA_RECTANGLE(width, height)
 
#define SPA_POINT(x, y)
 
#define SPA_REGION(x, y, width, height)
 
#define SPA_FRACTION(num, denom)
 
#define SPA_N_ELEMENTS(arr)
 
#define SPA_FOR_EACH_ELEMENT(arr, ptr)
 Array iterator macro.
 
#define SPA_FOR_EACH_ELEMENT_VAR(arr, var)
 
#define SPA_ABS(a)
 
#define SPA_MIN(a, b)
 
#define SPA_MAX(a, b)
 
#define SPA_CLAMP(v, low, high)
 
#define SPA_CLAMPF(v, low, high)
 
#define SPA_CLAMPD(v, low, high)
 
#define SPA_SWAP(a, b)
 
#define SPA_TYPECHECK(type, x)
 
#define SPA_CMP(a, b)
 3-way comparison.
 
#define SPA_PTROFF(ptr_, offset_, type_)
 Return the address (buffer + offset) as pointer of type.
 
#define SPA_PTROFF_ALIGN(ptr_, offset_, alignment_, type_)
 
#define SPA_MEMBER(b, o, t)
 Deprecated, use SPA_PTROFF and SPA_PTROFF_ALIGN instead.
 
#define SPA_MEMBER_ALIGN(b, o, a, t)
 
#define SPA_CONTAINER_OF(p, t, m)
 
#define SPA_PTRDIFF(p1, p2)
 
#define SPA_PTR_TO_UINT32(p)
 
#define SPA_UINT32_TO_PTR(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)
 
#define SPA_TIMESPEC_TO_USEC(ts)
 
#define SPA_TIMEVAL_TO_NSEC(tv)
 
#define SPA_TIMEVAL_TO_USEC(tv)
 
#define SPA_PRINTF_FUNC(fmt, arg1)
 
#define SPA_FORMAT_ARG_FUNC(arg1)
 
#define SPA_ALIGNED(align)
 
#define SPA_DEPRECATED
 
#define SPA_EXPORT
 
#define SPA_SENTINEL
 
#define SPA_UNUSED
 
#define SPA_NORETURN
 
#define SPA_WARN_UNUSED_RESULT
 
#define SPA_RESTRICT
 
#define SPA_ROUND_DOWN(num, value)
 
#define SPA_ROUND_UP(num, value)
 
#define SPA_ROUND_MASK(num, mask)
 
#define SPA_ROUND_DOWN_N(num, align)
 
#define SPA_ROUND_UP_N(num, align)
 
#define SPA_SCALE32_UP(val, num, denom)
 
#define SPA_PTR_ALIGNMENT(p, align)
 
#define SPA_IS_ALIGNED(p, align)
 
#define SPA_PTR_ALIGN(p, align, type)
 
#define SPA_LIKELY(x)
 
#define SPA_UNLIKELY(x)
 
#define spa_ptr_type_inside(p1, s1, p2, type, remaining)
 
#define SPA_PTR_TO_INT(p)
 
#define SPA_INT_TO_PTR(u)
 
#define SPA_STRINGIFY_1(...)
 
#define SPA_STRINGIFY(...)
 
#define spa_return_if_fail(expr)
 
#define spa_return_val_if_fail(expr, val)
 
#define spa_assert_se(expr)
 
#define spa_nop()
 
#define spa_assert(expr)
 
#define spa_assert_not_reached()
 
#define spa_memzero(x, l)
 
#define spa_zero(x)
 
#define spa_memcpy(d, s, n)
 
#define spa_memmove(d, s, n)
 
#define spa_aprintf(_fmt, ...)
 

Functions

static bool spa_ptrinside (const void *p1, size_t s1, const void *p2, size_t s2, size_t *remaining)
 
static bool spa_ptr_inside_and_aligned (const void *p1, size_t s1, const void *p2, size_t s2, size_t align, size_t *remaining)
 

Detailed Description

Helper macros and functions

Enumeration Type Documentation

◆ spa_direction

Enumerator
SPA_DIRECTION_INPUT 
SPA_DIRECTION_OUTPUT 

Macro Definition Documentation

◆ 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_MASK

#define SPA_FLAG_MASK ( field,
mask,
flag )
Value:
(((field) & (mask)) == (flag))

◆ SPA_FLAG_IS_SET

#define SPA_FLAG_IS_SET ( field,
flag )
Value:
SPA_FLAG_MASK(field, flag, flag)
#define SPA_FLAG_MASK(field, mask, flag)
Definition defs.h:88

◆ SPA_FLAG_SET

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

◆ SPA_FLAG_CLEAR

#define SPA_FLAG_CLEAR ( field,
flag )

◆ SPA_FLAG_UPDATE

#define SPA_FLAG_UPDATE ( field,
flag,
val )
Value:
((val) ? SPA_FLAG_SET((field),(flag)) : SPA_FLAG_CLEAR((field),(flag)))
#define SPA_FLAG_SET(field, flag)
Definition defs.h:93
#define SPA_FLAG_CLEAR(field, flag)
Definition defs.h:94

◆ SPA_DIRECTION_REVERSE

#define SPA_DIRECTION_REVERSE ( d)
Value:
((d) ^ 1)

◆ SPA_RECTANGLE

#define SPA_RECTANGLE ( width,
height )

◆ SPA_POINT

#define SPA_POINT ( x,
y )
Value:
((struct spa_point){ (x), (y) })
Definition defs.h:123
int32_t y
Definition defs.h:125
int32_t x
Definition defs.h:124
Examples
video-dsp-src.c, video-src-alloc.c, video-src-fixate.c, video-src-reneg.c, and video-src.c.

◆ SPA_REGION

#define SPA_REGION ( x,
y,
width,
height )
Value:
((struct spa_region){ SPA_POINT(x,y), SPA_RECTANGLE(width,height) })
#define SPA_POINT(x, y)
Definition defs.h:122
#define SPA_RECTANGLE(width, height)
Definition defs.h:115
Definition defs.h:130
Examples
video-dsp-src.c, video-src-alloc.c, video-src-fixate.c, video-src-reneg.c, and video-src.c.

◆ SPA_FRACTION

#define SPA_FRACTION ( num,
denom )

◆ SPA_N_ELEMENTS

#define SPA_N_ELEMENTS ( arr)
Value:
(sizeof(arr) / sizeof((arr)[0]))
Examples
midi-src.c.

◆ SPA_FOR_EACH_ELEMENT

#define SPA_FOR_EACH_ELEMENT ( arr,
ptr )
Value:
for ((ptr) = arr; (void*)(ptr) < SPA_PTROFF(arr, sizeof(arr), void); (ptr)++)
#define SPA_PTROFF(ptr_, offset_, type_)
Return the address (buffer + offset) as pointer of type.
Definition defs.h:222

Array iterator macro.

Usage:

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

◆ SPA_FOR_EACH_ELEMENT_VAR

#define SPA_FOR_EACH_ELEMENT_VAR ( arr,
var )
Value:
for (__typeof__((arr)[0])* var = arr; (void*)(var) < SPA_PTROFF(arr, sizeof(arr), void); (var)++)

◆ SPA_ABS

#define SPA_ABS ( a)

◆ SPA_MIN

◆ SPA_MAX

#define SPA_MAX ( a,
b )

◆ SPA_CLAMP

#define SPA_CLAMP ( v,
low,
high )

◆ SPA_CLAMPF

#define SPA_CLAMPF ( v,
low,
high )
Examples
audio-capture.c.

◆ SPA_CLAMPD

#define SPA_CLAMPD ( v,
low,
high )

◆ SPA_SWAP

#define SPA_SWAP ( a,
b )

◆ SPA_TYPECHECK

#define SPA_TYPECHECK ( type,
x )

◆ SPA_CMP

#define SPA_CMP ( a,
b )

3-way comparison.

NaN > NaN and NaN > finite numbers

◆ SPA_PTROFF

#define SPA_PTROFF ( ptr_,
offset_,
type_ )
Value:
((type_*)((uintptr_t)(ptr_) + (ptrdiff_t)(offset_)))

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

Examples
export-source.c, video-dsp-src.c, video-play-pull.c, video-play.c, video-src-alloc.c, video-src-fixate.c, video-src-reneg.c, and video-src.c.

◆ SPA_PTROFF_ALIGN

#define SPA_PTROFF_ALIGN ( ptr_,
offset_,
alignment_,
type_ )
Value:
SPA_PTR_ALIGN(SPA_PTROFF(ptr_,offset_,type_),alignment_,type_)
#define SPA_PTR_ALIGN(p, align, type)
Definition defs.h:357

◆ SPA_MEMBER

#define SPA_MEMBER ( b,
o,
t )
Value:
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 )
Value:
#define SPA_PTROFF_ALIGN(ptr_, offset_, alignment_, type_)
Definition defs.h:223

◆ SPA_CONTAINER_OF

#define SPA_CONTAINER_OF ( p,
t,
m )
Value:
((t*)((uintptr_t)(p) - offsetof(t,m)))

◆ SPA_PTRDIFF

#define SPA_PTRDIFF ( p1,
p2 )
Value:
((intptr_t)(p1) - (intptr_t)(p2))

◆ SPA_PTR_TO_UINT32

#define SPA_PTR_TO_UINT32 ( p)
Value:
((uint32_t) ((uintptr_t) (p)))

◆ SPA_UINT32_TO_PTR

#define SPA_UINT32_TO_PTR ( u)
Value:
((void*) ((uintptr_t) (u)))

◆ SPA_TIME_INVALID

#define SPA_TIME_INVALID   ((int64_t)INT64_MIN)

◆ SPA_IDX_INVALID

#define SPA_IDX_INVALID   ((unsigned int)-1)

◆ SPA_ID_INVALID

#define SPA_ID_INVALID   ((uint32_t)0xffffffff)

◆ SPA_NSEC_PER_SEC

#define SPA_NSEC_PER_SEC   (1000000000LL)
Examples
midi-src.c.

◆ SPA_NSEC_PER_MSEC

◆ SPA_NSEC_PER_USEC

#define SPA_NSEC_PER_USEC   (1000ll)

◆ SPA_USEC_PER_SEC

#define SPA_USEC_PER_SEC   (1000000ll)

◆ SPA_USEC_PER_MSEC

#define SPA_USEC_PER_MSEC   (1000ll)

◆ SPA_MSEC_PER_SEC

#define SPA_MSEC_PER_SEC   (1000ll)

◆ SPA_TIMESPEC_TO_NSEC

#define SPA_TIMESPEC_TO_NSEC ( ts)
Value:
((ts)->tv_sec * SPA_NSEC_PER_SEC + (ts)->tv_nsec)
#define SPA_NSEC_PER_SEC
Definition defs.h:253

◆ SPA_TIMESPEC_TO_USEC

#define SPA_TIMESPEC_TO_USEC ( ts)
Value:
((ts)->tv_sec * SPA_USEC_PER_SEC + (ts)->tv_nsec / SPA_NSEC_PER_USEC)
#define SPA_NSEC_PER_USEC
Definition defs.h:257
#define SPA_USEC_PER_SEC
Definition defs.h:259

◆ SPA_TIMEVAL_TO_NSEC

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

◆ SPA_TIMEVAL_TO_USEC

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

◆ SPA_PRINTF_FUNC

#define SPA_PRINTF_FUNC ( fmt,
arg1 )

◆ SPA_FORMAT_ARG_FUNC

#define SPA_FORMAT_ARG_FUNC ( arg1)

◆ SPA_ALIGNED

#define SPA_ALIGNED ( align)

◆ SPA_DEPRECATED

#define SPA_DEPRECATED

◆ SPA_EXPORT

#define SPA_EXPORT

◆ SPA_SENTINEL

#define SPA_SENTINEL

◆ SPA_UNUSED

#define SPA_UNUSED

◆ SPA_NORETURN

#define SPA_NORETURN

◆ SPA_WARN_UNUSED_RESULT

#define SPA_WARN_UNUSED_RESULT

◆ SPA_RESTRICT

#define SPA_RESTRICT

◆ SPA_ROUND_DOWN

#define SPA_ROUND_DOWN ( num,
value )

◆ SPA_ROUND_UP

#define SPA_ROUND_UP ( num,
value )

◆ SPA_ROUND_MASK

#define SPA_ROUND_MASK ( num,
mask )
Value:
((__typeof__(num))((mask)-1))

◆ SPA_ROUND_DOWN_N

#define SPA_ROUND_DOWN_N ( num,
align )
Value:
((num) & ~SPA_ROUND_MASK(num, align))

◆ SPA_ROUND_UP_N

#define SPA_ROUND_UP_N ( num,
align )
Value:
((((num)-1) | SPA_ROUND_MASK(num, align))+1)
#define SPA_ROUND_MASK(num, mask)
Definition defs.h:337
Examples
video-dsp-src.c, video-src-alloc.c, video-src-fixate.c, video-src-reneg.c, and video-src.c.

◆ SPA_SCALE32_UP

#define SPA_SCALE32_UP ( val,
num,
denom )

◆ SPA_PTR_ALIGNMENT

#define SPA_PTR_ALIGNMENT ( p,
align )
Value:
((uintptr_t)(p) & ((align)-1))

◆ SPA_IS_ALIGNED

#define SPA_IS_ALIGNED ( p,
align )
Value:
(SPA_PTR_ALIGNMENT(p,align) == 0)
#define SPA_PTR_ALIGNMENT(p, align)
Definition defs.h:353

◆ SPA_PTR_ALIGN

#define SPA_PTR_ALIGN ( p,
align,
type )
Value:
((type*)SPA_ROUND_UP_N((intptr_t)(p), (intptr_t)(align)))
#define SPA_ROUND_UP_N(num, align)
Definition defs.h:342

◆ SPA_LIKELY

#define SPA_LIKELY ( x)
Value:
(x)

◆ SPA_UNLIKELY

#define SPA_UNLIKELY ( x)
Value:
(x)

◆ spa_ptr_type_inside

#define spa_ptr_type_inside ( p1,
s1,
p2,
type,
remaining )
Value:
spa_ptr_inside_and_aligned(p1, s1, p2, sizeof(type), SPA_ALIGNOF(type), remaining)
#define SPA_ALIGNOF
Definition defs.h:35
static bool spa_ptr_inside_and_aligned(const void *p1, size_t s1, const void *p2, size_t s2, size_t align, size_t *remaining)
Definition defs.h:388

◆ SPA_PTR_TO_INT

#define SPA_PTR_TO_INT ( p)
Value:
((int) ((intptr_t) (p)))

◆ SPA_INT_TO_PTR

#define SPA_INT_TO_PTR ( u)
Value:
((void*) ((intptr_t) (u)))

◆ SPA_STRINGIFY_1

#define SPA_STRINGIFY_1 ( ...)
Value:
#__VA_ARGS__

◆ SPA_STRINGIFY

#define SPA_STRINGIFY ( ...)
Value:
SPA_STRINGIFY_1(__VA_ARGS__)
#define SPA_STRINGIFY_1(...)
Definition defs.h:410

◆ spa_return_if_fail

#define spa_return_if_fail ( expr)

◆ spa_return_val_if_fail

#define spa_return_val_if_fail ( expr,
val )

◆ spa_assert_se

#define spa_assert_se ( expr)

◆ spa_nop

#define spa_nop ( )
Value:
do {} while (false)

◆ spa_assert

#define spa_assert ( expr)
Value:
#define spa_assert_se(expr)
Definition defs.h:443
Examples
midi-src.c.

◆ spa_assert_not_reached

#define spa_assert_not_reached ( )

◆ spa_memzero

#define spa_memzero ( x,
l )
Value:
(memset((x), 0, (l)))

◆ spa_zero

#define spa_zero ( x)
Value:
(spa_memzero(&(x), sizeof(x)))
#define spa_memzero(x, l)
Definition defs.h:482
Examples
export-sink.c, export-source.c, spa/examples/adapter-control.c, tutorial2.c, and tutorial6.c.

◆ spa_memcpy

#define spa_memcpy ( d,
s,
n )
Value:
memcpy(d,s,n)

◆ spa_memmove

#define spa_memmove ( d,
s,
n )
Value:
memmove(d,s,n)

◆ spa_aprintf

Function Documentation

◆ spa_ptrinside()

static bool spa_ptrinside ( const void * p1,
size_t s1,
const void * p2,
size_t s2,
size_t * remaining )
inlinestatic

◆ spa_ptr_inside_and_aligned()

static bool spa_ptr_inside_and_aligned ( const void * p1,
size_t s1,
const void * p2,
size_t s2,
size_t align,
size_t * remaining )
inlinestatic