Branch data Line data Source code
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 : 4 : static pa_hook_result_t func1(const char *hook_data, const char *call_data, const char *slot_data) {
9 : 4 : pa_log("(func1) hook=%s call=%s slot=%s", hook_data, call_data, slot_data);
10 : 4 : return PA_HOOK_OK;
11 : : }
12 : :
13 : 1 : static pa_hook_result_t func2(const char *hook_data, const char *call_data, const char *slot_data) {
14 : 1 : pa_log("(func2) hook=%s call=%s slot=%s", hook_data, call_data, slot_data);
15 : 1 : return PA_HOOK_OK;
16 : : }
17 : :
18 : 1 : int main(int argc, char *argv[]) {
19 : : pa_hook hook;
20 : : pa_hook_slot *slot;
21 : :
22 : 1 : pa_hook_init(&hook, (void*) "hook");
23 : :
24 : 1 : pa_hook_connect(&hook, PA_HOOK_LATE, (pa_hook_cb_t) func1, (void*) "slot1");
25 : 1 : slot = pa_hook_connect(&hook, PA_HOOK_NORMAL, (pa_hook_cb_t) func2, (void*) "slot2");
26 : 1 : pa_hook_connect(&hook, PA_HOOK_NORMAL, (pa_hook_cb_t) func1, (void*) "slot3");
27 : :
28 : 1 : pa_hook_fire(&hook, (void*) "call1");
29 : :
30 : 1 : pa_hook_slot_free(slot);
31 : :
32 : 1 : pa_hook_fire(&hook, (void*) "call2");
33 : :
34 : 1 : pa_hook_done(&hook);
35 : :
36 : : return 0;
37 : : }
|