From 56acf766a5f38dad01528f20c518db927d165f70 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 5 Aug 2021 14:31:26 +1000 Subject: [PATCH] doc: split the spa_interfaces out as separate group from the spa_hooks --- spa/include/spa/utils/hook.h | 76 ++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 30 deletions(-) diff --git a/spa/include/spa/utils/hook.h b/spa/include/spa/utils/hook.h index ada7e23ee..f326452a3 100644 --- a/spa/include/spa/utils/hook.h +++ b/spa/include/spa/utils/hook.h @@ -32,23 +32,17 @@ extern "C" { #include #include -/** \defgroup spa_hook SPA Hooks +/** \defgroup spa_interface SPA Interfaces * - * \brief a list of hooks + * \brief Generic implementation of interfaces * - * The hook list provides a way to keep track of hooks. */ /** - * \addtogroup spa_hook + * \addtogroup spa_interface * \{ */ -/** A list of hooks */ -struct spa_hook_list { - struct spa_list list; -}; - /** Callbacks, contains the structure with functions and the data passed * to the functions. The structure should also contain a version field that * is checked. */ @@ -71,6 +65,49 @@ struct spa_interface { #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,...) \ +({ \ + const type *_f = (const type *) (callbacks)->funcs; \ + if (SPA_LIKELY(SPA_CALLBACK_CHECK(_f,method,vers))) \ + _f->method((callbacks)->data, ## __VA_ARGS__); \ +}) + +#define spa_callbacks_call_res(callbacks,type,res,method,vers,...) \ +({ \ + const type *_f = (const type *) (callbacks)->funcs; \ + if (SPA_LIKELY(SPA_CALLBACK_CHECK(_f,method,vers))) \ + res = _f->method((callbacks)->data, ## __VA_ARGS__); \ + res; \ +}) + +#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__) + +/** + * \} + */ + +/** \defgroup spa_hook SPA Hooks + * + * \brief a list of hooks + * + * The hook list provides a way to keep track of hooks. + */ + +/** + * \addtogroup spa_hook + * \{ + */ + +/** A list of hooks */ +struct spa_hook_list { + struct spa_list list; +}; + + /** A hook, contains the structure with functions and the data passed * to the functions. */ struct spa_hook { @@ -149,27 +186,6 @@ spa_hook_list_join(struct spa_hook_list *list, spa_list_insert_list(&list->list, &save->list); } -#define spa_callbacks_call(callbacks,type,method,vers,...) \ -({ \ - const type *_f = (const type *) (callbacks)->funcs; \ - if (SPA_LIKELY(SPA_CALLBACK_CHECK(_f,method,vers))) \ - _f->method((callbacks)->data, ## __VA_ARGS__); \ -}) - -#define spa_callbacks_call_res(callbacks,type,res,method,vers,...) \ -({ \ - const type *_f = (const type *) (callbacks)->funcs; \ - if (SPA_LIKELY(SPA_CALLBACK_CHECK(_f,method,vers))) \ - res = _f->method((callbacks)->data, ## __VA_ARGS__); \ - res; \ -}) - -#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,...) \ ({ \ struct spa_hook_list *_l = l; \