]> code.delx.au - pulseaudio/blobdiff - src/tests/hook-list-test.c
merge 'lennart' branch back into trunk.
[pulseaudio] / src / tests / hook-list-test.c
index 0d811a1eabe4a51ec966fc4b02061148cf6ed462..8628f521116007265aaed12a8c1630155e8438d9 100644 (file)
@@ -1,15 +1,19 @@
 /* $Id$ */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <pulsecore/hook-list.h>
 #include <pulsecore/log.h>
 
-static pa_hook_result_t func1(const char*a, void *userdata) {
-    pa_log("#1 arg=%s userdata=%s", a, (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, void *userdata) {
-    pa_log("#2 arg=%s userdata=%s", a, (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;
 }
 
@@ -17,16 +21,19 @@ int main(int argc, char *argv[]) {
     pa_hook hook;
     pa_hook_slot *slot;
 
-    pa_hook_init(&hook);
+    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_connect(&hook, (pa_hook_cb_t) func1, (void*) "1-1");
-    slot = pa_hook_connect(&hook, (pa_hook_cb_t) func2, (void*) "2-1");
-    pa_hook_connect(&hook, (pa_hook_cb_t) func1, (void*) "1-2");
-    
-    pa_hook_fire(&hook, (void*) "arg2");
+    pa_hook_fire(&hook, (void*) "call1");
 
     pa_hook_slot_free(slot);
+
+    pa_hook_fire(&hook, (void*) "call2");
+
     pa_hook_free(&hook);
-    
+
     return 0;
 }