diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2008-10-16 10:38:03 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2008-10-16 10:38:03 +0000 |
commit | 71898e5c547e1f92bb128aede558938873f56d3c (patch) | |
tree | a29ddd099bdefdd00db381b064f720801f275d56 | |
parent | 9e0ebcc4e696ce058a35441c85afaf608d1dd25c (diff) | |
download | rockbox-71898e5c547e1f92bb128aede558938873f56d3c.tar.gz rockbox-71898e5c547e1f92bb128aede558938873f56d3c.zip |
Accept FS#9480 - centralise and organise the events in the apps/ layer.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18819 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/appevents.h | 56 | ||||
-rw-r--r-- | apps/buffering.c | 14 | ||||
-rw-r--r-- | apps/buffering.h | 10 | ||||
-rw-r--r-- | apps/gui/gwps.c | 3 | ||||
-rw-r--r-- | apps/gui/statusbar.h | 4 | ||||
-rw-r--r-- | apps/menus/display_menu.c | 4 | ||||
-rw-r--r-- | apps/mpeg.c | 2 | ||||
-rw-r--r-- | apps/playback.c | 10 | ||||
-rw-r--r-- | apps/scrobbler.c | 1 | ||||
-rw-r--r-- | apps/tagtree.c | 2 | ||||
-rw-r--r-- | firmware/export/events.h | 15 |
11 files changed, 80 insertions, 41 deletions
diff --git a/apps/appevents.h b/apps/appevents.h new file mode 100644 index 0000000000..36990f9768 --- /dev/null +++ b/apps/appevents.h | |||
@@ -0,0 +1,56 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: events.h 17847 2008-06-28 18:10:04Z bagder $ | ||
9 | * | ||
10 | * Copyright (C) 2008 by Jonathan Gordon | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef _APPEVENTS_H | ||
23 | #define _APPEVENTS_H | ||
24 | |||
25 | #include <stdbool.h> | ||
26 | #include "events.h" | ||
27 | |||
28 | /** Only app/ level events should be defined here. | ||
29 | * firmware/ level events and CLASS's are defined in firmware/export/events.h | ||
30 | */ | ||
31 | |||
32 | /** Playback events **/ | ||
33 | enum { | ||
34 | PLAYBACK_EVENT_TRACK_BUFFER = (EVENT_CLASS_PLAYBACK|1), | ||
35 | PLAYBACK_EVENT_TRACK_FINISH, | ||
36 | PLAYBACK_EVENT_TRACK_CHANGE, | ||
37 | }; | ||
38 | |||
39 | /** Buffering events **/ | ||
40 | enum { | ||
41 | BUFFER_EVENT_BUFFER_LOW = (EVENT_CLASS_BUFFERING|1), | ||
42 | BUFFER_EVENT_REBUFFER, | ||
43 | BUFFER_EVENT_CLOSED, | ||
44 | BUFFER_EVENT_MOVED, | ||
45 | BUFFER_EVENT_FINISHED, | ||
46 | }; | ||
47 | |||
48 | /** Generic GUI class events **/ | ||
49 | enum { | ||
50 | GUI_EVENT_THEME_CHANGED = (EVENT_CLASS_GUI|1), | ||
51 | GUI_EVENT_STATUSBAR_TOGGLE, | ||
52 | }; | ||
53 | |||
54 | #endif | ||
55 | |||
56 | |||
diff --git a/apps/buffering.c b/apps/buffering.c index a821e7f8c7..d963a983a6 100644 --- a/apps/buffering.c +++ b/apps/buffering.c | |||
@@ -50,7 +50,7 @@ | |||
50 | #include "pcmbuf.h" | 50 | #include "pcmbuf.h" |
51 | #include "buffer.h" | 51 | #include "buffer.h" |
52 | #include "bmp.h" | 52 | #include "bmp.h" |
53 | #include "events.h" | 53 | #include "appevents.h" |
54 | #include "metadata.h" | 54 | #include "metadata.h" |
55 | 55 | ||
56 | #if MEM > 1 | 56 | #if MEM > 1 |
@@ -600,7 +600,7 @@ static bool buffer_handle(int handle_id) | |||
600 | h->filerem = 0; | 600 | h->filerem = 0; |
601 | h->available = sizeof(struct mp3entry); | 601 | h->available = sizeof(struct mp3entry); |
602 | h->widx += sizeof(struct mp3entry); | 602 | h->widx += sizeof(struct mp3entry); |
603 | send_event(EVENT_HANDLE_FINISHED, &h->id); | 603 | send_event(BUFFER_EVENT_FINISHED, &h->id); |
604 | return true; | 604 | return true; |
605 | } | 605 | } |
606 | 606 | ||
@@ -673,7 +673,7 @@ static bool buffer_handle(int handle_id) | |||
673 | /* finished buffering the file */ | 673 | /* finished buffering the file */ |
674 | close(h->fd); | 674 | close(h->fd); |
675 | h->fd = -1; | 675 | h->fd = -1; |
676 | send_event(EVENT_HANDLE_FINISHED, &h->id); | 676 | send_event(BUFFER_EVENT_FINISHED, &h->id); |
677 | } | 677 | } |
678 | 678 | ||
679 | return true; | 679 | return true; |
@@ -729,7 +729,7 @@ static void rebuffer_handle(int handle_id, size_t newpos) | |||
729 | /* There isn't enough space to rebuffer all of the track from its new | 729 | /* There isn't enough space to rebuffer all of the track from its new |
730 | offset, so we ask the user to free some */ | 730 | offset, so we ask the user to free some */ |
731 | DEBUGF("rebuffer_handle: space is needed\n"); | 731 | DEBUGF("rebuffer_handle: space is needed\n"); |
732 | send_event(EVENT_HANDLE_REBUFFER, &handle_id); | 732 | send_event(BUFFER_EVENT_REBUFFER, &handle_id); |
733 | } | 733 | } |
734 | 734 | ||
735 | /* Now we ask for a rebuffer */ | 735 | /* Now we ask for a rebuffer */ |
@@ -1339,7 +1339,7 @@ void buffering_thread(void) | |||
1339 | LOGFQUEUE("buffering < Q_START_FILL %d", (int)ev.data); | 1339 | LOGFQUEUE("buffering < Q_START_FILL %d", (int)ev.data); |
1340 | /* Call buffer callbacks here because this is one of two ways | 1340 | /* Call buffer callbacks here because this is one of two ways |
1341 | * to begin a full buffer fill */ | 1341 | * to begin a full buffer fill */ |
1342 | send_event(EVENT_BUFFER_LOW, 0); | 1342 | send_event(BUFFER_EVENT_BUFFER_LOW, 0); |
1343 | shrink_buffer(); | 1343 | shrink_buffer(); |
1344 | queue_reply(&buffering_queue, 1); | 1344 | queue_reply(&buffering_queue, 1); |
1345 | filling |= buffer_handle((int)ev.data); | 1345 | filling |= buffer_handle((int)ev.data); |
@@ -1401,7 +1401,7 @@ void buffering_thread(void) | |||
1401 | 1401 | ||
1402 | /* If the buffer is low, call the callbacks to get new data */ | 1402 | /* If the buffer is low, call the callbacks to get new data */ |
1403 | if (num_handles > 0 && data_counters.useful <= conf_watermark) | 1403 | if (num_handles > 0 && data_counters.useful <= conf_watermark) |
1404 | send_event(EVENT_BUFFER_LOW, 0); | 1404 | send_event(BUFFER_EVENT_BUFFER_LOW, 0); |
1405 | 1405 | ||
1406 | #if 0 | 1406 | #if 0 |
1407 | /* TODO: This needs to be fixed to use the idle callback, disable it | 1407 | /* TODO: This needs to be fixed to use the idle callback, disable it |
@@ -1411,7 +1411,7 @@ void buffering_thread(void) | |||
1411 | else if (ata_disk_is_active() && queue_empty(&buffering_queue)) | 1411 | else if (ata_disk_is_active() && queue_empty(&buffering_queue)) |
1412 | { | 1412 | { |
1413 | if (num_handles > 0 && data_counters.useful <= high_watermark) | 1413 | if (num_handles > 0 && data_counters.useful <= high_watermark) |
1414 | send_event(EVENT_BUFFER_LOW, 0); | 1414 | send_event(BUFFER_EVENT_BUFFER_LOW, 0); |
1415 | 1415 | ||
1416 | if (data_counters.remaining > 0 && BUF_USED <= high_watermark) | 1416 | if (data_counters.remaining > 0 && BUF_USED <= high_watermark) |
1417 | { | 1417 | { |
diff --git a/apps/buffering.h b/apps/buffering.h index c5a58c2e42..c36131898b 100644 --- a/apps/buffering.h +++ b/apps/buffering.h | |||
@@ -24,7 +24,7 @@ | |||
24 | 24 | ||
25 | #include <sys/types.h> | 25 | #include <sys/types.h> |
26 | #include <stdbool.h> | 26 | #include <stdbool.h> |
27 | #include "events.h" | 27 | #include "appevents.h" |
28 | 28 | ||
29 | 29 | ||
30 | enum data_type { | 30 | enum data_type { |
@@ -38,14 +38,6 @@ enum data_type { | |||
38 | TYPE_UNKNOWN, | 38 | TYPE_UNKNOWN, |
39 | }; | 39 | }; |
40 | 40 | ||
41 | enum callback_event { | ||
42 | EVENT_BUFFER_LOW = (EVENT_CLASS_BUFFERING|1), | ||
43 | EVENT_HANDLE_REBUFFER, | ||
44 | EVENT_HANDLE_CLOSED, | ||
45 | EVENT_HANDLE_MOVED, | ||
46 | EVENT_HANDLE_FINISHED, | ||
47 | }; | ||
48 | |||
49 | /* Error return values */ | 41 | /* Error return values */ |
50 | #define ERR_HANDLE_NOT_FOUND -1 | 42 | #define ERR_HANDLE_NOT_FOUND -1 |
51 | #define ERR_BUFFER_FULL -2 | 43 | #define ERR_BUFFER_FULL -2 |
diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c index 47cc05aad2..4d50740182 100644 --- a/apps/gui/gwps.c +++ b/apps/gui/gwps.c | |||
@@ -61,6 +61,7 @@ | |||
61 | #include "backdrop.h" | 61 | #include "backdrop.h" |
62 | #include "quickscreen.h" | 62 | #include "quickscreen.h" |
63 | #include "pitchscreen.h" | 63 | #include "pitchscreen.h" |
64 | #include "appevents.h" | ||
64 | 65 | ||
65 | /* currently only on wps_state is needed */ | 66 | /* currently only on wps_state is needed */ |
66 | struct wps_state wps_state; | 67 | struct wps_state wps_state; |
@@ -820,7 +821,7 @@ void gui_sync_wps_init(void) | |||
820 | gui_wps_set_statusbar(&gui_wps[i], &statusbars.statusbars[i]); | 821 | gui_wps_set_statusbar(&gui_wps[i], &statusbars.statusbars[i]); |
821 | } | 822 | } |
822 | #ifdef HAVE_LCD_BITMAP | 823 | #ifdef HAVE_LCD_BITMAP |
823 | add_event(STATUSBAR_TOGGLE_EVENT, false, statusbar_toggle_handler); | 824 | add_event(GUI_EVENT_STATUSBAR_TOGGLE, false, statusbar_toggle_handler); |
824 | #endif | 825 | #endif |
825 | #if LCD_DEPTH > 1 | 826 | #if LCD_DEPTH > 1 |
826 | unload_wps_backdrop(); | 827 | unload_wps_backdrop(); |
diff --git a/apps/gui/statusbar.h b/apps/gui/statusbar.h index 7e8221461d..f36d609bad 100644 --- a/apps/gui/statusbar.h +++ b/apps/gui/statusbar.h | |||
@@ -30,10 +30,6 @@ | |||
30 | #define STATUSBAR_Y_POS 0 /* MUST be a multiple of 8 */ | 30 | #define STATUSBAR_Y_POS 0 /* MUST be a multiple of 8 */ |
31 | #define STATUSBAR_HEIGHT 8 | 31 | #define STATUSBAR_HEIGHT 8 |
32 | 32 | ||
33 | /* possibly a horrible misuse of the event system. | ||
34 | This is triggered when the statusbar setting changes */ | ||
35 | #define STATUSBAR_TOGGLE_EVENT (EVENT_CLASS_GUI|1) | ||
36 | |||
37 | struct status_info { | 33 | struct status_info { |
38 | int battlevel; | 34 | int battlevel; |
39 | int batt_charge_step; | 35 | int batt_charge_step; |
diff --git a/apps/menus/display_menu.c b/apps/menus/display_menu.c index b71cbb0e08..016255bad1 100644 --- a/apps/menus/display_menu.c +++ b/apps/menus/display_menu.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include <stddef.h> | 23 | #include <stddef.h> |
24 | #include <limits.h> | 24 | #include <limits.h> |
25 | #include "config.h" | 25 | #include "config.h" |
26 | #include "events.h" | 26 | #include "appevents.h" |
27 | #include "lang.h" | 27 | #include "lang.h" |
28 | #include "action.h" | 28 | #include "action.h" |
29 | #include "settings.h" | 29 | #include "settings.h" |
@@ -304,7 +304,7 @@ static int statusbar_callback(int action,const struct menu_item_ex *this_item) | |||
304 | switch (action) | 304 | switch (action) |
305 | { | 305 | { |
306 | case ACTION_EXIT_MENUITEM: | 306 | case ACTION_EXIT_MENUITEM: |
307 | send_event(STATUSBAR_TOGGLE_EVENT, NULL); | 307 | send_event(GUI_EVENT_STATUSBAR_TOGGLE, NULL); |
308 | /* this should be changed so only the viewports are reloaded */ | 308 | /* this should be changed so only the viewports are reloaded */ |
309 | settings_apply(false); | 309 | settings_apply(false); |
310 | break; | 310 | break; |
diff --git a/apps/mpeg.c b/apps/mpeg.c index 6056b68053..713915d5a6 100644 --- a/apps/mpeg.c +++ b/apps/mpeg.c | |||
@@ -39,7 +39,7 @@ | |||
39 | #include "mp3_playback.h" | 39 | #include "mp3_playback.h" |
40 | #include "sound.h" | 40 | #include "sound.h" |
41 | #include "bitswap.h" | 41 | #include "bitswap.h" |
42 | #include "events.h" | 42 | #include "appevents.h" |
43 | #ifndef SIMULATOR | 43 | #ifndef SIMULATOR |
44 | #include "i2c.h" | 44 | #include "i2c.h" |
45 | #include "mas.h" | 45 | #include "mas.h" |
diff --git a/apps/playback.c b/apps/playback.c index 82ab24405f..c7c0b5e9c4 100644 --- a/apps/playback.c +++ b/apps/playback.c | |||
@@ -44,7 +44,7 @@ | |||
44 | #include "codecs.h" | 44 | #include "codecs.h" |
45 | #include "audio.h" | 45 | #include "audio.h" |
46 | #include "buffering.h" | 46 | #include "buffering.h" |
47 | #include "events.h" | 47 | #include "appevents.h" |
48 | #include "voice_thread.h" | 48 | #include "voice_thread.h" |
49 | #include "mp3_playback.h" | 49 | #include "mp3_playback.h" |
50 | #include "usb.h" | 50 | #include "usb.h" |
@@ -2134,7 +2134,7 @@ static void audio_stop_playback(void) | |||
2134 | 2134 | ||
2135 | prev_track_elapsed = curtrack_id3.elapsed; | 2135 | prev_track_elapsed = curtrack_id3.elapsed; |
2136 | 2136 | ||
2137 | remove_event(EVENT_BUFFER_LOW, buffering_low_buffer_callback); | 2137 | remove_event(BUFFER_EVENT_BUFFER_LOW, buffering_low_buffer_callback); |
2138 | } | 2138 | } |
2139 | 2139 | ||
2140 | paused = false; | 2140 | paused = false; |
@@ -2194,7 +2194,7 @@ static void audio_play_start(size_t offset) | |||
2194 | 2194 | ||
2195 | audio_fill_file_buffer(true, offset); | 2195 | audio_fill_file_buffer(true, offset); |
2196 | 2196 | ||
2197 | add_event(EVENT_BUFFER_LOW, false, buffering_low_buffer_callback); | 2197 | add_event(BUFFER_EVENT_BUFFER_LOW, false, buffering_low_buffer_callback); |
2198 | 2198 | ||
2199 | LOGFQUEUE("audio > audio Q_AUDIO_TRACK_CHANGED"); | 2199 | LOGFQUEUE("audio > audio Q_AUDIO_TRACK_CHANGED"); |
2200 | queue_post(&audio_queue, Q_AUDIO_TRACK_CHANGED, 0); | 2200 | queue_post(&audio_queue, Q_AUDIO_TRACK_CHANGED, 0); |
@@ -2578,8 +2578,8 @@ void audio_init(void) | |||
2578 | #endif | 2578 | #endif |
2579 | } | 2579 | } |
2580 | 2580 | ||
2581 | add_event(EVENT_HANDLE_REBUFFER, false, buffering_handle_rebuffer_callback); | 2581 | add_event(BUFFER_EVENT_REBUFFER, false, buffering_handle_rebuffer_callback); |
2582 | add_event(EVENT_HANDLE_FINISHED, false, buffering_handle_finished_callback); | 2582 | add_event(BUFFER_EVENT_FINISHED, false, buffering_handle_finished_callback); |
2583 | 2583 | ||
2584 | /* Probably safe to say */ | 2584 | /* Probably safe to say */ |
2585 | audio_is_initialized = true; | 2585 | audio_is_initialized = true; |
diff --git a/apps/scrobbler.c b/apps/scrobbler.c index 2c6bdf4a1f..acf1e9e4b0 100644 --- a/apps/scrobbler.c +++ b/apps/scrobbler.c | |||
@@ -34,6 +34,7 @@ http://www.audioscrobbler.net/wiki/Portable_Player_Logging | |||
34 | #include "settings.h" | 34 | #include "settings.h" |
35 | #include "ata_idle_notify.h" | 35 | #include "ata_idle_notify.h" |
36 | #include "misc.h" | 36 | #include "misc.h" |
37 | #include "appevents.h" | ||
37 | 38 | ||
38 | #if CONFIG_RTC | 39 | #if CONFIG_RTC |
39 | #include "time.h" | 40 | #include "time.h" |
diff --git a/apps/tagtree.c b/apps/tagtree.c index 92bf18bc26..7b05391640 100644 --- a/apps/tagtree.c +++ b/apps/tagtree.c | |||
@@ -47,7 +47,7 @@ | |||
47 | #include "misc.h" | 47 | #include "misc.h" |
48 | #include "filetypes.h" | 48 | #include "filetypes.h" |
49 | #include "audio.h" | 49 | #include "audio.h" |
50 | #include "events.h" | 50 | #include "appevents.h" |
51 | 51 | ||
52 | #define FILE_SEARCH_INSTRUCTIONS ROCKBOX_DIR "/tagnavi.config" | 52 | #define FILE_SEARCH_INSTRUCTIONS ROCKBOX_DIR "/tagnavi.config" |
53 | 53 | ||
diff --git a/firmware/export/events.h b/firmware/export/events.h index 40447d5533..cad0fad895 100644 --- a/firmware/export/events.h +++ b/firmware/export/events.h | |||
@@ -24,6 +24,10 @@ | |||
24 | 24 | ||
25 | #include <stdbool.h> | 25 | #include <stdbool.h> |
26 | 26 | ||
27 | /** Only CLASS defines and firmware/ level events should be defined here. | ||
28 | * apps/ level events are defined in apps/appevents.h | ||
29 | */ | ||
30 | |||
27 | /** | 31 | /** |
28 | * High byte = Event class definition | 32 | * High byte = Event class definition |
29 | * Low byte = Event ID | 33 | * Low byte = Event ID |
@@ -34,17 +38,6 @@ | |||
34 | #define EVENT_CLASS_BUFFERING 0x0400 | 38 | #define EVENT_CLASS_BUFFERING 0x0400 |
35 | #define EVENT_CLASS_GUI 0x0800 | 39 | #define EVENT_CLASS_GUI 0x0800 |
36 | 40 | ||
37 | /** | ||
38 | * Because same playback events are used in mpeg.c and playback.c, define | ||
39 | * them here to prevent cluttering and ifdefs. | ||
40 | */ | ||
41 | enum { | ||
42 | PLAYBACK_EVENT_TRACK_BUFFER = (EVENT_CLASS_PLAYBACK|1), | ||
43 | PLAYBACK_EVENT_TRACK_FINISH, | ||
44 | PLAYBACK_EVENT_TRACK_CHANGE, | ||
45 | }; | ||
46 | |||
47 | |||
48 | bool add_event(unsigned short id, bool oneshot, void (*handler)); | 41 | bool add_event(unsigned short id, bool oneshot, void (*handler)); |
49 | void remove_event(unsigned short id, void (*handler)); | 42 | void remove_event(unsigned short id, void (*handler)); |
50 | void send_event(unsigned short id, void *data); | 43 | void send_event(unsigned short id, void *data); |