From a67e5d89efe6c3fcf5a2eaf27aac1c14f024ee27 Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Mon, 17 Mar 2008 05:22:53 +0000 Subject: It makes more sense for the callback registrar to decide if its a "oneshot" then the callback caller. (Doing it this way means playback could(/should?) registar a disk spinup callback at init which is called every spinup without needing to be reregistered) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16685 a1c6a512-1295-4272-9138-f99709370657 --- firmware/events.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'firmware/events.c') diff --git a/firmware/events.c b/firmware/events.c index eaf2e5c352..00c0099bb9 100644 --- a/firmware/events.c +++ b/firmware/events.c @@ -23,12 +23,13 @@ struct sysevent { unsigned short id; + bool oneshot; void (*callback)(void *data); }; struct sysevent events[MAX_SYS_EVENTS]; -bool add_event(unsigned short id, void (*handler)) +bool add_event(unsigned short id, bool oneshot, void (*handler)) { int i; @@ -45,6 +46,7 @@ bool add_event(unsigned short id, void (*handler)) if (events[i].callback == NULL) { events[i].id = id; + events[i].oneshot = oneshot; events[i].callback = handler; return true; } @@ -70,7 +72,7 @@ void remove_event(unsigned short id, void (*handler)) panicf("event not found"); } -void send_event(unsigned short id, bool oneshot, void *data) +void send_event(unsigned short id, void *data) { int i; @@ -80,7 +82,7 @@ void send_event(unsigned short id, bool oneshot, void *data) { events[i].callback(data); - if (oneshot) + if (events[i].oneshot) events[i].callback = NULL; } } -- cgit