hooks: add and use _fast callback function

Add a _fast callback function that skips the version and method check.
We can use this in places where performance is critical when we do the
check out of the critical loops.

Make all system methods _fast calls. We expect them to exist and have
the right version. If we add new versions we can make them slow.
This commit is contained in:
Wim Taymans 2023-05-06 00:24:05 +02:00
parent 9967c35bbe
commit efea7ad060
12 changed files with 76 additions and 29 deletions

View file

@ -162,6 +162,14 @@ struct spa_interface {
_res; \
})
#define spa_callbacks_call_fast(callbacks,type,method,vers,...) \
({ \
const type *_f = (const type *) (callbacks)->funcs; \
_f->method((callbacks)->data, ## __VA_ARGS__); \
true; \
})
/**
* True if the \a callbacks are of version \a vers, false otherwise
*/
@ -194,6 +202,11 @@ struct spa_interface {
res = _f->method((callbacks)->data, ## __VA_ARGS__); \
res; \
})
#define spa_callbacks_call_fast_res(callbacks,type,res,method,vers,...) \
({ \
const type *_f = (const type *) (callbacks)->funcs; \
res = _f->method((callbacks)->data, ## __VA_ARGS__); \
})
/**
* True if the \a iface's callbacks are of version \a vers, false otherwise
@ -216,6 +229,9 @@ struct spa_interface {
#define spa_interface_call(iface,method_type,method,vers,...) \
spa_callbacks_call(&(iface)->cb,method_type,method,vers,##__VA_ARGS__)
#define spa_interface_call_fast(iface,method_type,method,vers,...) \
spa_callbacks_call_fast(&(iface)->cb,method_type,method,vers,##__VA_ARGS__)
/**
* 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
@ -226,6 +242,9 @@ struct spa_interface {
#define spa_interface_call_res(iface,method_type,res,method,vers,...) \
spa_callbacks_call_res(&(iface)->cb,method_type,res,method,vers,##__VA_ARGS__)
#define spa_interface_call_fast_res(iface,method_type,res,method,vers,...) \
spa_callbacks_call_fast_res(&(iface)->cb,method_type,res,method,vers,##__VA_ARGS__)
/**
* \}
*/