summaryrefslogtreecommitdiff
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
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
-rw-r--r--apps/playback.c6
-rw-r--r--apps/scrobbler.c2
-rw-r--r--apps/tagtree.c4
-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
7 files changed, 19 insertions, 17 deletions
diff --git a/apps/playback.c b/apps/playback.c
index ee1787e612..7eecd23e35 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -1731,7 +1731,7 @@ static bool audio_load_track(int offset, bool start_play)
1731 { 1731 {
1732 if (get_metadata(&id3, fd, trackname)) 1732 if (get_metadata(&id3, fd, trackname))
1733 { 1733 {
1734 send_event(PLAYBACK_EVENT_TRACK_BUFFER, false, &id3); 1734 send_event(PLAYBACK_EVENT_TRACK_BUFFER, &id3);
1735 1735
1736 tracks[track_widx].id3_hid = 1736 tracks[track_widx].id3_hid =
1737 bufalloc(&id3, sizeof(struct mp3entry), TYPE_ID3); 1737 bufalloc(&id3, sizeof(struct mp3entry), TYPE_ID3);
@@ -1968,7 +1968,7 @@ static int audio_check_new_track(void)
1968 bool end_of_playlist; /* Temporary flag, not the same as playlist_end */ 1968 bool end_of_playlist; /* Temporary flag, not the same as playlist_end */
1969 1969
1970 /* Now it's good time to send track unbuffer events. */ 1970 /* Now it's good time to send track unbuffer events. */
1971 send_event(PLAYBACK_EVENT_TRACK_FINISH, false, &curtrack_id3); 1971 send_event(PLAYBACK_EVENT_TRACK_FINISH, &curtrack_id3);
1972 1972
1973 if (dir_skip) 1973 if (dir_skip)
1974 { 1974 {
@@ -2339,7 +2339,7 @@ static void audio_finalise_track_change(void)
2339 bufgetid3(prev_ti->id3_hid)->elapsed = 0; 2339 bufgetid3(prev_ti->id3_hid)->elapsed = 0;
2340 } 2340 }
2341 2341
2342 send_event(PLAYBACK_EVENT_TRACK_CHANGE, false, &curtrack_id3); 2342 send_event(PLAYBACK_EVENT_TRACK_CHANGE, &curtrack_id3);
2343 2343
2344 track_changed = true; 2344 track_changed = true;
2345 playlist_update_resume_info(audio_current_track()); 2345 playlist_update_resume_info(audio_current_track());
diff --git a/apps/scrobbler.c b/apps/scrobbler.c
index 2f60e858e1..85285cb911 100644
--- a/apps/scrobbler.c
+++ b/apps/scrobbler.c
@@ -227,7 +227,7 @@ int scrobbler_init(void)
227 227
228 scrobbler_cache = buffer_alloc(SCROBBLER_MAX_CACHE*SCROBBLER_CACHE_LEN); 228 scrobbler_cache = buffer_alloc(SCROBBLER_MAX_CACHE*SCROBBLER_CACHE_LEN);
229 229
230 add_event(PLAYBACK_EVENT_TRACK_CHANGE, scrobbler_change_event); 230 add_event(PLAYBACK_EVENT_TRACK_CHANGE, false, scrobbler_change_event);
231 cache_pos = 0; 231 cache_pos = 0;
232 pending = false; 232 pending = false;
233 scrobbler_initialised = true; 233 scrobbler_initialised = true;
diff --git a/apps/tagtree.c b/apps/tagtree.c
index 4572204ae5..faffb0053d 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -925,8 +925,8 @@ void tagtree_init(void)
925 925
926 uniqbuf = buffer_alloc(UNIQBUF_SIZE); 926 uniqbuf = buffer_alloc(UNIQBUF_SIZE);
927 927
928 add_event(PLAYBACK_EVENT_TRACK_BUFFER, tagtree_buffer_event); 928 add_event(PLAYBACK_EVENT_TRACK_BUFFER, false, tagtree_buffer_event);
929 add_event(PLAYBACK_EVENT_TRACK_FINISH, tagtree_track_finish_event); 929 add_event(PLAYBACK_EVENT_TRACK_FINISH, false, tagtree_track_finish_event);
930} 930}
931 931
932static bool show_search_progress(bool init, int count) 932static bool show_search_progress(bool init, int count)
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 @@
26void register_ata_idle_func(ata_idle_notify function) 26void register_ata_idle_func(ata_idle_notify function)
27{ 27{
28#if USING_ATA_CALLBACK 28#if USING_ATA_CALLBACK
29 add_event(DISK_EVENT_SPINUP, function); 29 add_event(DISK_EVENT_SPINUP, true, function);
30#else 30#else
31 function(); /* just call the function now */ 31 function(); /* just call the function now */
32/* this _may_ cause problems later if the calling function 32/* this _may_ cause problems later if the calling function
@@ -55,7 +55,7 @@ bool call_ata_idle_notifys(bool force)
55 } 55 }
56 lock_until = current_tick + 30*HZ; 56 lock_until = current_tick + 30*HZ;
57 57
58 send_event(DISK_EVENT_SPINUP, true, NULL); 58 send_event(DISK_EVENT_SPINUP, NULL);
59 59
60 return true; 60 return true;
61} 61}
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
24struct sysevent { 24struct 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
29struct sysevent events[MAX_SYS_EVENTS]; 30struct sysevent events[MAX_SYS_EVENTS];
30 31
31bool add_event(unsigned short id, void (*handler)) 32bool 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
73void send_event(unsigned short id, bool oneshot, void *data) 75void 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 }
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 {
43}; 43};
44 44
45 45
46bool add_event(unsigned short id, void (*handler)); 46bool add_event(unsigned short id, bool oneshot, void (*handler));
47void remove_event(unsigned short id, void (*handler)); 47void remove_event(unsigned short id, void (*handler));
48void send_event(unsigned short id, bool oneshot, void *data); 48void send_event(unsigned short id, void *data);
49 49
50#endif 50#endif
51 51
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)
485 for (i = 0; i < numentries; i++) 485 for (i = 0; i < numentries; i++)
486 { 486 {
487 /* Send an event to notify that track has finished. */ 487 /* Send an event to notify that track has finished. */
488 send_event(PLAYBACK_EVENT_TRACK_FINISH, false, &trackdata[cur_idx].id3); 488 send_event(PLAYBACK_EVENT_TRACK_FINISH, &trackdata[cur_idx].id3);
489 cur_idx = (cur_idx + 1) & MAX_TRACK_ENTRIES_MASK; 489 cur_idx = (cur_idx + 1) & MAX_TRACK_ENTRIES_MASK;
490 } 490 }
491} 491}
@@ -499,7 +499,7 @@ static void generate_postbuffer_events(void)
499 499
500 for (i = 0; i < numentries; i++) 500 for (i = 0; i < numentries; i++)
501 { 501 {
502 send_event(PLAYBACK_EVENT_TRACK_BUFFER, false, &trackdata[cur_idx].id3); 502 send_event(PLAYBACK_EVENT_TRACK_BUFFER, &trackdata[cur_idx].id3);
503 cur_idx = (cur_idx + 1) & MAX_TRACK_ENTRIES_MASK; 503 cur_idx = (cur_idx + 1) & MAX_TRACK_ENTRIES_MASK;
504 } 504 }
505} 505}
@@ -1049,7 +1049,7 @@ static void track_change(void)
1049 if (num_tracks_in_memory() > 0) 1049 if (num_tracks_in_memory() > 0)
1050 { 1050 {
1051 remove_current_tag(); 1051 remove_current_tag();
1052 send_event(PLAYBACK_EVENT_TRACK_CHANGE, false, audio_current_track()); 1052 send_event(PLAYBACK_EVENT_TRACK_CHANGE, audio_current_track());
1053 update_playlist(); 1053 update_playlist();
1054 } 1054 }
1055 1055
@@ -1102,7 +1102,7 @@ static void start_playback_if_ready(void)
1102 if (play_pending_track_change) 1102 if (play_pending_track_change)
1103 { 1103 {
1104 play_pending_track_change = false; 1104 play_pending_track_change = false;
1105 send_event(PLAYBACK_EVENT_TRACK_CHANGE, false, audio_current_track()); 1105 send_event(PLAYBACK_EVENT_TRACK_CHANGE, audio_current_track());
1106 } 1106 }
1107 play_pending = false; 1107 play_pending = false;
1108 } 1108 }