61 #define SPA_CALLBACK_CHECK(c,m,v) ((c) && ((v) == 0 || (c)->version > (v)-1) && (c)->m)
63 #define SPA_CALLBACKS_INIT(_funcs,_data) (struct spa_callbacks){ _funcs, _data, }
71 #define SPA_INTERFACE_INIT(_type,_version,_funcs,_data) \
72 (struct spa_interface){ _type, _version, SPA_CALLBACKS_INIT(_funcs,_data), }
99 const void *funcs,
void *
data)
109 const void *funcs,
void *
data)
135 const void *funcs,
void *
data)
152 #define spa_callbacks_call(callbacks,type,method,vers,...) \
154 const type *_f = (const type *) (callbacks)->funcs; \
155 if (SPA_LIKELY(SPA_CALLBACK_CHECK(_f,method,vers))) \
156 _f->method((callbacks)->data, ## __VA_ARGS__); \
159 #define spa_callbacks_call_res(callbacks,type,res,method,vers,...) \
161 const type *_f = (const type *) (callbacks)->funcs; \
162 if (SPA_LIKELY(SPA_CALLBACK_CHECK(_f,method,vers))) \
163 res = _f->method((callbacks)->data, ## __VA_ARGS__); \
167 #define spa_interface_call(iface,type,method,vers,...) \
168 spa_callbacks_call(&(iface)->cb,type,method,vers,##__VA_ARGS__)
170 #define spa_interface_call_res(iface,type,res,method,vers,...) \
171 spa_callbacks_call_res(&(iface)->cb,type,res,method,vers,##__VA_ARGS__)
173 #define spa_hook_list_call_simple(l,type,method,vers,...) \
175 struct spa_hook_list *_l = l; \
176 struct spa_hook *_h, *_t; \
177 spa_list_for_each_safe(_h, _t, &_l->list, link) \
178 spa_callbacks_call(&_h->cb,type,method,vers, ## __VA_ARGS__); \
184 #define spa_hook_list_do_call(l,start,type,method,vers,once,...) \
186 struct spa_hook_list *list = l; \
187 struct spa_list *s = start ? (struct spa_list *)start : &list->list; \
188 struct spa_hook cursor = { 0 }, *ci; \
190 spa_list_cursor_start(cursor, s, link); \
191 spa_list_for_each_cursor(ci, cursor, &list->list, link) { \
192 const type *_f = (const type *)ci->cb.funcs; \
193 if (SPA_LIKELY(SPA_CALLBACK_CHECK(_f,method,vers))) { \
194 _f->method(ci->cb.data, ## __VA_ARGS__); \
200 spa_list_cursor_end(cursor, link); \
204 #define spa_hook_list_call(l,t,m,v,...) spa_hook_list_do_call(l,NULL,t,m,v,false,##__VA_ARGS__)
205 #define spa_hook_list_call_once(l,t,m,v,...) spa_hook_list_do_call(l,NULL,t,m,v,true,##__VA_ARGS__)
207 #define spa_hook_list_call_start(l,s,t,m,v,...) spa_hook_list_do_call(l,s,t,m,v,false,##__VA_ARGS__)
208 #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__)
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:132
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:107
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:97
void spa_hook_list_init(struct spa_hook_list *list)
Initialize a hook list.
Definition: hook.h:86
#define SPA_CALLBACKS_INIT(_funcs, _data)
Definition: hook.h:63
bool spa_hook_list_is_empty(struct spa_hook_list *list)
Definition: hook.h:91
void spa_hook_remove(struct spa_hook *hook)
Remove a hook.
Definition: hook.h:117
void spa_hook_list_join(struct spa_hook_list *list, struct spa_hook_list *save)
Definition: hook.h:146
void spa_hook_list_clean(struct spa_hook_list *list)
Definition: hook.h:124
void spa_list_init(struct spa_list *list)
Definition: list.h:44
#define spa_zero(x)
Definition: defs.h:288
void spa_list_insert_list(struct spa_list *list, struct spa_list *other)
Definition: list.h:59
#define spa_list_consume(pos, head, member)
Definition: list.h:96
void spa_list_remove(struct spa_list *elem)
Definition: list.h:69
#define spa_list_prepend(list, item)
Definition: list.h:84
#define spa_list_is_empty(l)
Definition: list.h:49
#define spa_list_append(list, item)
Definition: list.h:81
Callbacks, contains the structure with functions and the data passed to the functions.
Definition: hook.h:55
const void * funcs
Definition: hook.h:56
void * data
Definition: hook.h:57
A list of hooks.
Definition: hook.h:48
struct spa_list list
Definition: hook.h:49
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:76
void(* removed)(struct spa_hook *hook)
callback and data for the hook list, private to the hook_list implementor
Definition: hook.h:81
struct spa_callbacks cb
Definition: hook.h:78
struct spa_list link
Definition: hook.h:77
void * priv
Definition: hook.h:82
uint32_t version
Definition: hook.h:67
const char * type
Definition: hook.h:66
struct spa_callbacks cb
Definition: hook.h:68