MCPcopy Create free account
hub / github.com/csound/csound / deact

Function deact

Engine/insert.c:900–948  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

898int useropcd(CSOUND *, UOPCODE*);
899
900static void deact(CSOUND *csound, INSDS *ip)
901{ /* unlink single instr from activ chain */
902 INSDS *nxtp; /* and mark it inactive */
903 /* close any files in fd chain */
904
905 if (ip->nxtd != NULL)
906 csoundDeinitialiseOpcodes(csound, ip);
907 /* remove an active instrument */
908 csound->engineState.instrtxtp[ip->insno]->active--;
909 if (ip->xtratim > 0)
910 csound->engineState.instrtxtp[ip->insno]->pending_release--;
911 csound->cpu_power_busy -= csound->engineState.instrtxtp[ip->insno]->cpuload;
912 /* IV - Sep 8 2002: free subinstr instances */
913 /* that would otherwise result in a memory leak */
914 if (ip->opcod_deact) {
915 UOPCODE *p = (UOPCODE*) ip->opcod_deact; /* IV - Oct 26 2002 */
916 deact(csound, p->ip); /* deactivate */
917 p->ip = NULL;
918 /* IV - Oct 26 2002: set perf routine to "not initialised" */
919 p->h.opadr = (SUBR) useropcd;
920 ip->opcod_deact = NULL;
921 }
922 if (ip->subins_deact) {
923 deact(csound, ((SUBINST*) ip->subins_deact)->ip); /* IV - Oct 24 2002 */
924 ((SUBINST*) ip->subins_deact)->ip = NULL;
925 ip->subins_deact = NULL;
926 }
927 if (UNLIKELY(csound->oparms->odebug)) {
928 char *name = csound->engineState.instrtxtp[ip->insno]->insname;
929 if (UNLIKELY(name))
930 csound->Message(csound, Str("removed instance of instr %s\n"), name);
931 else
932 csound->Message(csound, Str("removed instance of instr %d\n"), ip->insno);
933 }
934 /* IV - Oct 24 2002: ip->prvact may be NULL, so need to check */
935 if (ip->prvact && (nxtp = ip->prvact->nxtact = ip->nxtact) != NULL) {
936 nxtp->prvact = ip->prvact;
937 }
938 ip->actflg = 0;
939 /* link into free instance chain */
940 /* This also destroys ip->nxtact causing loops */
941 if (csound->engineState.instrtxtp[ip->insno] == ip->instr){
942 ip->nxtact = csound->engineState.instrtxtp[ip->insno]->act_instance;
943 csound->engineState.instrtxtp[ip->insno]->act_instance = ip;
944 }
945 if (ip->fdchp != NULL)
946 fdchclose(csound, ip);
947 csound->dag_changed++;
948}
949
950
951int kill_instance(CSOUND *csound, KILLOP *p) {

Callers 3

xturnoffFunction · 0.85
beatexpireFunction · 0.85
timexpireFunction · 0.85

Calls 3

fdchcloseFunction · 0.85
MessageMethod · 0.80

Tested by

no test coverage detected