1
0
Fork 0
forked from len0rd/rockbox

Patch from Wincent Balin: Remove some duplicate code from the PDa plugin

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21049 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Peter D'Hoye 2009-05-23 06:24:18 +00:00
parent 1865af9a6d
commit 655ae81cf8
5 changed files with 3 additions and 468 deletions

View file

@ -89,7 +89,9 @@ PDa/src/x_gui.c
/*
PDa/src/d_imayer_fft.c
*/
/*
PDa/src/m_fixed.c
*/
/*
PDa/intern/biquad~.c
@ -163,168 +165,4 @@ PDa/extra/slider.c
PDa/extra/sliderh.c
PDa/extra/zerox~.c
*/
pdbox.c
pdbox-net.c
/*
dbestfit-3.3/bmalloc.c
dbestfit-3.3/bysize.c
dbestfit-3.3/dmalloc.c
*/
/*
PDa/src/g_canvas.c
PDa/src/g_graph.c
PDa/src/g_text.c
*/
/* PDa/src/g_rtext.c Does not compile */
/*
PDa/src/g_array.c
PDa/src/g_template.c
PDa/src/g_io.c
PDa/src/g_scalar.c
PDa/src/g_traversal.c
PDa/src/g_guiconnect.c
PDa/src/g_readwrite.c
PDa/src/g_editor.c
PDa/src/g_all_guis.c
PDa/src/g_bang.c
PDa/src/g_hdial.c
PDa/src/g_hslider.c
PDa/src/g_mycanvas.c
PDa/src/g_numbox.c
PDa/src/g_toggle.c
PDa/src/g_vdial.c
PDa/src/g_vslider.c
PDa/src/g_vumeter.c
PDa/src/m_pd.c
PDa/src/m_class.c
PDa/src/m_obj.c
PDa/src/m_atom.c
*/
/*
PDa/src/m_memory.c
*/
/* PDa/src/m_binbuf.c Does not compile, file handling stuff */
/*
PDa/src/m_conf.c
PDa/src/m_glob.c
PDa/src/m_sched.c
*/
/* PDa/src/s_main.c Does not compile, system reasons */
/* PDa/src/s_inter.c Does not compile, BSD sockets */
/* PDa/src/s_file.c Does not compile, file handling stuff */
/* PDa/src/s_print.c Does not compile, system reasons */
/*
PDa/src/s_loader.c
*/
/* PDa/src/s_path.c Does not compile, file handling stuff */
/*
PDa/src/s_entry.c
PDa/src/s_audio.c
PDa/src/s_midi.c
PDa/src/d_ugen.c
PDa/src/d_arithmetic.c
PDa/src/d_dac.c
PDa/src/d_misc.c
PDa/src/d_fft.c
PDa/src/d_mayer_fft.c
PDa/src/d_fftroutine.c
PDa/src/d_global.c
PDa/src/d_resample.c
PDa/src/d_ctl.c
*/
/* PDa/src/d_soundfile.c Does not compile, file handling stuff */
/*
PDa/src/x_arithmetic.c
PDa/src/x_connective.c
PDa/src/x_interface.c
PDa/src/x_midi.c
PDa/src/x_misc.c
PDa/src/x_time.c
PDa/src/x_acoustics.c
*/
/* PDa/src/x_net.c Does not compile, BSD sockets */
/*
PDa/src/x_qlist.c
PDa/src/x_gui.c
*/
/*
PDa/src/d_imayer_fft.c
*/
PDa/src/m_fixed.c
/*
PDa/intern/biquad~.c
PDa/intern/bp~.c
PDa/intern/clip~.c
PDa/intern/cos~.c
PDa/intern/dbtopow~.c
PDa/intern/dbtorms~.c
PDa/intern/delread~.c
PDa/intern/delwrite~.c
PDa/intern/env~.c
PDa/intern/ftom~.c
PDa/intern/hip~.c
PDa/intern/intern_setup.c
PDa/intern/line~.c
PDa/intern/lop~.c
PDa/intern/mtof~.c
PDa/intern/noise~.c
PDa/intern/osc~.c
PDa/intern/phasor~.c
PDa/intern/powtodb~.c
PDa/intern/print~.c
PDa/intern/rmstodb~.c
PDa/intern/rsqrt~.c
PDa/intern/samphold~.c
*/
/* PDa/intern/sfread~.c Does not compile, file handling stuff */
/* PDa/intern/sfwrite~.c Does not compile, file handling stuff */
/*
PDa/intern/sig~.c
PDa/intern/snapshot~.c
PDa/intern/sqrt~.c
PDa/intern/tabosc4~.c
PDa/intern/tabplay~.c
PDa/intern/tabread.c
PDa/intern/tabread4~.c
PDa/intern/tabread~.c
PDa/intern/tabreceive~.c
PDa/intern/tabsend~.c
PDa/intern/tabwrite.c
PDa/intern/tabwrite~.c
PDa/intern/threshold~.c
PDa/intern/vcf~.c
PDa/intern/vd~.c
PDa/intern/vline~.c
PDa/intern/vsnapshot~.c
PDa/intern/wrap~.c
*/
/*
PDa/extra/OSCroute.c
PDa/extra/bandpass.c
*/
/* PDa/extra/dumpOSC.c Does not compile, file handling stuff */
/*
PDa/extra/equalizer.c
PDa/extra/gcanvas.c
PDa/extra/highpass.c
PDa/extra/highshelf.c
PDa/extra/hlshelf.c
PDa/extra/image.c
PDa/extra/lowpass.c
PDa/extra/lowshelf.c
PDa/extra/moog~.c
PDa/extra/notch.c
*/
/* PDa/extra/sendOSC.c Does not compile, file handling stuff */
/*
PDa/extra/shell.c
PDa/extra/slider.c
PDa/extra/sliderh.c
PDa/extra/zerox~.c
*/

View file

@ -117,122 +117,4 @@ void net_destroy(void)
rb->queue_delete(&gui_to_core);
rb->queue_delete(&core_to_gui);
}
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2009 Wincent Balin
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "plugin.h"
#include "pdbox.h"
/* Datagram pool will contains 16 datagrams. */
#define MAX_DATAGRAMS 16
/* Datagram pool. */
struct datagram datagrams[MAX_DATAGRAMS];
/* UDP message queues. */
struct event_queue gui_to_core;
struct event_queue core_to_gui;
/* Initialize net infrastructure. */
void net_init(void)
{
unsigned int i;
/* Initialize message pool. */
for(i = 0; i < MAX_DATAGRAMS; i++)
datagrams[i].used = false;
/* Initialize and register message queues. */
rb->queue_init(&gui_to_core, true);
rb->queue_init(&core_to_gui, true);
}
/* Send datagram. */
bool send_datagram(struct event_queue* route,
int port,
char* data,
size_t size)
{
unsigned int i;
/* If datagram too long, abort. */
if(size > MAX_DATAGRAM_SIZE)
return false;
/* Find free datagram buffer. */
for(i = 0; i < MAX_DATAGRAMS; i++)
if(!datagrams[i].used)
break;
/* If no free buffer found, abort. */
if(i == MAX_DATAGRAMS)
return false;
/* Copy datagram to the buffer. */
rb->memcpy(datagrams[i].data, data, size);
datagrams[i].size = size;
/* Mark datagram buffer as used. */
datagrams[i].used = true;
/* Send event via route. */
rb->queue_post(route, port, (intptr_t) &datagrams[i]);
/* Everything went ok. */
return true;
}
/* Receive datagram. */
bool receive_datagram(struct event_queue* route,
int port,
struct datagram* buffer)
{
struct queue_event event;
/* If route queue empty, abort. */
if(rb->queue_empty(route))
return false;
/* Receive event. */
rb->queue_wait(route, &event);
/* If wrong port, abort.
NOTE: Event is removed from the queue in any case! */
if(event.id != port)
return false;
/* Copy datagram. */
rb->memcpy(buffer, (struct datagram*) event.data, sizeof(struct datagram));
/* Free datagram buffer. */
((struct datagram*) event.data)->used = false;
/* Everything went ok. */
return true;
}
/* Destroy net infrastructure. */
void net_destroy(void)
{
/* Remove message queues. */
rb->queue_delete(&gui_to_core);
rb->queue_delete(&core_to_gui);
}

View file

@ -155,160 +155,4 @@ enum plugin_status plugin_start(const void* parameter)
return PLUGIN_OK;
}
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2009 Wincent Balin
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "plugin.h"
#include "pdbox.h"
/* Welcome to the PDBox plugin */
PLUGIN_HEADER
PLUGIN_IRAM_DECLARE
/* Quit flag. */
bool quit = false;
/* Thread IDs. */
unsigned int core_thread_id;
unsigned int gui_thread_id;
/* Stacks for threads. */
#define STACK_SIZE 16384
uint32_t core_stack[STACK_SIZE / sizeof(uint32_t)];
uint32_t gui_stack[STACK_SIZE / sizeof(uint32_t)];
/* Core thread */
void core_thread(void)
{
struct datagram ping;
/* Main loop */
while(!quit)
{
/* Wait for request. */
while(!RECEIVE_TO_CORE(&ping))
rb->yield();
if(memcmp("Ping!", ping.data, ping.size) == 0)
{
SEND_FROM_CORE("Pong!");
break;
}
rb->yield();
}
rb->thread_exit();
}
/* GUI thread */
void gui_thread(void)
{
struct datagram pong;
/* GUI loop */
while(!quit)
{
/* Send ping to the core. */
SEND_TO_CORE("Ping!");
rb->splash(HZ, "Sent ping.");
/* Wait for answer. */
while(!RECEIVE_FROM_CORE(&pong))
rb->yield();
/* If got a pong -- everything allright. */
if(memcmp("Pong!", pong.data, pong.size) == 0)
{
rb->splash(HZ, "Got pong!");
quit = true;
break;
}
rb->yield();
}
rb->thread_exit();
}
/* Plug-in entry point */
enum plugin_status plugin_start(const void* parameter)
{
PLUGIN_IRAM_INIT(rb)
size_t mem_size;
void* mem_pool;
/* Get the file name. */
const char* filename = (const char*) parameter;
#if 0
/* Allocate memory; check it's size; add to the pool. */
mem_pool = rb->plugin_get_audio_buffer(&mem_size);
if(mem_size < MIN_MEM_SIZE)
{
rb->splash(HZ, "Not enough memory!");
return PLUGIN_ERROR;
}
add_pool(mem_pool, mem_size);
#endif
/* Initialze net. */
net_init();
/* Start threads. */
core_thread_id =
rb->create_thread(&core_thread,
core_stack,
sizeof(core_stack),
0, /* FIXME Which flags? */
"PD core"
IF_PRIO(, MAX(PRIORITY_USER_INTERFACE / 2,
PRIORITY_REALTIME + 1))
IF_COP(, COP));
gui_thread_id =
rb->create_thread(&gui_thread,
gui_stack,
sizeof(gui_stack),
0, /* FIXME Which flags? */
"PD GUI"
IF_PRIO(, PRIORITY_USER_INTERFACE)
IF_COP(, CPU));
/* If having an error creating threads, bail out. */
if(core_thread_id == 0 || gui_thread_id == 0)
return PLUGIN_ERROR;
/* Wait for quit flag. */
while(!quit)
rb->yield();
/* Wait for threads to complete. */
rb->thread_wait(gui_thread_id);
rb->thread_wait(core_thread_id);
/* Destroy net. */
net_destroy();
return PLUGIN_OK;
}

View file

@ -140,3 +140,4 @@ extern struct event_queue core_to_gui;
receive_datagram(&core_to_gui, PD_GUI_PORT, buffer)
#endif

View file

@ -29,34 +29,4 @@ PDBOXFLAGS = $(PLUGINFLAGS) \
$(PDBOXBUILDDIR)/%.o: $(PDBOXSRCDIR)/%.c $(PDBOXSRCDIR)/pdbox.make
$(SILENT)mkdir -p $(dir $@)
$(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PDBOXFLAGS) -c $< -o $@
# __________ __ ___.
# Open \______ \ ____ ____ | | _\_ |__ _______ ___
# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
# \/ \/ \/ \/ \/
# $Id$
#
PDBOXSRCDIR := $(APPSDIR)/plugins/pdbox
PDBOXBUILDDIR := $(BUILDDIR)/apps/plugins/pdbox
ROCKS += $(PDBOXBUILDDIR)/pdbox.rock
PDBOXSRC := $(call preprocess, $(PDBOXSRCDIR)/SOURCES)
PDBOXOBJ := $(call c2obj, $(PDBOXSRC))
# add source files to OTHERSRC to get automatic dependencies
OTHERSRC += $(PDBOXSRC)
$(PDBOXBUILDDIR)/pdbox.rock: $(PDBOXOBJ)
PDBOXFLAGS = $(PLUGINFLAGS) \
-DFIXEDPOINT -DSTATIC -DPD \
-I$(PDBOXSRCDIR) -I$(PDBOXSRCDIR)/PDa/src \
-DBMALLOC -I$(PDBOXSRCDIR)/dbestfit-3.3
# Compile PDBox with extra flags (adapted from ZXBox)
$(PDBOXBUILDDIR)/%.o: $(PDBOXSRCDIR)/%.c $(PDBOXSRCDIR)/pdbox.make
$(SILENT)mkdir -p $(dir $@)
$(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PDBOXFLAGS) -c $< -o $@