I am trying to implement a threaded equivalent of outlet_list(), which recursively copies the content of a list (symbol, argc, argv) into a ringbuffer at one end (worker thread) and retrieves them at the other end (audio thread). I have been looking through the Pd source code in and out but could not find a suitable function, except perhaps for those implemented in the [list] class, but they are not meant to be accessible from outside (static!).
struct t_outletrb_float_msg {
t_outlet* outlet;
t_float f;
};
// call this from the audio thread
void outletrb_floatprocess(ring_buffer* rb)
{
while(rb_available_to_read(rb) > sizeof(struct t_outletrb_float_msg))
{
struct t_outletrb_float_msg msg;
rb_read_from_buffer(rb, (char*)&msg, sizeof(msg));
t_outlet* x = msg.outlet;
t_float f = msg.f;
outlet_float(x, f);
}
}
// call this from the worker thread
void outletrb_float(ring_buffer* rb, t_outlet *x, t_float f)
{
struct t_outletrb_float_msg msg;
msg.outlet = x;
msg.f = f;
rb_write_to_buffer(rb, 1, (char*)&msg, sizeof(msg));
}
-------------------
b) and this is the INCOMPLETE ringbuffer implementation of outlet_list:
struct t_outletrb_list_msg {
t_outlet* outlet;
t_symbol* s;
int argc;
t_atom* argv;
}
// call this from the audio thread
void outletrb_listprocess(ring_buffer* rb)
{
///// retrieve the data from rb and use them for outlet_list();
}
// call this from the worker thread
void outletrb_list(ring_buffer* rb, t_outlet *x, t_symbol *s, int argc, t_atom *argv)
{
//??????? this is the function I am trying to figure out
}