1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2009 Wincent Balin
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
25 /* Welcome to the PDBox plugin */
33 unsigned int core_thread_id
;
34 unsigned int gui_thread_id
;
36 /* Stacks for threads. */
37 #define STACK_SIZE 16384
38 uint32_t core_stack
[STACK_SIZE
/ sizeof(uint32_t)];
39 uint32_t gui_stack
[STACK_SIZE
/ sizeof(uint32_t)];
43 void core_thread(void)
50 /* Wait for request. */
51 while(!RECEIVE_TO_CORE(&ping
))
54 if(memcmp("Ping!", ping
.data
, ping
.size
) == 0)
56 SEND_FROM_CORE("Pong!");
74 /* Send ping to the core. */
75 SEND_TO_CORE("Ping!");
76 rb
->splash(HZ
, "Sent ping.");
78 /* Wait for answer. */
79 while(!RECEIVE_FROM_CORE(&pong
))
82 /* If got a pong -- everything allright. */
83 if(memcmp("Pong!", pong
.data
, pong
.size
) == 0)
85 rb
->splash(HZ
, "Got pong!");
97 /* Plug-in entry point */
98 enum plugin_status
plugin_start(const void* parameter
)
105 /* Get the file name. */
106 const char* filename
= (const char*) parameter
;
109 /* Allocate memory; check it's size; add to the pool. */
110 mem_pool
= rb
->plugin_get_audio_buffer(&mem_size
);
111 if(mem_size
< MIN_MEM_SIZE
)
113 rb
->splash(HZ
, "Not enough memory!");
116 add_pool(mem_pool
, mem_size
);
124 rb
->create_thread(&core_thread
,
127 0, /* FIXME Which flags? */
129 IF_PRIO(, MAX(PRIORITY_USER_INTERFACE
/ 2,
130 PRIORITY_REALTIME
+ 1))
133 rb
->create_thread(&gui_thread
,
136 0, /* FIXME Which flags? */
138 IF_PRIO(, PRIORITY_USER_INTERFACE
)
141 /* If having an error creating threads, bail out. */
142 if(core_thread_id
== 0 || gui_thread_id
== 0)
145 /* Wait for quit flag. */
149 /* Wait for threads to complete. */
150 rb
->thread_wait(gui_thread_id
);
151 rb
->thread_wait(core_thread_id
);
158 /***************************************************************************
160 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
161 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
162 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
163 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
167 * Copyright (C) 2009 Wincent Balin
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.
174 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
175 * KIND, either express or implied.
177 ****************************************************************************/
182 /* Welcome to the PDBox plugin */
190 unsigned int core_thread_id
;
191 unsigned int gui_thread_id
;
193 /* Stacks for threads. */
194 #define STACK_SIZE 16384
195 uint32_t core_stack
[STACK_SIZE
/ sizeof(uint32_t)];
196 uint32_t gui_stack
[STACK_SIZE
/ sizeof(uint32_t)];
200 void core_thread(void)
202 struct datagram ping
;
207 /* Wait for request. */
208 while(!RECEIVE_TO_CORE(&ping
))
211 if(memcmp("Ping!", ping
.data
, ping
.size
) == 0)
213 SEND_FROM_CORE("Pong!");
224 void gui_thread(void)
226 struct datagram pong
;
231 /* Send ping to the core. */
232 SEND_TO_CORE("Ping!");
233 rb
->splash(HZ
, "Sent ping.");
235 /* Wait for answer. */
236 while(!RECEIVE_FROM_CORE(&pong
))
239 /* If got a pong -- everything allright. */
240 if(memcmp("Pong!", pong
.data
, pong
.size
) == 0)
242 rb
->splash(HZ
, "Got pong!");
254 /* Plug-in entry point */
255 enum plugin_status
plugin_start(const void* parameter
)
262 /* Get the file name. */
263 const char* filename
= (const char*) parameter
;
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
)
270 rb
->splash(HZ
, "Not enough memory!");
273 add_pool(mem_pool
, mem_size
);
281 rb
->create_thread(&core_thread
,
284 0, /* FIXME Which flags? */
286 IF_PRIO(, MAX(PRIORITY_USER_INTERFACE
/ 2,
287 PRIORITY_REALTIME
+ 1))
290 rb
->create_thread(&gui_thread
,
293 0, /* FIXME Which flags? */
295 IF_PRIO(, PRIORITY_USER_INTERFACE
)
298 /* If having an error creating threads, bail out. */
299 if(core_thread_id
== 0 || gui_thread_id
== 0)
302 /* Wait for quit flag. */
306 /* Wait for threads to complete. */
307 rb
->thread_wait(gui_thread_id
);
308 rb
->thread_wait(core_thread_id
);