Git init
[framework/multimedia/pulseaudio.git] / src / tests / hook-list-test.c
1 #ifdef HAVE_CONFIG_H
2 #include <config.h>
3 #endif
4
5 #include <pulsecore/hook-list.h>
6 #include <pulsecore/log.h>
7
8 static pa_hook_result_t func1(const char *hook_data, const char *call_data, const char *slot_data) {
9     pa_log("(func1) hook=%s call=%s slot=%s", hook_data, call_data, slot_data);
10     return PA_HOOK_OK;
11 }
12
13 static pa_hook_result_t func2(const char *hook_data, const char *call_data, const char *slot_data) {
14     pa_log("(func2) hook=%s call=%s slot=%s", hook_data, call_data, slot_data);
15     return PA_HOOK_OK;
16 }
17
18 int main(int argc, char *argv[]) {
19     pa_hook hook;
20     pa_hook_slot *slot;
21
22     pa_hook_init(&hook, (void*) "hook");
23
24     pa_hook_connect(&hook, PA_HOOK_LATE, (pa_hook_cb_t) func1, (void*) "slot1");
25     slot = pa_hook_connect(&hook, PA_HOOK_NORMAL, (pa_hook_cb_t) func2, (void*) "slot2");
26     pa_hook_connect(&hook, PA_HOOK_NORMAL, (pa_hook_cb_t) func1, (void*) "slot3");
27
28     pa_hook_fire(&hook, (void*) "call1");
29
30     pa_hook_slot_free(slot);
31
32     pa_hook_fire(&hook, (void*) "call2");
33
34     pa_hook_done(&hook);
35
36     return 0;
37 }