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

@ -123,7 +123,7 @@ struct spa_loop_control_hooks {
struct spa_hook_list *_l = l; \
struct spa_hook *_h; \
spa_list_for_each_reverse(_h, &_l->list, link) \
spa_callbacks_call(&_h->cb, struct spa_loop_control_hooks, before, 0); \
spa_callbacks_call_fast(&_h->cb, struct spa_loop_control_hooks, before, 0); \
})
#define spa_loop_control_hook_after(l) \
@ -131,7 +131,7 @@ struct spa_loop_control_hooks {
struct spa_hook_list *_l = l; \
struct spa_hook *_h; \
spa_list_for_each(_h, &_l->list, link) \
spa_callbacks_call(&_h->cb, struct spa_loop_control_hooks, after, 0); \
spa_callbacks_call_fast(&_h->cb, struct spa_loop_control_hooks, after, 0); \
})
/**
@ -212,6 +212,16 @@ struct spa_loop_control_methods {
_res; \
})
#define spa_loop_control_method_fast_r(o,method,version,...) \
({ \
int _res; \
struct spa_loop_control *_o = o; \
spa_interface_call_fast_res(&_o->iface, \
struct spa_loop_control_methods, _res, \
method, version, ##__VA_ARGS__); \
_res; \
})
#define spa_loop_control_get_fd(l) spa_loop_control_method_r(l,get_fd,0)
#define spa_loop_control_add_hook(l,...) spa_loop_control_method_v(l,add_hook,0,__VA_ARGS__)
#define spa_loop_control_enter(l) spa_loop_control_method_v(l,enter,0)
@ -219,6 +229,8 @@ struct spa_loop_control_methods {
#define spa_loop_control_iterate(l,...) spa_loop_control_method_r(l,iterate,0,__VA_ARGS__)
#define spa_loop_control_check(l) spa_loop_control_method_r(l,check,1)
#define spa_loop_control_iterate_fast(l,...) spa_loop_control_method_fast_r(l,iterate,0,__VA_ARGS__)
typedef void (*spa_source_io_func_t) (void *data, int fd, uint32_t mask);
typedef void (*spa_source_idle_func_t) (void *data);
typedef void (*spa_source_event_func_t) (void *data, uint64_t count);

View file

@ -101,13 +101,12 @@ struct spa_system_methods {
({ \
volatile int _res = -ENOTSUP; \
struct spa_system *_o = o; \
spa_interface_call_res(&_o->iface, \
spa_interface_call_fast_res(&_o->iface, \
struct spa_system_methods, _res, \
method, version, ##__VA_ARGS__); \
_res; \
})
#define spa_system_read(s,...) spa_system_method_r(s,read,0,__VA_ARGS__)
#define spa_system_write(s,...) spa_system_method_r(s,write,0,__VA_ARGS__)
#define spa_system_ioctl(s,...) spa_system_method_r(s,ioctl,0,__VA_ARGS__)