116#define SPA_CALLBACK_VERSION_MIN(c,v) ((c) && ((v) == 0 || (c)->version > (v)-1))
119#define SPA_CALLBACK_CHECK(c,m,v) (SPA_CALLBACK_VERSION_MIN(c,v) && (c)->m)
125#define SPA_CALLBACKS_INIT(_funcs,_data) ((struct spa_callbacks){ (_funcs), (_data), })
148#define SPA_INTERFACE_INIT(_type,_version,_funcs,_data) \
149 ((struct spa_interface){ (_type), (_version), SPA_CALLBACKS_INIT(_funcs,_data), })
156#define spa_callbacks_call(callbacks,type,method,vers,...) \
158 const type *_f = (const type *) (callbacks)->funcs; \
159 bool _res = SPA_CALLBACK_CHECK(_f,method,vers); \
160 if (SPA_LIKELY(_res)) \
161 _f->method((callbacks)->data, ## __VA_ARGS__); \
165#define spa_callbacks_call_fast(callbacks,type,method,vers,...) \
167 const type *_f = (const type *) (callbacks)->funcs; \
168 _f->method((callbacks)->data, ## __VA_ARGS__); \
176#define spa_callback_version_min(callbacks,type,vers) \
178 const type *_f = (const type *) (callbacks)->funcs; \
179 SPA_CALLBACK_VERSION_MIN(_f,vers); \
186#define spa_callback_check(callbacks,type,method,vers) \
188 const type *_f = (const type *) (callbacks)->funcs; \
189 SPA_CALLBACK_CHECK(_f,method,vers); \
198#define spa_callbacks_call_res(callbacks,type,res,method,vers,...) \
200 const type *_f = (const type *) (callbacks)->funcs; \
201 if (SPA_LIKELY(SPA_CALLBACK_CHECK(_f,method,vers))) \
202 res = _f->method((callbacks)->data, ## __VA_ARGS__); \
205#define spa_callbacks_call_fast_res(callbacks,type,res,method,vers,...) \
207 const type *_f = (const type *) (callbacks)->funcs; \
208 res = _f->method((callbacks)->data, ## __VA_ARGS__); \
214#define spa_interface_callback_version_min(iface,method_type,vers) \
215 spa_callback_version_min(&(iface)->cb, method_type, vers)
221#define spa_interface_callback_check(iface,method_type,method,vers) \
222 spa_callback_check(&(iface)->cb, method_type, method, vers)
229#define spa_interface_call(iface,method_type,method,vers,...) \
230 spa_callbacks_call(&(iface)->cb,method_type,method,vers,##__VA_ARGS__)
232#define spa_interface_call_fast(iface,method_type,method,vers,...) \
233 spa_callbacks_call_fast(&(iface)->cb,method_type,method,vers,##__VA_ARGS__)
242#define spa_interface_call_res(iface,method_type,res,method,vers,...) \
243 spa_callbacks_call_res(&(iface)->cb,method_type,res,method,vers,##__VA_ARGS__)
245#define spa_interface_call_fast_res(iface,method_type,res,method,vers,...) \
246 spa_callbacks_call_fast_res(&(iface)->cb,method_type,res,method,vers,##__VA_ARGS__)
364 const void *funcs,
void *data)
374 const void *funcs,
void *data)
402 const void *funcs,
void *data)
419#define spa_hook_list_call_simple(l,type,method,vers,...) \
421 struct spa_hook_list *_l = l; \
422 struct spa_hook *_h, *_t; \
423 spa_list_for_each_safe(_h, _t, &_l->list, link) \
424 spa_callbacks_call(&_h->cb,type,method,vers, ## __VA_ARGS__); \
430#define spa_hook_list_do_call(l,start,type,method,vers,once,...) \
432 struct spa_hook_list *_list = l; \
433 struct spa_list *_s = start ? (struct spa_list *)start : &_list->list; \
434 struct spa_hook _cursor = { 0 }, *_ci; \
436 spa_list_cursor_start(_cursor, _s, link); \
437 spa_list_for_each_cursor(_ci, _cursor, &_list->list, link) { \
438 if (spa_callbacks_call(&_ci->cb,type,method,vers, ## __VA_ARGS__)) { \
444 spa_list_cursor_end(_cursor, link); \
452#define spa_hook_list_call(l,t,m,v,...) spa_hook_list_do_call(l,NULL,t,m,v,false,##__VA_ARGS__)
458#define spa_hook_list_call_once(l,t,m,v,...) spa_hook_list_do_call(l,NULL,t,m,v,true,##__VA_ARGS__)
460#define spa_hook_list_call_start(l,s,t,m,v,...) spa_hook_list_do_call(l,s,t,m,v,false,##__VA_ARGS__)
461#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__)
static bool spa_hook_list_is_empty(struct spa_hook_list *list)
Definition hook.h:365
static void spa_hook_list_append(struct spa_hook_list *list, struct spa_hook *hook, const void *funcs, void *data)
Append a hook.
Definition hook.h:371
static void spa_hook_list_join(struct spa_hook_list *list, struct spa_hook_list *save)
Definition hook.h:422
static void spa_hook_list_init(struct spa_hook_list *list)
Initialize a hook list to the empty list.
Definition hook.h:360
static void spa_hook_remove(struct spa_hook *hook)
Remove a hook.
Definition hook.h:391
static void spa_hook_list_clean(struct spa_hook_list *list)
Remove all hooks from the list.
Definition hook.h:400
static void spa_hook_list_prepend(struct spa_hook_list *list, struct spa_hook *hook, const void *funcs, void *data)
Prepend a hook.
Definition hook.h:381
static void spa_hook_list_isolate(struct spa_hook_list *list, struct spa_hook_list *save, struct spa_hook *hook, const void *funcs, void *data)
Definition hook.h:408
#define SPA_CALLBACKS_INIT(_funcs, _data)
Initialize the set of functions funcs as a spa_callbacks, together with _data.
Definition hook.h:134
static int spa_list_is_initialized(struct spa_list *list)
Definition list.h:40
#define spa_list_consume(pos, head, member)
Definition list.h:92
static void spa_list_init(struct spa_list *list)
Definition list.h:35
static void spa_list_remove(struct spa_list *elem)
Definition list.h:65
#define spa_list_prepend(list, item)
Definition list.h:80
#define spa_list_is_empty(l)
Definition list.h:45
#define spa_list_append(list, item)
Definition list.h:77
static void spa_list_insert_list(struct spa_list *list, struct spa_list *other)
Definition list.h:55
#define spa_zero(x)
Definition defs.h:483
Callbacks, contains the structure with functions and the data passed to the functions.
Definition hook.h:116
const void * funcs
Definition hook.h:117
void * data
Definition hook.h:118
A list of hooks.
Definition hook.h:339
struct spa_list list
Definition hook.h:340
A hook, contains the structure with functions and the data passed to the functions.
Definition hook.h:350
void(* removed)(struct spa_hook *hook)
callback and data for the hook list, private to the hook_list implementor
Definition hook.h:355
struct spa_callbacks cb
Definition hook.h:352
struct spa_list link
Definition hook.h:351
void * priv
Definition hook.h:356
uint32_t version
Definition hook.h:140
const char * type
Definition hook.h:139
struct spa_callbacks cb
Definition hook.h:141