summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
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 @@
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 }