Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4793
Modified Files: Tag: devel_0_39 desire.c Log Message: added the update-queue and the update-manager and the observer-notice-forwarder (gobj_changed3) and made toplevel canvases send to the queue.
Index: desire.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v retrieving revision 1.1.2.39 retrieving revision 1.1.2.40 diff -C2 -d -r1.1.2.39 -r1.1.2.40 *** desire.c 28 Oct 2005 12:53:07 -0000 1.1.2.39 --- desire.c 28 Oct 2005 23:34:11 -0000 1.1.2.40 *************** *** 34,38 ****
//-------------------------------------------------------------------------- ! // t_appendix: an extension to t_gobj written by Mathieu Bouchard so that // all t_gobj's may have new fields without sacrificing binary compat with // externals compiled for PureMSP. --- 34,38 ----
//-------------------------------------------------------------------------- ! // t_appendix: an extension to t_gobj made by matju so that // all t_gobj's may have new fields without sacrificing binary compat with // externals compiled for PureMSP. *************** *** 71,75 **** t_atom argv[1]; SETFLOAT(argv,(float)dirty); ! gobj_changed2(self,1,argv); }
--- 71,75 ---- t_atom argv[1]; SETFLOAT(argv,(float)dirty); ! gobj_changed3(self,self,1,argv); }
*************** *** 78,81 **** --- 78,86 ---- void gobj_changed2 (void *self_, int argc, t_atom *argv) { t_gobj *self = (t_gobj *)self_; + gobj_changed3(self,self,argc,argv); + } + + void gobj_changed3 (void *self_, t_gobj *origin, int argc, t_atom *argv) { + t_gobj *self = (t_gobj *)self_; t_appendix *d = self->g_adix; int i; *************** *** 83,87 **** t_gobj *obs = d->obs[i]; t_notice ice = obs->g_pd->c_notice; ! if (ice) ice(obs,self,argc,argv); else post("null func ptr for class %s",self->g_pd->c_name->s_name); --- 88,92 ---- t_gobj *obs = d->obs[i]; t_notice ice = obs->g_pd->c_notice; ! if (ice) ice(obs,origin,argc,argv); else post("null func ptr for class %s",self->g_pd->c_name->s_name); *************** *** 90,95 **** --- 95,165 ----
//-------------------------------------------------------------------------- + // some simple ringbuffer-style queue + // when this becomes too small, use a bigger constant or a better impl. + + #define QUEUE_SIZE 1024 + typedef struct _queue { + int start,len; + void *o[QUEUE_SIZE]; + } t_queue; + + t_queue *queue_new (void) { + t_queue *self = (t_queue *)malloc(sizeof(t_queue)); + self->start = self->len = 0; + return self; + } + + void queue_put (t_queue *self, void *stuff) { + if (self->len==QUEUE_SIZE) {bug("queue full"); return;} + self->o[(self->start+self->len)%QUEUE_SIZE] = stuff; + self->len++; + } + + void *queue_get (t_queue *self) { + void *r = self->o[self->start]; + self->start = (self->start+1)%QUEUE_SIZE; + self->len--; + return r; + } + + int queue_empty (t_queue *self) {return self->len==0;} + int queue_full (t_queue *self) {return self->len==QUEUE_SIZE;} + + //-------------------------------------------------------------------------- // update manager:
+ typedef struct _manager { + t_queue *q; + t_clock *clock; + } t_manager; + + t_manager *manager; + + void manager_call (void *foo) { + t_manager *self = (t_manager *)foo; + while (!queue_empty(self->q)) { + t_gobj *o = (t_gobj *)queue_get(self->q); + if (!o->g_adix->dirtyc) continue; + pd_upload(o); + o->g_adix->dirtyc = 0; + } + clock_delay(self->clock,50); + } + + void manager_notice (t_manager *self, t_gobj *origin, int argc, t_atom *argv) { + t_appendix *a = (t_appendix *)origin->g_adix; + if (!a->dirtyc) queue_put(self->q,origin); + a->dirtyc = 1; + SETFLOAT(a->dirtyv,-1); /* in the future this will contain real data */ + } + + t_manager *manager_new (void) { + t_manager *self = (t_manager *)malloc(sizeof(t_manager)); + self->q = queue_new(); + self->clock = clock_new(self,(t_method)manager_call); + clock_delay(self->clock,0); + return self; + } + //-------------------------------------------------------------------------- /* the "glist" class is also known as "canvas" (the two used *************** *** 13336,13340 **** --- 13406,13416 ----
void canvas_notice(t_gobj *x, struct _gobj *origin, int argc, t_atom *argv) { + t_canvas *self = (t_canvas *)x; post("canvas_notice(%p,%p,%d,...)",x,origin,argc); + if (self->gl_havewindow) { + manager_notice(manager,origin,argc,argv); + } else { + + } }
*************** *** 13438,13441 **** --- 13514,13518 ----
void desire_setup(void) { + manager = manager_new(); #define S(x) x##_setup(); S(vinlet) S(voutlet)