Niro
1
Hi,
is it thread-safe add or remove AudioProcessorGraph connections from Editor (for example on Button event)?
void MyAudioProcessorEditor::buttonClicked(Button* button) {
processor.removeConnection();
}
void MyAudioProcessor::removeConnection() {
graph.removeConnection(ioProcInNode->nodeId, 0, moduleEQ->getNodeID(), 0);
graph.removeConnection(ioProcInNode->nodeId, 1, moduleEQ->getNodeID(), 1);
graph.removeConnection(moduleEQ->getNodeID(), 0, ioProcOutNode->nodeId, 0);
graph.removeConnection(moduleEQ->getNodeID(), 1, ioProcOutNode->nodeId, 1);
}
Thanks for your answer
daniel
2
I think for simple calls you can add a lock, that way processBlock and your remove calls cannot occur at the same time:
void MyAudioProcessor::removeConnection() {
ScopedLock myLock (getCallbackLock());
graph.removeConnection(ioProcInNode->nodeId, 0, moduleEQ->getNodeID(), 0);
graph.removeConnection(ioProcInNode->nodeId, 1, moduleEQ->getNodeID(), 1);
graph.removeConnection(moduleEQ->getNodeID(), 0, ioProcOutNode->nodeId, 0);
graph.removeConnection(moduleEQ->getNodeID(), 1, ioProcOutNode->nodeId, 1);
}
But don’t use the lock for something that may block longer (especially things that allocate memory).
Hope that helps
1 Like
Niro
3
Perfect, thank you very much