summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spa/include/spa/utils/hook.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/spa/include/spa/utils/hook.h b/spa/include/spa/utils/hook.h
index 97bda859..8fddc252 100644
--- a/spa/include/spa/utils/hook.h
+++ b/spa/include/spa/utils/hook.h
@@ -80,20 +80,28 @@ static inline void spa_hook_remove(struct spa_hook *hook)
/** 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 */
-#define spa_hook_list_do_call(l,start,type,method,once,...) ({ \
+#define spa_hook_list_do_call(l,start,type,method,once,...) \
+({ \
struct spa_hook_list *list = l; \
struct spa_list *s = start ? (struct spa_list *)start : &list->list; \
- struct spa_hook *ci, *t; \
+ struct spa_hook cursor = { 0, }; \
+ struct spa_hook *ci; \
int count = 0; \
- spa_list_for_each_safe_next(ci, t, &list->list, s, link) { \
+ spa_list_prepend(s, &cursor.link); \
+ for(ci = spa_list_first(&cursor.link, struct spa_hook, link); \
+ &ci->link != s; \
+ ci = spa_list_next(&cursor, link)) { \
const type *cb = ci->funcs; \
- if (cb->method) { \
+ spa_list_remove(&ci->link); \
+ spa_list_append(&cursor.link, &ci->link); \
+ if (cb && cb->method) { \
cb->method(ci->data, ## __VA_ARGS__); \
count++; \
if (once) \
break; \
} \
} \
+ spa_list_remove(&cursor.link); \
count; \
})