| 2720 | } |
| 2721 | |
| 2722 | int csoundKillInstanceInternal(CSOUND *csound, MYFLT instr, char *instrName, |
| 2723 | int mode, int allow_release, int async) |
| 2724 | { |
| 2725 | INSDS *ip; |
| 2726 | int insno; |
| 2727 | |
| 2728 | if (instrName) { |
| 2729 | instr = named_instr_find(csound, instrName); |
| 2730 | insno = (int) instr; |
| 2731 | } else insno = instr; |
| 2732 | |
| 2733 | if (UNLIKELY(insno < 1 || insno > (int) csound->engineState.maxinsno || |
| 2734 | csound->engineState.instrtxtp[insno] == NULL)) { |
| 2735 | return CSOUND_ERROR; |
| 2736 | } |
| 2737 | |
| 2738 | if (UNLIKELY(mode < 0 || mode > 15 || (mode & 3) == 3)) { |
| 2739 | csoundUnlockMutex(csound->API_lock); |
| 2740 | return CSOUND_ERROR; |
| 2741 | } |
| 2742 | ip = &(csound->actanchor); |
| 2743 | |
| 2744 | while ((ip = ip->nxtact) != NULL && (int) ip->insno != insno); |
| 2745 | if (UNLIKELY(ip == NULL)) { |
| 2746 | return CSOUND_ERROR; |
| 2747 | } |
| 2748 | |
| 2749 | if (!async) { |
| 2750 | csoundLockMutex(csound->API_lock); |
| 2751 | killInstance(csound, instr, insno, ip, mode, allow_release); |
| 2752 | csoundUnlockMutex(csound->API_lock); |
| 2753 | } |
| 2754 | else |
| 2755 | killInstance_enqueue(csound, instr, insno, ip, mode, allow_release); |
| 2756 | return CSOUND_SUCCESS; |
| 2757 | } |
no test coverage detected