diff options
author | Wim Taymans <wtaymans@redhat.com> | 2018-09-24 11:35:46 +0200 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2018-12-14 10:07:55 +0100 |
commit | 053e01177d4d728f5c346839a6dd1c566d790712 (patch) | |
tree | de2af11bb83664332a4965656ee64aa8e38048ef | |
parent | 73aac68908c2c9f1dda2aab20bc4044fb0367782 (diff) |
loop: use simple hook emission
Add new simple hook emision without a cursor. The one with the cursor
is not thread safe and is not needed for the loop.
Fixes #110
-rw-r--r-- | spa/include/spa/support/loop.h | 4 | ||||
-rw-r--r-- | spa/include/spa/utils/hook.h | 12 |
2 files changed, 14 insertions, 2 deletions
diff --git a/spa/include/spa/support/loop.h b/spa/include/spa/support/loop.h index d6fa85b2..b08c9d2e 100644 --- a/spa/include/spa/support/loop.h +++ b/spa/include/spa/support/loop.h @@ -111,8 +111,8 @@ struct spa_loop_control_hooks { void (*after) (void *data); }; -#define spa_loop_control_hook_before(l) spa_hook_list_call(l, struct spa_loop_control_hooks, before, 0) -#define spa_loop_control_hook_after(l) spa_hook_list_call(l, struct spa_loop_control_hooks, after, 0) +#define spa_loop_control_hook_before(l) spa_hook_list_call_simple(l, struct spa_loop_control_hooks, before, 0) +#define spa_loop_control_hook_after(l) spa_hook_list_call_simple(l, struct spa_loop_control_hooks, after, 0) /** * Control an event loop diff --git a/spa/include/spa/utils/hook.h b/spa/include/spa/utils/hook.h index bde20dc2..dd04af9a 100644 --- a/spa/include/spa/utils/hook.h +++ b/spa/include/spa/utils/hook.h @@ -82,6 +82,18 @@ static inline void spa_hook_remove(struct spa_hook *hook) hook->removed(hook); } +#define spa_hook_list_call_simple(l,type,method,vers,...) \ +({ \ + struct spa_hook_list *list = l; \ + struct spa_hook *ci; \ + spa_list_for_each(ci, &list->list, link) { \ + const type *cb = ci->funcs; \ + if (cb && cb->version >= vers && cb->method) { \ + cb->method(ci->data, ## __VA_ARGS__); \ + } \ + } \ +}) + /** Call all hooks in a list, starting from the given one and optionally stopping * after calling the first non-NULL function, returns the number of methods * called */ |