/* $Id$ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include <pulsecore/hook-list.h>
#include <pulsecore/log.h>
-PA_HOOK_DECLARE(test, const char *, const char*);
-
-static pa_hook_result_t func1(const char*a, const char*b, void *userdata) {
- pa_log("#1 a=%s b=%s userdata=%s", a, b, (char*) userdata);
+static pa_hook_result_t func1(const char*hook_data, const char*call_data, const char*slot_data) {
+ pa_log("(func1) hook=%s call=%s slot=%s", hook_data, call_data, slot_data);
return PA_HOOK_OK;
}
-static pa_hook_result_t func2(const char*a, const char*b, void *userdata) {
- pa_log("#2 a=%s b=%s userdata=%s", a, b, (char*) userdata);
+static pa_hook_result_t func2(const char*hook_data, const char*call_data, const char*slot_data) {
+ pa_log("(func2) hook=%s call=%s slot=%s", hook_data, call_data, slot_data);
return PA_HOOK_OK;
}
int main(int argc, char *argv[]) {
- void *u;
-
- PA_HOOK_HEAD(test, test);
+ pa_hook hook;
+ pa_hook_slot *slot;
+
+ pa_hook_init(&hook, (void*) "hook");
+
+ pa_hook_connect(&hook, (pa_hook_cb_t) func1, (void*) "slot1");
+ slot = pa_hook_connect(&hook, (pa_hook_cb_t) func2, (void*) "slot2");
+ pa_hook_connect(&hook, (pa_hook_cb_t) func1, (void*) "slot3");
- PA_HOOK_HEAD_INIT(test, test);
+ pa_hook_fire(&hook, (void*) "call1");
- PA_HOOK_APPEND(test, test, func1, (void*) "1-1");
- PA_HOOK_APPEND(test, test, func2, u = (void*) "2");
- PA_HOOK_APPEND(test, test, func1, (void*) "1-2");
+ pa_hook_slot_free(slot);
- PA_HOOK_EXECUTE(test, test, "arg1", "arg2");
+ pa_hook_fire(&hook, (void*) "call2");
- PA_HOOK_REMOVE(test, test, func2, u);
+ pa_hook_free(&hook);
- PA_HOOK_FREE(test, test);
-
return 0;
}