int MpTopologyGraph::addVirtualOutputs(MpResourceTopology& resourceTopology, UtlHashBag& newResources, UtlBoolean replaceNumInName, int resourceNum) { int portsAdded = 0; MpResourceTopology::VirtualPortIterator portIter; UtlString realResourceName; int realPortIdx; UtlString virtualResourceName; int virtualPortIdx; resourceTopology.initVirtualOutputIterator(portIter); while (resourceTopology.getNextVirtualOutput(portIter, realResourceName, realPortIdx, virtualResourceName, virtualPortIdx) == OS_SUCCESS) { if(replaceNumInName) { MpResourceTopology::replaceNumInName(realResourceName, resourceNum); MpResourceTopology::replaceNumInName(virtualResourceName, resourceNum); } // Lookup real resource. MpResource *pResource = (MpResource*)newResources.find(&realResourceName); assert(pResource); if (!pResource) { continue; } // Check port index correctness. Note, that this check gracefully // handles case with realPortIdx equal -1. if (realPortIdx >= pResource->maxOutputs()) { assert(!"Trying to map virtual port to non existing real port!"); continue; } // Add entry to virtual ports map. // We need to create UtlVoidPtr wrapper for pResource, or it will be // destroyed on pair deletion. UtlContainablePair *pRealPort = new UtlContainablePair(new UtlVoidPtr(pResource), new UtlInt(realPortIdx)); UtlContainablePair *pVirtPort = new UtlContainablePair(new UtlString(virtualResourceName), new UtlInt(virtualPortIdx)); mVirtualOutputs.insertKeyAndValue(pVirtPort, pRealPort); portsAdded++; } resourceTopology.freeVirtualOutputIterator(portIter); return portsAdded; }
// Removes the link between the "outPortIdx" port of the "rFrom" // resource and its downstream counterpart. If the flow graph is not // "started", this call takes effect immediately. Otherwise, the call // takes effect at the start of the next frame processing interval. // Returns OS_SUCCESS if the link is removed. Returns // OS_INVALID_ARGUMENT if the caller specified an invalid port index. OsStatus MpFlowGraphBase::removeLink(MpResource& rFrom, int outPortIdx) { OsWriteLock lock(mRWMutex); UtlBoolean handled; MpFlowGraphMsg msg(MpFlowGraphMsg::FLOWGRAPH_REMOVE_LINK, NULL, &rFrom, NULL, outPortIdx); if (outPortIdx < 0 || outPortIdx >= rFrom.maxOutputs()) return OS_INVALID_ARGUMENT; if (mCurState == STARTED) return postMessage(msg); handled = handleMessage(msg); if (handled) return OS_SUCCESS; else return OS_UNSPECIFIED; }