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); }
// node destructor void Node_Dtor(Node *inNode) { Node_StateMsg(inNode, kNode_End); Node_Remove(inNode); World *world = inNode->mWorld; world->hw->mNodeLib->Remove(inNode); World_Free(world, inNode); }
SCErr SendReplyCmd_d_removed(World * inWorld,int inSize,char* inData, ReplyAddress *inReply) { void* space = World_Alloc(inWorld, sizeof(SendReplyCmd)); SendReplyCmd *cmd = new (space) SendReplyCmd(inWorld, inReply); if (!cmd) return kSCErr_Failed; int err = cmd->Init(inData, inSize); if (err) { cmd->~SendReplyCmd(); World_Free(inWorld, space); return err; } if (inWorld->mRealTime) cmd->CallNextStage(); else cmd->CallEveryStage(); return kSCErr_None; }
// create a new node int Node_New(World *inWorld, NodeDef *def, int32 inID, Node** outNode) { if (inID < 0) { if (inID == -1) { // -1 means generate an id for the event HiddenWorld* hw = inWorld->hw; inID = hw->mHiddenID = (hw->mHiddenID - 8) | 0x80000000; } else { return kSCErr_ReservedNodeID; } } if (World_GetNode(inWorld, inID)) { return kSCErr_DuplicateNodeID; } Node* node = (Node*)World_Alloc(inWorld, def->mAllocSize); node->mWorld = inWorld; node->mDef = def; node->mParent = 0; node->mPrev = 0; node->mNext = 0; node->mIsGroup = false; node->mID = inID; node->mHash = Hash(inID); if (!World_AddNode(inWorld, node)) { World_Free(inWorld, node); return kSCErr_TooManyNodes; } inWorld->hw->mRecentID = inID; *outNode = node; return kSCErr_None; }
static void NodeReplyMsg_RTFree(FifoMsg* msg) { //scprintf("NodeReplyMsg_RTFree()\n"); World_Free(msg->mWorld, msg->mData); }
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); }
BufReadChannelCmd::~BufReadChannelCmd() { World_Free(mWorld, mFilename); }
BufAllocReadCmd::~BufAllocReadCmd() { World_Free(mWorld, mFilename); }
BufGenCmd::~BufGenCmd() { World_Free(mWorld, mData); }
void SC_SequencedCommand::Delete() { CallDestructor(); World_Free(mWorld, this); }
AsyncPlugInCmd::~AsyncPlugInCmd() { (mCleanup)(mWorld, mCmdData); if (mMsgData) World_Free(mWorld, mMsgData); }
LoadSynthDefDirCmd::~LoadSynthDefDirCmd() { World_Free(mWorld, mFilename); }
RecvSynthDefCmd::~RecvSynthDefCmd() { World_Free(mWorld, mBuffer); }
SendFailureCmd::~SendFailureCmd() { World_Free(mWorld, mCmdName); World_Free(mWorld, mErrString); }
SC_SequencedCommand::~SC_SequencedCommand() { if (mMsgData) World_Free(mWorld, mMsgData); }
BufWriteCmd::~BufWriteCmd() { World_Free(mWorld, mFilename); }