summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2008-03-17 05:22:53 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2008-03-17 05:22:53 +0000
commita67e5d89efe6c3fcf5a2eaf27aac1c14f024ee27 (patch)
tree2e62c72ea2e45410216bdbd62b70101db0f4e7ca /firmware
parentc6b6bad18fcd68182574086c2eb2a1da30d36d25 (diff)
downloadrockbox-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')
-rw-r--r--firmware/ata_idle_notify.c4
-rw-r--r--firmware/events.c8
-rw-r--r--firmware/export/events.h4
-rw-r--r--firmware/mpeg.c8
4 files changed, 13 insertions, 11 deletions
diff --git a/firmware/ata_idle_notify.c b/firmware/ata_idle_notify.c
index a97c3538da..ab2233da1f 100644
--- a/firmware/ata_idle_notify.c
+++ b/firmware/ata_idle_notify.c
@@ -26,7 +26,7 @@
void register_ata_idle_func(ata_idle_notify function)
{
#if USING_ATA_CALLBACK
- add_event(DISK_EVENT_SPINUP, function);
+ add_event(DISK_EVENT_SPINUP, true, function);
#else
function(); /* just call the function now */
/* this _may_ cause problems later if the calling function
@@ -55,7 +55,7 @@ bool call_ata_idle_notifys(bool force)
}
lock_until = current_tick + 30*HZ;
- send_event(DISK_EVENT_SPINUP, true, NULL);
+ send_event(DISK_EVENT_SPINUP, NULL);
return true;
}
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;
}
}
diff --git a/firmware/export/events.h b/firmware/export/events.h
index b27b5dee4c..c7935dbc74 100644
--- a/firmware/export/events.h
+++ b/firmware/export/events.h
@@ -43,9 +43,9 @@ enum {
};
-bool add_event(unsigned short id, void (*handler));
+bool add_event(unsigned short id, bool oneshot, void (*handler));
void remove_event(unsigned short id, void (*handler));
-void send_event(unsigned short id, bool oneshot, void *data);
+void send_event(unsigned short id, void *data);
#endif
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index 9023c304d2..f2322e563b 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -485,7 +485,7 @@ static void generate_unbuffer_events(void)
for (i = 0; i < numentries; i++)
{
/* Send an event to notify that track has finished. */
- send_event(PLAYBACK_EVENT_TRACK_FINISH, false, &trackdata[cur_idx].id3);
+ send_event(PLAYBACK_EVENT_TRACK_FINISH, &trackdata[cur_idx].id3);
cur_idx = (cur_idx + 1) & MAX_TRACK_ENTRIES_MASK;
}
}
@@ -499,7 +499,7 @@ static void generate_postbuffer_events(void)
for (i = 0; i < numentries; i++)
{
- send_event(PLAYBACK_EVENT_TRACK_BUFFER, false, &trackdata[cur_idx].id3);
+ send_event(PLAYBACK_EVENT_TRACK_BUFFER, &trackdata[cur_idx].id3);
cur_idx = (cur_idx + 1) & MAX_TRACK_ENTRIES_MASK;
}
}
@@ -1049,7 +1049,7 @@ static void track_change(void)
if (num_tracks_in_memory() > 0)
{
remove_current_tag();
- send_event(PLAYBACK_EVENT_TRACK_CHANGE, false, audio_current_track());
+ send_event(PLAYBACK_EVENT_TRACK_CHANGE, audio_current_track());
update_playlist();
}
@@ -1102,7 +1102,7 @@ static void start_playback_if_ready(void)
if (play_pending_track_change)
{
play_pending_track_change = false;
- send_event(PLAYBACK_EVENT_TRACK_CHANGE, false, audio_current_track());
+ send_event(PLAYBACK_EVENT_TRACK_CHANGE, audio_current_track());
}
play_pending = false;
}