diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2006-10-31 11:17:00 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2006-10-31 11:17:00 +0000 |
commit | 29e259a29190a5ec67dbffc85389a1cb71a9fe26 (patch) | |
tree | fbb8615c108ee177f378444952b89009f5527519 /apps/plugins | |
parent | 23f127ddd7ccda46f88597307cd6df3da3a98c0c (diff) | |
download | rockbox-29e259a29190a5ec67dbffc85389a1cb71a9fe26.tar.gz rockbox-29e259a29190a5ec67dbffc85389a1cb71a9fe26.zip |
* give tsr plugins the choice to quit or not
* bumps plugin api version
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11405 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/alpine_cdc.c | 5 | ||||
-rw-r--r-- | apps/plugins/battery_bench.c | 28 |
2 files changed, 25 insertions, 8 deletions
diff --git a/apps/plugins/alpine_cdc.c b/apps/plugins/alpine_cdc.c index 134bb3dee6..65108680c6 100644 --- a/apps/plugins/alpine_cdc.c +++ b/apps/plugins/alpine_cdc.c | |||
@@ -1122,8 +1122,10 @@ void thread(void) | |||
1122 | } | 1122 | } |
1123 | 1123 | ||
1124 | /* callback to end the TSR plugin, called before a new one gets loaded */ | 1124 | /* callback to end the TSR plugin, called before a new one gets loaded */ |
1125 | void exit_tsr(void) | 1125 | bool exit_tsr(bool reenter) |
1126 | { | 1126 | { |
1127 | if (reenter) | ||
1128 | return false; /* dont let it start again */ | ||
1127 | gTread.exiting = true; /* tell the thread to end */ | 1129 | gTread.exiting = true; /* tell the thread to end */ |
1128 | while (!gTread.ended) /* wait until it did */ | 1130 | while (!gTread.ended) /* wait until it did */ |
1129 | rb->yield(); | 1131 | rb->yield(); |
@@ -1133,6 +1135,7 @@ void exit_tsr(void) | |||
1133 | timer_set_mode(TM_OFF); /* timer interrupt off */ | 1135 | timer_set_mode(TM_OFF); /* timer interrupt off */ |
1134 | 1136 | ||
1135 | sound_normal(); /* restore sound settings */ | 1137 | sound_normal(); /* restore sound settings */ |
1138 | return true; | ||
1136 | } | 1139 | } |
1137 | 1140 | ||
1138 | /****************** main ******************/ | 1141 | /****************** main ******************/ |
diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c index 75d5cbcabd..85d35b003e 100644 --- a/apps/plugins/battery_bench.c +++ b/apps/plugins/battery_bench.c | |||
@@ -92,7 +92,7 @@ PLUGIN_HEADER | |||
92 | /****************************** Plugin Entry Point ****************************/ | 92 | /****************************** Plugin Entry Point ****************************/ |
93 | static struct plugin_api* rb; | 93 | static struct plugin_api* rb; |
94 | int main(void); | 94 | int main(void); |
95 | void exit_tsr(void); | 95 | bool exit_tsr(bool); |
96 | void thread(void); | 96 | void thread(void); |
97 | 97 | ||
98 | 98 | ||
@@ -119,13 +119,27 @@ struct batt_info | |||
119 | 119 | ||
120 | struct event_queue thread_q; | 120 | struct event_queue thread_q; |
121 | 121 | ||
122 | void exit_tsr(void) | 122 | bool exit_tsr(bool reenter) |
123 | { | 123 | { |
124 | rb->queue_post(&thread_q, EV_EXIT, NULL); | 124 | bool exit = true; |
125 | while (!s_thread.ended) | 125 | (void)reenter; |
126 | rb->yield(); | 126 | rb->lcd_clear_display(); |
127 | /* remove the thread's queue from the broadcast list */ | 127 | rb->lcd_puts_scroll(0, 0, "Batt.Bench is currently running."); |
128 | rb->queue_delete(&thread_q); | 128 | rb->lcd_puts_scroll(0, 1, "Press OFF to cancel the test"); |
129 | rb->lcd_puts_scroll(0, 2, "Anything else will resume"); | ||
130 | rb->lcd_update(); | ||
131 | if (rb->button_get(true) != BATTERY_OFF) | ||
132 | exit = false; | ||
133 | if (exit) | ||
134 | { | ||
135 | rb->queue_post(&thread_q, EV_EXIT, NULL); | ||
136 | while (!s_thread.ended) | ||
137 | rb->yield(); | ||
138 | /* remove the thread's queue from the broadcast list */ | ||
139 | rb->queue_delete(&thread_q); | ||
140 | return true; | ||
141 | } | ||
142 | else return false; | ||
129 | } | 143 | } |
130 | 144 | ||
131 | #define BIT_CHARGER 0x1000 | 145 | #define BIT_CHARGER 0x1000 |