Re: [Csnd-dev] opcode deinit
Steven Yi <[email protected]>
| Newsgroups | gmane.comp.audio.csound.devel |
|---|---|
| Message-ID | <CANtcCs6LBqT9E9ZSyXaqw-hRw3=tV-A4Z2d=7rTmciO53GgN3g@mail.gmail.com> |
I'm in favor of this, it's a much clearer design. I'd also recommend removing csoundRegisterDeinitCallback() from the API. On Tue, Mar 26, 2024 at 10:35 AM Victor Lazzarini <[email protected]> wrote: > > 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 >