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.c156
1 files changed, 0 insertions, 156 deletions
diff --git a/apps/plugins/pdbox/pdbox.c b/apps/plugins/pdbox/pdbox.c
index 9407849352..c3fb4499e1 100644
--- a/apps/plugins/pdbox/pdbox.c
+++ b/apps/plugins/pdbox/pdbox.c
@@ -155,160 +155,4 @@ enum plugin_status plugin_start(const void* parameter)
155 155
156 return PLUGIN_OK; 156 return PLUGIN_OK;
157} 157}
158/***************************************************************************
159 * __________ __ ___.
160 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
161 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
162 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
163 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
164 * \/ \/ \/ \/ \/
165 * $Id$
166 *
167 * Copyright (C) 2009 Wincent Balin
168 *
169 * This program is free software; you can redistribute it and/or
170 * modify it under the terms of the GNU General Public License
171 * as published by the Free Software Foundation; either version 2
172 * of the License, or (at your option) any later version.
173 *
174 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
175 * KIND, either express or implied.
176 *
177 ****************************************************************************/
178
179#include "plugin.h"
180#include "pdbox.h"
181
182/* Welcome to the PDBox plugin */
183PLUGIN_HEADER
184PLUGIN_IRAM_DECLARE
185
186/* Quit flag. */
187bool quit = false;
188
189/* Thread IDs. */
190unsigned int core_thread_id;
191unsigned int gui_thread_id;
192
193/* Stacks for threads. */
194#define STACK_SIZE 16384
195uint32_t core_stack[STACK_SIZE / sizeof(uint32_t)];
196uint32_t gui_stack[STACK_SIZE / sizeof(uint32_t)];
197
198
199/* Core thread */
200void core_thread(void)
201{
202 struct datagram ping;
203
204 /* Main loop */
205 while(!quit)
206 {
207 /* Wait for request. */
208 while(!RECEIVE_TO_CORE(&ping))
209 rb->yield();
210
211 if(memcmp("Ping!", ping.data, ping.size) == 0)
212 {
213 SEND_FROM_CORE("Pong!");
214 break;
215 }
216
217 rb->yield();
218 }
219
220 rb->thread_exit();
221}
222
223/* GUI thread */
224void gui_thread(void)
225{
226 struct datagram pong;
227
228 /* GUI loop */
229 while(!quit)
230 {
231 /* Send ping to the core. */
232 SEND_TO_CORE("Ping!");
233 rb->splash(HZ, "Sent ping.");
234
235 /* Wait for answer. */
236 while(!RECEIVE_FROM_CORE(&pong))
237 rb->yield();
238
239 /* If got a pong -- everything allright. */
240 if(memcmp("Pong!", pong.data, pong.size) == 0)
241 {
242 rb->splash(HZ, "Got pong!");
243 quit = true;
244 break;
245 }
246
247 rb->yield();
248 }
249
250 rb->thread_exit();
251}
252
253
254/* Plug-in entry point */
255enum plugin_status plugin_start(const void* parameter)
256{
257 PLUGIN_IRAM_INIT(rb)
258
259 size_t mem_size;
260 void* mem_pool;
261
262 /* Get the file name. */
263 const char* filename = (const char*) parameter;
264
265#if 0
266 /* Allocate memory; check it's size; add to the pool. */
267 mem_pool = rb->plugin_get_audio_buffer(&mem_size);
268 if(mem_size < MIN_MEM_SIZE)
269 {
270 rb->splash(HZ, "Not enough memory!");
271 return PLUGIN_ERROR;
272 }
273 add_pool(mem_pool, mem_size);
274#endif
275 158
276 /* Initialze net. */
277 net_init();
278
279 /* Start threads. */
280 core_thread_id =
281 rb->create_thread(&core_thread,
282 core_stack,
283 sizeof(core_stack),
284 0, /* FIXME Which flags? */
285 "PD core"
286 IF_PRIO(, MAX(PRIORITY_USER_INTERFACE / 2,
287 PRIORITY_REALTIME + 1))
288 IF_COP(, COP));
289 gui_thread_id =
290 rb->create_thread(&gui_thread,
291 gui_stack,
292 sizeof(gui_stack),
293 0, /* FIXME Which flags? */
294 "PD GUI"
295 IF_PRIO(, PRIORITY_USER_INTERFACE)
296 IF_COP(, CPU));
297
298 /* If having an error creating threads, bail out. */
299 if(core_thread_id == 0 || gui_thread_id == 0)
300 return PLUGIN_ERROR;
301
302 /* Wait for quit flag. */
303 while(!quit)
304 rb->yield();
305
306 /* Wait for threads to complete. */
307 rb->thread_wait(gui_thread_id);
308 rb->thread_wait(core_thread_id);
309
310 /* Destroy net. */
311 net_destroy();
312
313 return PLUGIN_OK;
314}