diff options
author | Wincent Balin <wincent@rockbox.org> | 2009-08-04 02:01:55 +0000 |
---|---|---|
committer | Wincent Balin <wincent@rockbox.org> | 2009-08-04 02:01:55 +0000 |
commit | bec80ca7ddeff355d0ca46efa331d98c77567fd4 (patch) | |
tree | 701d8d4cadf97c4a218c9c2bc3b7e33918db025a /apps/plugins/pdbox/pdbox.c | |
parent | 218b31272e5afcb8f98a62974b46f4febbfde39c (diff) | |
download | rockbox-bec80ca7ddeff355d0ca46efa331d98c77567fd4.tar.gz rockbox-bec80ca7ddeff355d0ca46efa331d98c77567fd4.zip |
PDBox: Added GUI.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22147 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/pdbox/pdbox.c')
-rw-r--r-- | apps/plugins/pdbox/pdbox.c | 62 |
1 files changed, 45 insertions, 17 deletions
diff --git a/apps/plugins/pdbox/pdbox.c b/apps/plugins/pdbox/pdbox.c index dd848deba2..5c5677c42e 100644 --- a/apps/plugins/pdbox/pdbox.c +++ b/apps/plugins/pdbox/pdbox.c | |||
@@ -44,6 +44,7 @@ int sys_soundindevlist[MAXAUDIOINDEV]; | |||
44 | int sys_chinlist[MAXAUDIOINDEV]; | 44 | int sys_chinlist[MAXAUDIOINDEV]; |
45 | int sys_soundoutdevlist[MAXAUDIOOUTDEV]; | 45 | int sys_soundoutdevlist[MAXAUDIOOUTDEV]; |
46 | int sys_choutlist[MAXAUDIOOUTDEV]; | 46 | int sys_choutlist[MAXAUDIOOUTDEV]; |
47 | t_binbuf* inbinbuf; | ||
47 | 48 | ||
48 | /* References for scheduler variables and functions. */ | 49 | /* References for scheduler variables and functions. */ |
49 | extern t_time sys_time; | 50 | extern t_time sys_time; |
@@ -59,7 +60,7 @@ rates we expect to see: 32000, 44100, 48000, 88200, 96000. */ | |||
59 | bool quit = false; | 60 | bool quit = false; |
60 | 61 | ||
61 | /* Stack sizes for threads. */ | 62 | /* Stack sizes for threads. */ |
62 | #define CORESTACKSIZE (8 * 1024 * 1024) | 63 | #define CORESTACKSIZE (1 * 1024 * 1024) |
63 | #define GUISTACKSIZE (512 * 1024) | 64 | #define GUISTACKSIZE (512 * 1024) |
64 | 65 | ||
65 | /* Thread stacks. */ | 66 | /* Thread stacks. */ |
@@ -74,30 +75,45 @@ unsigned int gui_thread_id; | |||
74 | /* GUI thread */ | 75 | /* GUI thread */ |
75 | void gui_thread(void) | 76 | void gui_thread(void) |
76 | { | 77 | { |
77 | /* struct datagram pong; */ | 78 | struct pd_widget widget[128]; |
79 | unsigned int widgets = 0; | ||
80 | struct datagram dg; | ||
81 | bool update; | ||
82 | |||
83 | /* Initialize GUI. */ | ||
84 | pd_gui_init(); | ||
85 | |||
86 | /* Load PD patch. */ | ||
87 | widgets = pd_gui_load_patch(widget, | ||
88 | sizeof(widget) / sizeof(struct pd_widget)); | ||
89 | |||
90 | /* Draw initial state of UI. */ | ||
91 | pd_gui_draw(widget, widgets); | ||
78 | 92 | ||
79 | /* GUI loop */ | 93 | /* GUI loop */ |
80 | while(!quit) | 94 | while(!quit) |
81 | { | 95 | { |
82 | #if 0 | 96 | /* Reset update flag. */ |
83 | /* Send ping to the core. */ | 97 | update = false; |
84 | SEND_TO_CORE("Ping!"); | 98 | |
85 | rb->splash(HZ, "Sent ping."); | 99 | /* Apply timer to widgets. */ |
100 | update |= | ||
101 | pd_gui_apply_timeouts(widget, widgets); | ||
86 | 102 | ||
87 | /* Wait for answer. */ | 103 | /* Process buttons. */ |
88 | while(!RECEIVE_FROM_CORE(&pong)) | 104 | update |= |
89 | rb->yield(); | 105 | pd_gui_parse_buttons(widgets); |
90 | 106 | ||
91 | /* If got a pong -- everything allright. */ | 107 | /* Receive and parse datagrams. */ |
92 | if(memcmp("Pong!", pong.data, pong.size) == 0) | 108 | while(RECEIVE_FROM_CORE(&dg)) |
93 | { | 109 | { |
94 | rb->splash(HZ, "Got pong!"); | 110 | update = true; |
95 | quit = true; | 111 | pd_gui_parse_message(&dg, widget, widgets); |
96 | break; | ||
97 | } | 112 | } |
98 | #endif | 113 | |
99 | if(rb->button_get(false) == BUTTON_OFF) | 114 | /* If there is something to update in GUI, do so. */ |
100 | quit = true; | 115 | if(update) |
116 | pd_gui_draw(widget, widgets); | ||
101 | 117 | ||
102 | rb->sleep(1); | 118 | rb->sleep(1); |
103 | } | 119 | } |
@@ -120,6 +136,12 @@ void core_thread(void) | |||
120 | /* Core scheduler loop */ | 136 | /* Core scheduler loop */ |
121 | while(!quit) | 137 | while(!quit) |
122 | { | 138 | { |
139 | /* Receive datagrams. */ | ||
140 | struct datagram dg; | ||
141 | |||
142 | while(RECEIVE_TO_CORE(&dg)) | ||
143 | rockbox_receive_callback(&dg); | ||
144 | |||
123 | /* Use sys_send_dacs() function as timer. */ | 145 | /* Use sys_send_dacs() function as timer. */ |
124 | while(sys_send_dacs() != SENDDACS_NO) | 146 | while(sys_send_dacs() != SENDDACS_NO) |
125 | sched_tick(sys_time + sys_time_per_dsp_tick); | 147 | sched_tick(sys_time + sys_time_per_dsp_tick); |
@@ -194,6 +216,9 @@ enum plugin_status plugin_start(const void* parameter) | |||
194 | return PLUGIN_ERROR; | 216 | return PLUGIN_ERROR; |
195 | } | 217 | } |
196 | 218 | ||
219 | /* Boost CPU. */ | ||
220 | cpu_boost(true); | ||
221 | |||
197 | /* Start threads. */ | 222 | /* Start threads. */ |
198 | core_thread_id = | 223 | core_thread_id = |
199 | rb->create_thread(&core_thread, | 224 | rb->create_thread(&core_thread, |
@@ -237,6 +262,9 @@ enum plugin_status plugin_start(const void* parameter) | |||
237 | rb->thread_wait(gui_thread_id); | 262 | rb->thread_wait(gui_thread_id); |
238 | rb->thread_wait(core_thread_id); | 263 | rb->thread_wait(core_thread_id); |
239 | 264 | ||
265 | /* Unboost CPU. */ | ||
266 | cpu_boost(false); | ||
267 | |||
240 | /* Close audio subsystem. */ | 268 | /* Close audio subsystem. */ |
241 | sys_close_audio(); | 269 | sys_close_audio(); |
242 | 270 | ||