void World_Cleanup(World *world) { if (!world) return; HiddenWorld *hw = world->hw; if (hw && world->mRealTime) hw->mAudioDriver->Stop(); world->mRunning = false; if (world->mTopGroup) Group_DeleteAll(world->mTopGroup); world->mDriverLock->Lock(); // never unlock.. if (hw) { free(hw->mWireBufSpace); delete hw->mAudioDriver; hw->mAudioDriver = 0; } delete world->mNRTLock; delete world->mDriverLock; World_Free(world, world->mTopGroup); for (uint32 i=0; i<world->mNumSndBufs; ++i) { SndBuf *nrtbuf = world->mSndBufsNonRealTimeMirror + i; SndBuf * rtbuf = world->mSndBufs + i; if (nrtbuf->data) free(nrtbuf->data); if (rtbuf->data && rtbuf->data != nrtbuf->data) free(rtbuf->data); #ifndef NO_LIBSNDFILE if (nrtbuf->sndfile) sf_close(nrtbuf->sndfile); if (rtbuf->sndfile && rtbuf->sndfile != nrtbuf->sndfile) sf_close(rtbuf->sndfile); #endif } free(world->mSndBufsNonRealTimeMirror); free(world->mSndBufs); free(world->mControlBusTouched); free(world->mAudioBusTouched); free(world->mControlBus); free(world->mAudioBus); delete [] world->mRGen; if (hw) { #ifndef NO_LIBSNDFILE if (hw->mNRTInputFile) sf_close(hw->mNRTInputFile); if (hw->mNRTOutputFile) sf_close(hw->mNRTOutputFile); if (hw->mNRTCmdFile) fclose(hw->mNRTCmdFile); #endif free(hw->mUsers); delete hw->mNodeLib; delete hw->mGraphDefLib; delete hw->mQuitProgram; delete hw->mAllocPool; free(hw); } free(world); }
SCErr meth_g_freeAll(World *inWorld, int inSize, char *inData, ReplyAddress* /*inReply*/) { sc_msg_iter msg(inSize, inData); while (msg.remain()) { Group *group = Msg_GetGroup(inWorld, msg); if (!group) return kSCErr_GroupNotFound; Group_DeleteAll(group); } return kSCErr_None; }
void World_Cleanup(World *world, bool unload_plugins) { if (!world) return; if (scsynth::asioThreadStarted()){ scsynth::stopAsioThread(); } if(unload_plugins) deinitialize_library(); HiddenWorld *hw = world->hw; if (hw && world->mRealTime) hw->mAudioDriver->Stop(); world->mRunning = false; if (world->mTopGroup) Group_DeleteAll(world->mTopGroup); reinterpret_cast<SC_Lock*>(world->mDriverLock)->lock(); if (hw) { sc_free(hw->mWireBufSpace); delete hw->mAudioDriver; hw->mAudioDriver = 0; } delete reinterpret_cast<SC_Lock*>(world->mNRTLock); reinterpret_cast<SC_Lock*>(world->mDriverLock)->unlock(); delete reinterpret_cast<SC_Lock*>(world->mDriverLock); World_Free(world, world->mTopGroup); for (uint32 i=0; i<world->mNumSndBufs; ++i) { SndBuf *nrtbuf = world->mSndBufsNonRealTimeMirror + i; SndBuf * rtbuf = world->mSndBufs + i; if (nrtbuf->data) free_alig(nrtbuf->data); if (rtbuf->data && rtbuf->data != nrtbuf->data) free_alig(rtbuf->data); #ifndef NO_LIBSNDFILE if (nrtbuf->sndfile) sf_close(nrtbuf->sndfile); if (rtbuf->sndfile && rtbuf->sndfile != nrtbuf->sndfile) sf_close(rtbuf->sndfile); #endif } free_alig(world->mSndBufsNonRealTimeMirror); free_alig(world->mSndBufs); free_alig(world->mControlBusTouched); free_alig(world->mAudioBusTouched); if (hw->mShmem) { delete hw->mShmem; } else free_alig(world->mControlBus); free_alig(world->mAudioBus); delete [] world->mRGen; if (hw) { #ifndef NO_LIBSNDFILE if (hw->mNRTInputFile) sf_close(hw->mNRTInputFile); if (hw->mNRTOutputFile) sf_close(hw->mNRTOutputFile); if (hw->mNRTCmdFile) fclose(hw->mNRTCmdFile); #endif delete hw->mUsers; delete hw->mAvailableClientIDs; delete hw->mClientIDdict; delete hw->mNodeLib; delete hw->mGraphDefLib; delete hw->mQuitProgram; delete hw->mAllocPool; free_alig(hw); } free_alig(world); }
void Group_Dtor(Group *inGroup) { Group_DeleteAll(inGroup); inGroup->mNode.mWorld->mNumGroups--; Node_Dtor(&inGroup->mNode); }
void Unit_DoneAction(int doneAction, Unit *unit) { switch (doneAction) { case 1 : Node_SetRun(&unit->mParent->mNode, 0); break; case 2 : Node_End(&unit->mParent->mNode); break; case 3 : { Node_End(&unit->mParent->mNode); Node* prev = unit->mParent->mNode.mPrev; if (prev) Node_End(prev); } break; case 4 : { Node_End(&unit->mParent->mNode); Node* next = unit->mParent->mNode.mNext; if (next) Node_End(next); } break; case 5 : { Node_End(&unit->mParent->mNode); Node* prev = unit->mParent->mNode.mPrev; if (!prev) break; if (prev && prev->mIsGroup) Group_DeleteAll((Group*)prev); else Node_End(prev); } break; case 6 : { Node_End(&unit->mParent->mNode); Node* next = unit->mParent->mNode.mNext; if (!next) break; if (next->mIsGroup) Group_DeleteAll((Group*)next); else Node_End(next); } break; case 7 : { Node* node = &unit->mParent->mNode; while (node) { Node *prev = node->mPrev; Node_End(node); node = prev; } } break; case 8 : { Node* node = &unit->mParent->mNode; while (node) { Node *next = node->mNext; Node_End(node); node = next; } } break; case 9 : { Node_End(&unit->mParent->mNode); Node* prev = unit->mParent->mNode.mPrev; if (prev) Node_SetRun(prev, 0); } break; case 10 : { Node_End(&unit->mParent->mNode); Node* next = unit->mParent->mNode.mNext; if (next) Node_SetRun(next, 0); } break; case 11 : { Node_End(&unit->mParent->mNode); Node* prev = unit->mParent->mNode.mPrev; if (!prev) break; if (prev->mIsGroup) Group_DeepFreeGraphs((Group*)prev); else Node_End(prev); } break; case 12 : { Node_End(&unit->mParent->mNode); Node* next = unit->mParent->mNode.mNext; if (!next) break; if (next->mIsGroup) Group_DeepFreeGraphs((Group*)next); else Node_End(next); } break; case 13 : { Node* node = unit->mParent->mNode.mParent->mHead; while (node) { Node *next = node->mNext; Node_End(node); node = next; } } break; case 14 : Node_End(&unit->mParent->mNode.mParent->mNode); break; } }