diff options
author | Lennart Poettering <lennart@poettering.net> | 2006-08-13 01:43:34 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2006-08-13 01:43:34 +0000 |
commit | 281125c72767713d6294ac7094f3bf7bde47a1e3 (patch) | |
tree | 713e700723f22d3d6eeb4b8cd17f942a6ecd87d9 /src/tests | |
parent | 2622b0ca9eae2ffb18caed2b54b4e25325bed702 (diff) |
rework hook list stuff again, and replace macros with real functins. We loose type safety but things are much cleaner now
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1234 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/hook-list-test.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/src/tests/hook-list-test.c b/src/tests/hook-list-test.c index b0ea5997..0d811a1e 100644 --- a/src/tests/hook-list-test.c +++ b/src/tests/hook-list-test.c @@ -3,34 +3,30 @@ #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*a, void *userdata) { + pa_log("#1 arg=%s userdata=%s", a, (char*) userdata); 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*a, void *userdata) { + pa_log("#2 arg=%s userdata=%s", a, (char*) userdata); return PA_HOOK_OK; } int main(int argc, char *argv[]) { - void *u; - - PA_HOOK_HEAD(test, test); - - PA_HOOK_HEAD_INIT(test, test); + pa_hook hook; + pa_hook_slot *slot; - 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_init(&hook); - PA_HOOK_EXECUTE(test, test, "arg1", "arg2"); - - PA_HOOK_REMOVE(test, test, func2, u); + 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_FREE(test, test); + pa_hook_slot_free(slot); + pa_hook_free(&hook); return 0; } |