[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-dev] reading an array from lang to C



>
> You are allocating a dynamically sized array on the stack (this is new
> style code, only works in C99 and gcc) then copying the data into it
> (not sure why since you already have a buffer: the Int8Array itself)
> and passing that to MIDISendSysex. Since data is on the stack it will
> go away immediately even though MIDISendSysEx is asynchronous (returns
> immediately before data has been sent) and requires that data to
> persist for the duration sending the data.
>

Thanks James, clearly I'm just too used closures in SC...

I am copying the Int8Array for fear of garbage collection.
It would certainly be more efficient to use it directly.
Is there some legal way to suspend gc on the array and then
have the completion routine restore it?

RJK


> Likewise MIDISysexSendRequest will need to persist for the duration of
> sending, but you allocate it on the stack and also do not zero it out
> or initialize all of its fields.
>
>
> >
> >     PyrSlot *u = g->sp - 1;
> >     err = slotIntVal(u, &uid);
> >     if (err) return err;
> >
> >     MIDIEndpointRef dest;
> >     MIDIObjectType mtype;
> >     MIDIObjectFindByUniqueID(uid, (MIDIObjectRef*)&dest, &mtype);
> >     if (mtype != kMIDIObjectType_Destination) return errFailed;
> >     if (!dest) return errFailed;
> >
> >     sendsysex(dest, size, data);
> >     return errNone;
> > }
> >
> >
> > // in the lang:  +MIDIOut { sysex { arg uid, Int8Array; _SendSysex } }
> > _______________________________________________
> > sc-dev mailing list
> > sc-dev@xxxxxxxxxxxxxxx
> > http://www.create.ucsb.edu/mailman/listinfo/sc-dev
> >
> >
> --
> --- james mccartney   james@xxxxxxxxxxxxxx   <http://www.audiosynth.com>
> SuperCollider - a real time audio synthesis programming language
>
> _______________________________________________
> sc-dev mailing list
> sc-dev@xxxxxxxxxxxxxxx
> http://www.create.ucsb.edu/mailman/listinfo/sc-dev
>