mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-20 06:59:58 -05:00
interface: add an interface struct
The interface struct has the type,version and methods of the interface. Make spa interfaces extend from spa_interface and make a separate structure for the methods. Pass a generic void* as the first argument of methods, like we don in PipeWire. Bundle the methods + implementation in a versioned inteface and use that to invoke methods. This way we can do version checks on the methods. Make resource and proxy interfaces that we can can call. We can then make the core interfaces independent on proxy/resource and hide them in the lower layers. Add add_listener method to methods of core interfaces, just like SPA.
This commit is contained in:
parent
eb6481efb3
commit
ff946e3d4b
85 changed files with 3051 additions and 3000 deletions
|
|
@ -52,6 +52,15 @@ struct spa_callbacks {
|
|||
|
||||
#define SPA_CALLBACKS_INIT(_funcs,_data) (struct spa_callbacks){ _funcs, _data, }
|
||||
|
||||
struct spa_interface {
|
||||
uint32_t type;
|
||||
uint32_t version;
|
||||
struct spa_callbacks cb;
|
||||
};
|
||||
|
||||
#define SPA_INTERFACE_INIT(_type,_version,_funcs,_data) \
|
||||
(struct spa_interface){ _type, _version, SPA_CALLBACKS_INIT(_funcs,_data), }
|
||||
|
||||
/** A hook, contains the structure with functions and the data passed
|
||||
* to the functions. */
|
||||
struct spa_hook {
|
||||
|
|
@ -130,6 +139,12 @@ spa_hook_list_join(struct spa_hook_list *list,
|
|||
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; \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue