// Handle the FLOWGRAPH_DESTROY_RESOURCES message. // Returns TRUE if the message was handled, otherwise FALSE. UtlBoolean MpFlowGraphBase::handleDestroyResources(void) { int i; int numResources; MpResource* pResource; // if not already stopped, then stop the flow graph if (mCurState == STARTED) if (handleStop() == FALSE) { assert(FALSE); return FALSE; } // iterate over all resources // BE VERY CAREFUL HERE. The handleRemoveResource() operation // SHUFFLES the array we are using to tell us what resources need // to be removed. // You have been warned. numResources = mResourceCnt; for (i=numResources-1; i >= 0; i--) { pResource = mUnsorted[i]; // disconnect all inputs and outputs if ((disconnectAllInputs(pResource) == FALSE) || (disconnectAllOutputs(pResource) == FALSE)) { assert(FALSE); return FALSE; } // remove the resource from the flow graph if (handleRemoveResource(pResource) == FALSE) { assert(FALSE); return FALSE; } // destroy the resource delete pResource; } return TRUE; }
void Node::disconnectAll() { disconnectAllInputs(); disconnectAllOutputs(); }
void AudioNodeOutput::disconnectAll() { disconnectAllInputs(); disconnectAllParams(); }
// Handle the FLOWGRAPH_REMOVE_RESOURCE message. // Returns TRUE if the message was handled, otherwise FALSE. UtlBoolean MpFlowGraphBase::handleRemoveResource(MpResource* pResource) { UtlBoolean found; int i; UtlString* pDictKey; UtlString* pKey; // make sure this resource is part of this flow graph if (pResource->getFlowGraph() != this) { Zprintf("handleRemoveResource:\n" " pResource=0x%p, pResource->getFlowGraph()=0x%p, this=0x%p\n", pResource, (pResource->getFlowGraph()), this, 0,0,0); assert(FALSE); return FALSE; } // remove all input links from this resource if (disconnectAllInputs(pResource) == FALSE) { assert(FALSE); return FALSE; } // remove all output links from this resource if (disconnectAllOutputs(pResource) == FALSE) { assert(FALSE); return FALSE; } // remove the entry from the dictionary for this resource OsSysLog::add(FAC_MP, PRI_DEBUG, "MpFlowGraphBase::handleRemoveResource %s\n", pResource->getName().data()); pKey = new UtlString(pResource->getName()); pDictKey = (UtlString*) mResourceDict.remove(pKey); delete pKey; if (pDictKey == NULL) { assert(FALSE); // no entry found for the resource return FALSE; } delete pDictKey; // get rid of the dictionary key for the entry // remove the resource from the unsorted array of resources for this graph found = FALSE; for (i=0; i < mResourceCnt; i++) { if (found) { // shift entries following the mUnsorted[i-1] = mUnsorted[i]; // deleted resource down by one } else if (mUnsorted[i] == pResource) { found = TRUE; mUnsorted[i] = NULL; // clear the entry } } if (!found) { assert(FALSE); // didn't find the entry return FALSE; } pResource->setFlowGraph(NULL); // remove the reference to this flow graph mResourceCnt--; mUnsorted[mResourceCnt] = NULL; mRecomputeOrder = TRUE; return TRUE; }