summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/pdbox.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/pdbox/pdbox.c')
-rw-r--r--apps/plugins/pdbox/pdbox.c62
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];
44int sys_chinlist[MAXAUDIOINDEV]; 44int sys_chinlist[MAXAUDIOINDEV];
45int sys_soundoutdevlist[MAXAUDIOOUTDEV]; 45int sys_soundoutdevlist[MAXAUDIOOUTDEV];
46int sys_choutlist[MAXAUDIOOUTDEV]; 46int sys_choutlist[MAXAUDIOOUTDEV];
47t_binbuf* inbinbuf;
47 48
48/* References for scheduler variables and functions. */ 49/* References for scheduler variables and functions. */
49extern t_time sys_time; 50extern t_time sys_time;
@@ -59,7 +60,7 @@ rates we expect to see: 32000, 44100, 48000, 88200, 96000. */
59bool quit = false; 60bool 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 */
75void gui_thread(void) 76void 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