From db3f561ec4d6fe7b6deedff45802a5efd3ba4013 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 13 Aug 2006 16:13:36 +0000 Subject: rework hook list stuff once again: change the callback prototype to recieve three data pointers: one to the data for the hook, once for the slot and once for the call git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1235 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/hook-list.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/pulsecore/hook-list.c') diff --git a/src/pulsecore/hook-list.c b/src/pulsecore/hook-list.c index 14ab8e89..72b206b2 100644 --- a/src/pulsecore/hook-list.c +++ b/src/pulsecore/hook-list.c @@ -21,12 +21,13 @@ #include -void pa_hook_init(pa_hook *hook) { +void pa_hook_init(pa_hook *hook, void *data) { assert(hook); PA_LLIST_HEAD_INIT(pa_hook_slots, hook->slots); hook->last = NULL; hook->n_dead = hook->firing = 0; + hook->data = data; } static void slot_free(pa_hook *hook, pa_hook_slot *slot) { @@ -48,10 +49,10 @@ void pa_hook_free(pa_hook *hook) { while (hook->slots) slot_free(hook, hook->slots); - pa_hook_init(hook); + pa_hook_init(hook, NULL); } -pa_hook_slot* pa_hook_connect(pa_hook *hook, pa_hook_cb_t cb, void *userdata) { +pa_hook_slot* pa_hook_connect(pa_hook *hook, pa_hook_cb_t cb, void *data) { pa_hook_slot *slot; assert(cb); @@ -60,7 +61,7 @@ pa_hook_slot* pa_hook_connect(pa_hook *hook, pa_hook_cb_t cb, void *userdata) { slot->hook = hook; slot->dead = 0; slot->callback = cb; - slot->userdata = userdata; + slot->data = data; PA_LLIST_INSERT_AFTER(pa_hook_slot, hook->slots, hook->last, slot); hook->last = slot; @@ -91,7 +92,7 @@ pa_hook_result_t pa_hook_fire(pa_hook *hook, void *data) { if (slot->dead) continue; - if ((result = slot->callback(data, slot->userdata)) != PA_HOOK_OK) + if ((result = slot->callback(hook->data, data, slot->data)) != PA_HOOK_OK) break; } -- cgit