mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-08 13:30:08 -05:00
spa: add a macro to check for a callback version
spa_interface_call() and friends will quietly do nothing if the version
doesn't match so we need an extra macro to know whether we can
spa_interface_call() for any given version.
This allows us to implement things like:
if (spa_interface_callback_version_min(1)
spa_interface_call(..., 1, func_v1)
else
spa_interface_call(..., 0, func_v0)
This commit is contained in:
parent
6bf1f9a694
commit
cbcf62f341
2 changed files with 53 additions and 0 deletions
|
|
@ -179,6 +179,15 @@ struct spa_interface {
|
|||
_f->method((callbacks)->data, ## __VA_ARGS__); \
|
||||
})
|
||||
|
||||
/**
|
||||
* True if the \a callbacks are of version \a vers, false otherwise
|
||||
*/
|
||||
#define spa_callback_version_min(callbacks,type,vers) \
|
||||
({ \
|
||||
const type *_f = (const type *) (callbacks)->funcs; \
|
||||
SPA_CALLBACK_VERSION_MIN(_f,vers); \
|
||||
})
|
||||
|
||||
/**
|
||||
* Invoke method named \a method in the \a callbacks.
|
||||
* The \a method_type defines the type of the method struct.
|
||||
|
|
@ -193,6 +202,12 @@ struct spa_interface {
|
|||
res; \
|
||||
})
|
||||
|
||||
/**
|
||||
* True if the \a iface's \a callbacks are of version \a vers, false otherwise
|
||||
*/
|
||||
#define spa_interface_callback_version_min(iface,method_type,vers) \
|
||||
spa_callback_version_min(&(iface)->cb, method_type, vers)
|
||||
|
||||
/**
|
||||
* Invoke method named \a method in the callbacks on the given interface object.
|
||||
* The \a method_type defines the type of the method struct, not the interface
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue