PipeWire  0.3.30
SPA Hooks

a list of hooks More...

Data Structures

struct  spa_hook_list
 A list of hooks. More...
 
struct  spa_callbacks
 Callbacks, contains the structure with functions and the data passed to the functions. More...
 
struct  spa_interface
 
struct  spa_hook
 A hook, contains the structure with functions and the data passed to the functions. More...
 

Macros

#define SPA_CALLBACK_CHECK(c, m, v)   ((c) && ((v) == 0 || (c)->version > (v)-1) && (c)->m)
 Check if a callback c has method m of version v. More...
 
#define SPA_CALLBACKS_INIT(_funcs, _data)   (struct spa_callbacks){ _funcs, _data, }
 
#define SPA_INTERFACE_INIT(_type, _version, _funcs, _data)    (struct spa_interface){ _type, _version, SPA_CALLBACKS_INIT(_funcs,_data), }
 
#define spa_callbacks_call(callbacks, type, method, vers, ...)
 
#define spa_callbacks_call_res(callbacks, type, res, method, vers, ...)
 
#define spa_interface_call(iface, type, method, vers, ...)    spa_callbacks_call(&(iface)->cb,type,method,vers,##__VA_ARGS__)
 
#define spa_interface_call_res(iface, type, res, method, vers, ...)    spa_callbacks_call_res(&(iface)->cb,type,res,method,vers,##__VA_ARGS__)
 
#define spa_hook_list_call_simple(l, type, method, vers, ...)
 
#define spa_hook_list_do_call(l, start, type, method, vers, once, ...)
 Call all hooks in a list, starting from the given one and optionally stopping after calling the first non-NULL function, returns the number of methods called. More...
 
#define spa_hook_list_call(l, t, m, v, ...)   spa_hook_list_do_call(l,NULL,t,m,v,false,##__VA_ARGS__)
 
#define spa_hook_list_call_once(l, t, m, v, ...)   spa_hook_list_do_call(l,NULL,t,m,v,true,##__VA_ARGS__)
 
#define spa_hook_list_call_start(l, s, t, m, v, ...)   spa_hook_list_do_call(l,s,t,m,v,false,##__VA_ARGS__)
 
#define spa_hook_list_call_once_start(l, s, t, m, v, ...)   spa_hook_list_do_call(l,s,t,m,v,true,##__VA_ARGS__)
 

Functions

void spa_hook_list_init (struct spa_hook_list *list)
 Initialize a hook list. More...
 
bool spa_hook_list_is_empty (struct spa_hook_list *list)
 
void spa_hook_list_append (struct spa_hook_list *list, struct spa_hook *hook, const void *funcs, void *data)
 Append a hook. More...
 
void spa_hook_list_prepend (struct spa_hook_list *list, struct spa_hook *hook, const void *funcs, void *data)
 Prepend a hook. More...
 
void spa_hook_remove (struct spa_hook *hook)
 Remove a hook. More...
 
void spa_hook_list_clean (struct spa_hook_list *list)
 
void spa_hook_list_isolate (struct spa_hook_list *list, struct spa_hook_list *save, struct spa_hook *hook, const void *funcs, void *data)
 
void spa_hook_list_join (struct spa_hook_list *list, struct spa_hook_list *save)
 

Detailed Description

a list of hooks

The hook list provides a way to keep track of hooks.

Macro Definition Documentation

◆ SPA_CALLBACK_CHECK

#define SPA_CALLBACK_CHECK (   c,
  m,
 
)    ((c) && ((v) == 0 || (c)->version > (v)-1) && (c)->m)

Check if a callback c has method m of version v.

◆ spa_callbacks_call

#define spa_callbacks_call (   callbacks,
  type,
  method,
  vers,
  ... 
)
Value:
({ \
const type *_f = (const type *) (callbacks)->funcs; \
if (SPA_LIKELY(SPA_CALLBACK_CHECK(_f,method,vers))) \
_f->method((callbacks)->data, ## __VA_ARGS__); \
})

◆ spa_callbacks_call_res

#define spa_callbacks_call_res (   callbacks,
  type,
  res,
  method,
  vers,
  ... 
)
Value:
({ \
const type *_f = (const type *) (callbacks)->funcs; \
if (SPA_LIKELY(SPA_CALLBACK_CHECK(_f,method,vers))) \
res = _f->method((callbacks)->data, ## __VA_ARGS__); \
res; \
})

◆ SPA_CALLBACKS_INIT

#define SPA_CALLBACKS_INIT (   _funcs,
  _data 
)    (struct spa_callbacks){ _funcs, _data, }

◆ spa_hook_list_call

#define spa_hook_list_call (   l,
  t,
  m,
  v,
  ... 
)    spa_hook_list_do_call(l,NULL,t,m,v,false,##__VA_ARGS__)

◆ spa_hook_list_call_once

#define spa_hook_list_call_once (   l,
  t,
  m,
  v,
  ... 
)    spa_hook_list_do_call(l,NULL,t,m,v,true,##__VA_ARGS__)

◆ spa_hook_list_call_once_start

#define spa_hook_list_call_once_start (   l,
  s,
  t,
  m,
  v,
  ... 
)    spa_hook_list_do_call(l,s,t,m,v,true,##__VA_ARGS__)

◆ spa_hook_list_call_simple

#define spa_hook_list_call_simple (   l,
  type,
  method,
  vers,
  ... 
)
Value:
({ \
struct spa_hook_list *_l = l; \
struct spa_hook *_h, *_t; \
spa_list_for_each_safe(_h, _t, &_l->list, link) \
spa_callbacks_call(&_h->cb,type,method,vers, ## __VA_ARGS__); \
})

◆ spa_hook_list_call_start

#define spa_hook_list_call_start (   l,
  s,
  t,
  m,
  v,
  ... 
)    spa_hook_list_do_call(l,s,t,m,v,false,##__VA_ARGS__)

◆ spa_hook_list_do_call

#define spa_hook_list_do_call (   l,
  start,
  type,
  method,
  vers,
  once,
  ... 
)
Value:
({ \
struct spa_hook_list *list = l; \
struct spa_list *s = start ? (struct spa_list *)start : &list->list; \
struct spa_hook cursor = { 0 }, *ci; \
int count = 0; \
spa_list_cursor_start(cursor, s, link); \
spa_list_for_each_cursor(ci, cursor, &list->list, link) { \
const type *_f = (const type *)ci->cb.funcs; \
if (SPA_LIKELY(SPA_CALLBACK_CHECK(_f,method,vers))) { \
_f->method(ci->cb.data, ## __VA_ARGS__); \
count++; \
if (once) \
break; \
} \
} \
spa_list_cursor_end(cursor, link); \
count; \
})

Call all hooks in a list, starting from the given one and optionally stopping after calling the first non-NULL function, returns the number of methods called.

◆ spa_interface_call

#define spa_interface_call (   iface,
  type,
  method,
  vers,
  ... 
)     spa_callbacks_call(&(iface)->cb,type,method,vers,##__VA_ARGS__)

◆ spa_interface_call_res

#define spa_interface_call_res (   iface,
  type,
  res,
  method,
  vers,
  ... 
)     spa_callbacks_call_res(&(iface)->cb,type,res,method,vers,##__VA_ARGS__)

◆ SPA_INTERFACE_INIT

#define SPA_INTERFACE_INIT (   _type,
  _version,
  _funcs,
  _data 
)     (struct spa_interface){ _type, _version, SPA_CALLBACKS_INIT(_funcs,_data), }

Function Documentation

◆ spa_hook_list_append()

◆ spa_hook_list_clean()

◆ spa_hook_list_init()

◆ spa_hook_list_is_empty()

bool spa_hook_list_is_empty ( struct spa_hook_list list)
inline

◆ spa_hook_list_isolate()

void spa_hook_list_isolate ( struct spa_hook_list list,
struct spa_hook_list save,
struct spa_hook hook,
const void *  funcs,
void *  data 
)
inline

◆ spa_hook_list_join()

void spa_hook_list_join ( struct spa_hook_list list,
struct spa_hook_list save 
)
inline

◆ spa_hook_list_prepend()

void spa_hook_list_prepend ( struct spa_hook_list list,
struct spa_hook hook,
const void *  funcs,
void *  data 
)
inline

◆ spa_hook_remove()

data
Definition: filter.c:75
spa_list
Definition: list.h:37
SPA_LIKELY
#define SPA_LIKELY(x)
Definition: defs.h:234
if
if(basename) basename+
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:76
SPA_CALLBACK_CHECK
#define SPA_CALLBACK_CHECK(c, m, v)
Check if a callback c has method m of version v.
Definition: hook.h:61
spa_hook_list
A list of hooks.
Definition: hook.h:48