[Csnd-dev] opcode deinit
Victor Lazzarini <[email protected]>
| Newsgroups | gmane.comp.audio.csound.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi all,
I have been thinking that we could regularise the opcode api by adding an (optional) deinit field
in OENTRY.
At the moment, opcodes requiring deinit need to explicitly register a callback with Csound. While this
works, it seems a bit awkward.
Since we have already removed the use for the “a” function field in the OENTRY, I thought we may
be able to reuse it for this purpose. For example,
OENTRY o = { “name”, S(STATE), 0, 3, "a", “aki", init_func, perf_func, deinit_func};
Not all opcode need this, but for the ones who do, this seems a more natural way to set it up.
The current deinit routine for an instrument is:
/* call the opcode deinitialisation routines of an instrument instance */
/* called from deact() in insert.c */
int csoundDeinitialiseOpcodes(CSOUND *csound, INSDS *ip)
{
int err = 0;
while (ip->nxtd != NULL) {
opcodeDeinit_t *dp = (opcodeDeinit_t*) ip->nxtd;
err |= dp->func(csound, dp->p);
ip->nxtd = (void*) dp->nxt;
free(dp);
}
return err;
}
and we would possibly modify it to be something simple like this:
int csoundDeinitialiseOpcodes(CSOUND *csound, INSDS *ip)
{
int err = 0;
OPDS dds = (OPDS *) ip;
while ((dds = dds->nxtp) != NULL)
err |= (*dds->dopadr)(csound, dds);
return err;
}
or thereabouts.
Any thoughts?
========================
Prof. Victor Lazzarini
Maynooth University
Ireland