From 5287f2b838de77918649e80a1c119f6d148632bf Mon Sep 17 00:00:00 2001 From: falkTX Date: Mon, 14 Jul 2014 01:56:01 +0100 Subject: [PATCH] Enable code for non-jack drivers, kinda (weird mem issue lurking) --- source/backend/engine/CarlaEngineGraph.cpp | 73 ++++++++++++++----- source/backend/engine/CarlaEngineInternal.cpp | 2 + source/backend/engine/CarlaEngineRtAudio.cpp | 2 + 3 files changed, 57 insertions(+), 20 deletions(-) diff --git a/source/backend/engine/CarlaEngineGraph.cpp b/source/backend/engine/CarlaEngineGraph.cpp index 52290a99f..b566a4b5d 100644 --- a/source/backend/engine/CarlaEngineGraph.cpp +++ b/source/backend/engine/CarlaEngineGraph.cpp @@ -1295,21 +1295,37 @@ void EngineInternalGraph::processRack(CarlaEngine::ProtectedData* const data, co bool CarlaEngine::patchbayConnect(const uint groupA, const uint portA, const uint groupB, const uint portB) { CARLA_SAFE_ASSERT_RETURN(pData->options.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK || pData->options.processMode == ENGINE_PROCESS_MODE_PATCHBAY, false); - //CARLA_SAFE_ASSERT_RETURN(pData->graph.isReady, false); - //CARLA_SAFE_ASSERT_RETURN(pData->graph.graph != nullptr, false); + CARLA_SAFE_ASSERT_RETURN(pData->graph.isReady(), false); carla_stdout("CarlaEngine::patchbayConnect(%u, %u, %u, %u)", groupA, portA, groupB, portB); - return false; //pData->graph.graph->connect(this, groupA, portA, groupB, portB); + if (pData->options.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK) + { + if (RackGraph* const graph = pData->graph.getRackGraph()) + return graph->connect(this, groupA, portA, groupB, portB); + } + else + { + } + + return false; } bool CarlaEngine::patchbayDisconnect(const uint connectionId) { CARLA_SAFE_ASSERT_RETURN(pData->options.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK || pData->options.processMode == ENGINE_PROCESS_MODE_PATCHBAY, false); - //CARLA_SAFE_ASSERT_RETURN(pData->graph.isReady, false); - //CARLA_SAFE_ASSERT_RETURN(pData->graph.graph != nullptr, false); + CARLA_SAFE_ASSERT_RETURN(pData->graph.isReady(), false); carla_stdout("CarlaEngine::patchbayDisconnect(%u)", connectionId); - return false; //pData->graph.graph->disconnect(this, connectionId); + if (pData->options.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK) + { + if (RackGraph* const graph = pData->graph.getRackGraph()) + return graph->disconnect(this, connectionId); + } + else + { + } + + return false; } bool CarlaEngine::patchbayRefresh() @@ -1322,30 +1338,47 @@ bool CarlaEngine::patchbayRefresh() const char* const* CarlaEngine::getPatchbayConnections() const { - //CARLA_SAFE_ASSERT_RETURN(pData->graph.isReady, nullptr); - //CARLA_SAFE_ASSERT_RETURN(pData->graph.graph != nullptr, nullptr); + CARLA_SAFE_ASSERT_RETURN(pData->graph.isReady(), nullptr); carla_debug("CarlaEngine::getPatchbayConnections()"); - return nullptr; //pData->graph.graph->getConnections(); + if (pData->options.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK) + { + if (RackGraph* const graph = pData->graph.getRackGraph()) + return graph->getConnections(); + } + else + { + } + + return nullptr; } void CarlaEngine::restorePatchbayConnection(const char* const connSource, const char* const connTarget) { - //CARLA_SAFE_ASSERT_RETURN(pData->graph.isReady,); - //CARLA_SAFE_ASSERT_RETURN(pData->graph.graph != nullptr,); + CARLA_SAFE_ASSERT_RETURN(pData->graph.isReady(),); CARLA_SAFE_ASSERT_RETURN(connSource != nullptr && connSource[0] != '\0',); CARLA_SAFE_ASSERT_RETURN(connTarget != nullptr && connTarget[0] != '\0',); carla_debug("CarlaEngine::restorePatchbayConnection(\"%s\", \"%s\")", connSource, connTarget); -// uint groupA, portA; -// uint groupB, portB; -// -// if (! pData->graph.graph->getPortIdFromFullName(connSource, groupA, portA)) -// return; -// if (! pData->graph.graph->getPortIdFromFullName(connTarget, groupB, portB)) -// return; -// -// patchbayConnect(groupA, portA, groupB, portB); + uint groupA, portA; + uint groupB, portB; + + if (pData->options.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK) + { + RackGraph* const graph = pData->graph.getRackGraph(); + CARLA_SAFE_ASSERT_RETURN(graph != nullptr,); + + if (! graph->getGroupAndPortIdFromFullName(connSource, groupA, portA)) + return; + if (! graph->getGroupAndPortIdFromFullName(connTarget, groupB, portB)) + return; + } + else + { + return; + } + + patchbayConnect(groupA, portA, groupB, portB); } // ----------------------------------------------------------------------- diff --git a/source/backend/engine/CarlaEngineInternal.cpp b/source/backend/engine/CarlaEngineInternal.cpp index 1e6381bf8..e9e1d858e 100644 --- a/source/backend/engine/CarlaEngineInternal.cpp +++ b/source/backend/engine/CarlaEngineInternal.cpp @@ -152,6 +152,8 @@ bool CarlaEngine::ProtectedData::init(const char* const clientName) case ENGINE_PROCESS_MODE_PATCHBAY: maxPluginNumber = MAX_PATCHBAY_PLUGINS; + events.in = new EngineEvent[kMaxEngineEventInternalCount]; + events.out = new EngineEvent[kMaxEngineEventInternalCount]; break; case ENGINE_PROCESS_MODE_BRIDGE: diff --git a/source/backend/engine/CarlaEngineRtAudio.cpp b/source/backend/engine/CarlaEngineRtAudio.cpp index 171d1116c..b7a51ace8 100644 --- a/source/backend/engine/CarlaEngineRtAudio.cpp +++ b/source/backend/engine/CarlaEngineRtAudio.cpp @@ -582,6 +582,8 @@ public: void patchbayRefreshPatchbay() noexcept { + PatchbayGraph* const graph(pData->graph.getPatchbayGraph()); + CARLA_SAFE_ASSERT_RETURN(graph != nullptr,); } // -------------------------------------------------------------------