diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2008-03-17 05:22:53 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2008-03-17 05:22:53 +0000 |
commit | a67e5d89efe6c3fcf5a2eaf27aac1c14f024ee27 (patch) | |
tree | 2e62c72ea2e45410216bdbd62b70101db0f4e7ca /firmware/events.c | |
parent | c6b6bad18fcd68182574086c2eb2a1da30d36d25 (diff) | |
download | rockbox-a67e5d89efe6c3fcf5a2eaf27aac1c14f024ee27.tar.gz rockbox-a67e5d89efe6c3fcf5a2eaf27aac1c14f024ee27.zip |
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
Diffstat (limited to 'firmware/events.c')
-rw-r--r-- | firmware/events.c | 8 |
1 files changed, 5 insertions, 3 deletions
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 @@ | |||
23 | 23 | ||
24 | struct sysevent { | 24 | struct sysevent { |
25 | unsigned short id; | 25 | unsigned short id; |
26 | bool oneshot; | ||
26 | void (*callback)(void *data); | 27 | void (*callback)(void *data); |
27 | }; | 28 | }; |
28 | 29 | ||
29 | struct sysevent events[MAX_SYS_EVENTS]; | 30 | struct sysevent events[MAX_SYS_EVENTS]; |
30 | 31 | ||
31 | bool add_event(unsigned short id, void (*handler)) | 32 | bool add_event(unsigned short id, bool oneshot, void (*handler)) |
32 | { | 33 | { |
33 | int i; | 34 | int i; |
34 | 35 | ||
@@ -45,6 +46,7 @@ bool add_event(unsigned short id, void (*handler)) | |||
45 | if (events[i].callback == NULL) | 46 | if (events[i].callback == NULL) |
46 | { | 47 | { |
47 | events[i].id = id; | 48 | events[i].id = id; |
49 | events[i].oneshot = oneshot; | ||
48 | events[i].callback = handler; | 50 | events[i].callback = handler; |
49 | return true; | 51 | return true; |
50 | } | 52 | } |
@@ -70,7 +72,7 @@ void remove_event(unsigned short id, void (*handler)) | |||
70 | panicf("event not found"); | 72 | panicf("event not found"); |
71 | } | 73 | } |
72 | 74 | ||
73 | void send_event(unsigned short id, bool oneshot, void *data) | 75 | void send_event(unsigned short id, void *data) |
74 | { | 76 | { |
75 | int i; | 77 | int i; |
76 | 78 | ||
@@ -80,7 +82,7 @@ void send_event(unsigned short id, bool oneshot, void *data) | |||
80 | { | 82 | { |
81 | events[i].callback(data); | 83 | events[i].callback(data); |
82 | 84 | ||
83 | if (oneshot) | 85 | if (events[i].oneshot) |
84 | events[i].callback = NULL; | 86 | events[i].callback = NULL; |
85 | } | 87 | } |
86 | } | 88 | } |