MCPcopy Create free account
hub / github.com/DISTRHO/Cardinal / removeCable_NoLock

Method removeCable_NoLock

src/override/Engine.cpp:1026–1060  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1024
1025
1026void Engine::removeCable_NoLock(Cable* cable) {
1027 DISTRHO_SAFE_ASSERT_RETURN(cable,);
1028 // Check that the cable is already added
1029 auto it = std::find(internal->cables.begin(), internal->cables.end(), cable);
1030 DISTRHO_SAFE_ASSERT_RETURN(it != internal->cables.end(),);
1031 // Remove the cable's zero-latency shortcut
1032 cable->outputModule->outputs[cable->outputId].cables.remove(cable);
1033 // Remove the cable
1034 internal->cablesCache.erase(cable->id);
1035 internal->cables.erase(it);
1036 Engine_updateConnected(this);
1037 bool outputIsConnected = false;
1038 for (Cable* cable2 : internal->cables) {
1039 // Get connected status of output, to decide whether we need to call a PortChangeEvent.
1040 // It's best to not trust `cable->outputModule->outputs[cable->outputId]->isConnected()`
1041 if (cable2->outputModule == cable->outputModule && cable2->outputId == cable->outputId)
1042 outputIsConnected = true;
1043 }
1044 // Dispatch input port event
1045 {
1046 Module::PortChangeEvent e;
1047 e.connecting = false;
1048 e.type = Port::INPUT;
1049 e.portId = cable->inputId;
1050 cable->inputModule->onPortChange(e);
1051 }
1052 // Dispatch output port event if its state went from connected to disconnected.
1053 if (!outputIsConnected) {
1054 Module::PortChangeEvent e;
1055 e.connecting = false;
1056 e.type = Port::OUTPUT;
1057 e.portId = cable->outputId;
1058 cable->outputModule->onPortChange(e);
1059 }
1060}
1061
1062
1063bool Engine::hasCable(Cable* cable) {

Callers

nothing calls this directly

Calls 5

findFunction · 0.85
Engine_updateConnectedFunction · 0.85
eraseMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected