2007-10-28 19:13:50 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-08-12 23:35:44 +00:00
|
|
|
#include <pulsecore/hook-list.h>
|
|
|
|
|
#include <pulsecore/log.h>
|
|
|
|
|
|
2008-06-11 19:45:57 +00:00
|
|
|
static pa_hook_result_t func1(const char *hook_data, const char *call_data, const char *slot_data) {
|
2006-08-13 16:13:36 +00:00
|
|
|
pa_log("(func1) hook=%s call=%s slot=%s", hook_data, call_data, slot_data);
|
2006-08-12 23:35:44 +00:00
|
|
|
return PA_HOOK_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-11 19:45:57 +00:00
|
|
|
static pa_hook_result_t func2(const char *hook_data, const char *call_data, const char *slot_data) {
|
2006-08-13 16:13:36 +00:00
|
|
|
pa_log("(func2) hook=%s call=%s slot=%s", hook_data, call_data, slot_data);
|
2006-08-12 23:35:44 +00:00
|
|
|
return PA_HOOK_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
2006-08-13 01:43:34 +00:00
|
|
|
pa_hook hook;
|
|
|
|
|
pa_hook_slot *slot;
|
2006-08-12 23:35:44 +00:00
|
|
|
|
2006-08-13 16:13:36 +00:00
|
|
|
pa_hook_init(&hook, (void*) "hook");
|
2006-08-12 23:35:44 +00:00
|
|
|
|
2008-06-11 19:45:57 +00:00
|
|
|
pa_hook_connect(&hook, PA_HOOK_LATE, (pa_hook_cb_t) func1, (void*) "slot1");
|
|
|
|
|
slot = pa_hook_connect(&hook, PA_HOOK_NORMAL, (pa_hook_cb_t) func2, (void*) "slot2");
|
|
|
|
|
pa_hook_connect(&hook, PA_HOOK_NORMAL, (pa_hook_cb_t) func1, (void*) "slot3");
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2006-08-13 16:13:36 +00:00
|
|
|
pa_hook_fire(&hook, (void*) "call1");
|
2006-08-12 23:35:44 +00:00
|
|
|
|
2006-08-13 01:43:34 +00:00
|
|
|
pa_hook_slot_free(slot);
|
2006-08-13 16:13:36 +00:00
|
|
|
|
|
|
|
|
pa_hook_fire(&hook, (void*) "call2");
|
|
|
|
|
|
2006-08-13 01:43:34 +00:00
|
|
|
pa_hook_free(&hook);
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2006-08-12 23:35:44 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|