Browse Source

Finish patchbay host/osc split, minor API changes

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.1-alpha2
falkTX 5 years ago
parent
commit
4ce1c0c76c
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
14 changed files with 291 additions and 221 deletions
  1. +7
    -3
      source/backend/CarlaEngine.hpp
  2. +2
    -2
      source/backend/CarlaHost.h
  3. +7
    -6
      source/backend/CarlaStandalone.cpp
  4. +2
    -5
      source/backend/engine/CarlaEngine.cpp
  5. +130
    -105
      source/backend/engine/CarlaEngineGraph.cpp
  6. +13
    -8
      source/backend/engine/CarlaEngineGraph.hpp
  7. +4
    -2
      source/backend/engine/CarlaEngineInternal.hpp
  8. +59
    -40
      source/backend/engine/CarlaEngineJack.cpp
  9. +13
    -10
      source/backend/engine/CarlaEngineJuce.cpp
  10. +6
    -2
      source/backend/engine/CarlaEngineNative.cpp
  11. +19
    -12
      source/backend/engine/CarlaEngineOscHandlers.cpp
  12. +13
    -10
      source/backend/engine/CarlaEngineRtAudio.cpp
  13. +14
    -14
      source/frontend/carla_backend.py
  14. +2
    -2
      source/frontend/carla_host.py

+ 7
- 3
source/backend/CarlaEngine.hpp View File

@@ -1027,12 +1027,14 @@ public:
/*!
* Connect two patchbay ports.
*/
virtual bool patchbayConnect(const uint groupA, const uint portA, const uint groupB, const uint portB);
virtual bool patchbayConnect(const bool external,
const uint groupA, const uint portA,
const uint groupB, const uint portB);

/*!
* Remove a patchbay connection.
*/
virtual bool patchbayDisconnect(const uint connectionId);
virtual bool patchbayDisconnect(const bool external, const uint connectionId);

/*!
* Force the engine to resend all patchbay clients, ports and connections again.
@@ -1221,7 +1223,9 @@ protected:
* Do not free returned data.
*/
virtual const char* const* getPatchbayConnections(const bool external) const;
virtual void restorePatchbayConnection(const bool external, const char* const sourcePort, const char* const targetPort, const bool sendCallback);
virtual void restorePatchbayConnection(const bool external,
const char* const sourcePort,
const char* const targetPort);
#endif

// -------------------------------------------------------------------


+ 2
- 2
source/backend/CarlaHost.h View File

@@ -450,14 +450,14 @@ CARLA_EXPORT void carla_clear_project_filename();
* @param portIdB Input port
* @see ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED
*/
CARLA_EXPORT bool carla_patchbay_connect(uint groupIdA, uint portIdA, uint groupIdB, uint portIdB);
CARLA_EXPORT bool carla_patchbay_connect(bool external, uint groupIdA, uint portIdA, uint groupIdB, uint portIdB);

/*!
* Disconnect two patchbay ports.
* @param connectionId Connection Id
* @see ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED
*/
CARLA_EXPORT bool carla_patchbay_disconnect(uint connectionId);
CARLA_EXPORT bool carla_patchbay_disconnect(bool external, uint connectionId);

/*!
* Force the engine to resend all patchbay clients, ports and connections again.


+ 7
- 6
source/backend/CarlaStandalone.cpp View File

@@ -899,22 +899,23 @@ void carla_clear_project_filename()

// --------------------------------------------------------------------------------------------------------------------

bool carla_patchbay_connect(uint groupIdA, uint portIdA, uint groupIdB, uint portIdB)
bool carla_patchbay_connect(bool external, uint groupIdA, uint portIdA, uint groupIdB, uint portIdB)
{
CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(gStandalone.engine != nullptr, "Engine is not initialized", false);

carla_debug("carla_patchbay_connect(%u, %u, %u, %u)", groupIdA, portIdA, groupIdB, portIdB);
carla_debug("carla_patchbay_connect(%s, %u, %u, %u, %u)",
bool2str(external), groupIdA, portIdA, groupIdB, portIdB);

return gStandalone.engine->patchbayConnect(groupIdA, portIdA, groupIdB, portIdB);
return gStandalone.engine->patchbayConnect(external, groupIdA, portIdA, groupIdB, portIdB);
}

bool carla_patchbay_disconnect(uint connectionId)
bool carla_patchbay_disconnect(bool external, uint connectionId)
{
CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(gStandalone.engine != nullptr, "Engine is not initialized", false);

carla_debug("carla_patchbay_disconnect(%i)", connectionId);
carla_debug("carla_patchbay_disconnect(%s, %i)", bool2str(external), connectionId);

return gStandalone.engine->patchbayDisconnect(connectionId);
return gStandalone.engine->patchbayDisconnect(external, connectionId);
}

bool carla_patchbay_refresh(bool external)


+ 2
- 5
source/backend/engine/CarlaEngine.cpp View File

@@ -2640,7 +2640,6 @@ bool CarlaEngine::loadProjectInternal(water::XmlDocument& xmlDoc)
if (pData->options.processMode == ENGINE_PROCESS_MODE_PATCHBAY)
{
CarlaString sourcePort, targetPort;
const bool isUsingExternal(pData->graph.isUsingExternal());

for (XmlElement* patchElem = elem->getFirstChildElement(); patchElem != nullptr; patchElem = patchElem->getNextElement())
{
@@ -2664,7 +2663,7 @@ bool CarlaEngine::loadProjectInternal(water::XmlDocument& xmlDoc)
}

if (sourcePort.isNotEmpty() && targetPort.isNotEmpty())
restorePatchbayConnection(false, sourcePort, targetPort, !isUsingExternal);
restorePatchbayConnection(false, sourcePort, targetPort);
}

callback(true, true, ENGINE_CALLBACK_IDLE, 0, 0, 0, 0, 0.0f, nullptr);
@@ -2697,8 +2696,6 @@ bool CarlaEngine::loadProjectInternal(water::XmlDocument& xmlDoc)
// plus external connections too
if (loadExternalConnections)
{
const bool isUsingExternal = pData->options.processMode != ENGINE_PROCESS_MODE_PATCHBAY ||
pData->graph.isUsingExternal();
const bool loadingAsExternal = pData->options.processMode == ENGINE_PROCESS_MODE_PATCHBAY &&
hasInternalConnections;

@@ -2742,7 +2739,7 @@ bool CarlaEngine::loadProjectInternal(water::XmlDocument& xmlDoc)
}

if (sourcePort.isNotEmpty() && targetPort.isNotEmpty())
restorePatchbayConnection(loadingAsExternal, sourcePort, targetPort, isUsingExternal);
restorePatchbayConnection(loadingAsExternal, sourcePort, targetPort);
}
break;
}


+ 130
- 105
source/backend/engine/CarlaEngineGraph.cpp View File

@@ -146,7 +146,8 @@ void ExternalGraph::clear() noexcept
midiPorts.outs.clear();
}

bool ExternalGraph::connect(const uint groupA, const uint portA, const uint groupB, const uint portB, const bool sendCallback) noexcept
bool ExternalGraph::connect(const bool sendHost, const bool sendOSC,
const uint groupA, const uint portA, const uint groupB, const uint portB) noexcept
{
uint otherGroup, otherPort, carlaPort;

@@ -220,15 +221,15 @@ bool ExternalGraph::connect(const uint groupA, const uint portA, const uint grou
strBuf[STR_MAX] = '\0';
std::snprintf(strBuf, STR_MAX, "%u:%u:%u:%u", groupA, portA, groupB, portB);

if (sendCallback)
kEngine->callback(true, true,
ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, connectionToId.id, 0, 0, 0, 0.0f, strBuf);
kEngine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, connectionToId.id, 0, 0, 0, 0.0f, strBuf);

connections.list.append(connectionToId);
return true;
}

bool ExternalGraph::disconnect(const uint connectionId) noexcept
bool ExternalGraph::disconnect(const bool sendHost, const bool sendOSC,
const uint connectionId) noexcept
{
CARLA_SAFE_ASSERT_RETURN(connections.list.count() > 0, false);

@@ -301,7 +302,8 @@ bool ExternalGraph::disconnect(const uint connectionId) noexcept
return false;
}

kEngine->callback(true, true, ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED, connectionToId.id, 0, 0, 0, 0.0f, nullptr);
kEngine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED, connectionToId.id, 0, 0, 0, 0.0f, nullptr);

connections.list.remove(it);
return true;
@@ -311,7 +313,7 @@ bool ExternalGraph::disconnect(const uint connectionId) noexcept
return false;
}

void ExternalGraph::refresh(const bool sendHost, const bool sendOsc, const char* const deviceName)
void ExternalGraph::refresh(const bool sendHost, const bool sendOSC, const char* const deviceName)
{
CARLA_SAFE_ASSERT_RETURN(deviceName != nullptr,);

@@ -319,7 +321,7 @@ void ExternalGraph::refresh(const bool sendHost, const bool sendOsc, const char*

// Main
{
kEngine->callback(sendHost, sendOsc,
kEngine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED,
kExternalGraphGroupCarla,
PATCHBAY_ICON_CARLA,
@@ -329,7 +331,7 @@ void ExternalGraph::refresh(const bool sendHost, const bool sendOsc, const char*

if (isRack)
{
kEngine->callback(sendHost, sendOsc,
kEngine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_PORT_ADDED,
kExternalGraphGroupCarla,
kExternalGraphCarlaPortAudioIn1,
@@ -337,7 +339,7 @@ void ExternalGraph::refresh(const bool sendHost, const bool sendOsc, const char*
0, 0.0f,
"audio-in1");

kEngine->callback(sendHost, sendOsc,
kEngine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_PORT_ADDED,
kExternalGraphGroupCarla,
kExternalGraphCarlaPortAudioIn2,
@@ -345,7 +347,7 @@ void ExternalGraph::refresh(const bool sendHost, const bool sendOsc, const char*
0, 0.0f,
"audio-in2");

kEngine->callback(sendHost, sendOsc,
kEngine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_PORT_ADDED,
kExternalGraphGroupCarla,
kExternalGraphCarlaPortAudioOut1,
@@ -353,7 +355,7 @@ void ExternalGraph::refresh(const bool sendHost, const bool sendOsc, const char*
0, 0.0f,
"audio-out1");

kEngine->callback(sendHost, sendOsc,
kEngine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_PORT_ADDED,
kExternalGraphGroupCarla,
kExternalGraphCarlaPortAudioOut2,
@@ -362,7 +364,7 @@ void ExternalGraph::refresh(const bool sendHost, const bool sendOsc, const char*
"audio-out2");
}

kEngine->callback(sendHost, sendOsc,
kEngine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_PORT_ADDED,
kExternalGraphGroupCarla,
kExternalGraphCarlaPortMidiIn,
@@ -370,7 +372,7 @@ void ExternalGraph::refresh(const bool sendHost, const bool sendOsc, const char*
0, 0.0f,
"midi-in");

kEngine->callback(sendHost, sendOsc,
kEngine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_PORT_ADDED,
kExternalGraphGroupCarla,
kExternalGraphCarlaPortMidiOut,
@@ -390,7 +392,7 @@ void ExternalGraph::refresh(const bool sendHost, const bool sendOsc, const char*
else
std::strncpy(strBuf, "Capture", STR_MAX);

kEngine->callback(sendHost, sendOsc,
kEngine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED,
kExternalGraphGroupAudioIn,
PATCHBAY_ICON_HARDWARE,
@@ -408,7 +410,7 @@ void ExternalGraph::refresh(const bool sendHost, const bool sendOsc, const char*

portNameToId.setFullName(groupNameIn + portNameToId.name);

kEngine->callback(sendHost, sendOsc,
kEngine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_PORT_ADDED,
kExternalGraphGroupAudioIn,
++h,
@@ -423,7 +425,7 @@ void ExternalGraph::refresh(const bool sendHost, const bool sendOsc, const char*
else
std::strncpy(strBuf, "Playback", STR_MAX);

kEngine->callback(sendHost, sendOsc,
kEngine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED,
kExternalGraphGroupAudioOut,
PATCHBAY_ICON_HARDWARE,
@@ -441,7 +443,7 @@ void ExternalGraph::refresh(const bool sendHost, const bool sendOsc, const char*

portNameToId.setFullName(groupNameOut + portNameToId.name);

kEngine->callback(sendHost, sendOsc,
kEngine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_PORT_ADDED,
kExternalGraphGroupAudioOut,
++h,
@@ -453,7 +455,7 @@ void ExternalGraph::refresh(const bool sendHost, const bool sendOsc, const char*

// MIDI In
{
kEngine->callback(sendHost, sendOsc,
kEngine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED,
kExternalGraphGroupMidiIn,
PATCHBAY_ICON_HARDWARE,
@@ -471,7 +473,7 @@ void ExternalGraph::refresh(const bool sendHost, const bool sendOsc, const char*

portNameToId.setFullName(groupNamePlus + portNameToId.name);

kEngine->callback(sendHost, sendOsc,
kEngine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_PORT_ADDED,
kExternalGraphGroupMidiIn,
++h,
@@ -483,7 +485,7 @@ void ExternalGraph::refresh(const bool sendHost, const bool sendOsc, const char*

// MIDI Out
{
kEngine->callback(sendHost, sendOsc,
kEngine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED,
kExternalGraphGroupMidiOut,
PATCHBAY_ICON_HARDWARE,
@@ -501,7 +503,7 @@ void ExternalGraph::refresh(const bool sendHost, const bool sendOsc, const char*

portNameToId.setFullName(groupNamePlus + portNameToId.name);

kEngine->callback(sendHost, sendOsc,
kEngine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_PORT_ADDED,
kExternalGraphGroupMidiOut,
++h,
@@ -775,17 +777,17 @@ void RackGraph::setOffline(const bool offline) noexcept

bool RackGraph::connect(const uint groupA, const uint portA, const uint groupB, const uint portB) noexcept
{
return extGraph.connect(groupA, portA, groupB, portB, true);
return extGraph.connect(true, true, groupA, portA, groupB, portB);
}

bool RackGraph::disconnect(const uint connectionId) noexcept
{
return extGraph.disconnect(connectionId);
return extGraph.disconnect(true, true, connectionId);
}

void RackGraph::refresh(const bool sendHost, const bool sendOsc, const char* const deviceName)
void RackGraph::refresh(const bool sendHost, const bool sendOSC, const bool, const char* const deviceName)
{
extGraph.refresh(sendHost, sendOsc, deviceName);
extGraph.refresh(sendHost, sendOSC, deviceName);

char strBuf[STR_MAX+1];
strBuf[STR_MAX] = '\0';
@@ -804,7 +806,7 @@ void RackGraph::refresh(const bool sendHost, const bool sendOsc, const char* con

std::snprintf(strBuf, STR_MAX, "%i:%i:%i:%i", connectionToId.groupA, connectionToId.portA, connectionToId.groupB, connectionToId.portB);

kEngine->callback(sendHost, sendOsc,
kEngine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED,
connectionToId.id,
0, 0, 0, 0.0f,
@@ -824,7 +826,7 @@ void RackGraph::refresh(const bool sendHost, const bool sendOsc, const char* con

std::snprintf(strBuf, STR_MAX, "%i:%i:%i:%i", connectionToId.groupA, connectionToId.portA, connectionToId.groupB, connectionToId.portB);

kEngine->callback(sendHost, sendOsc,
kEngine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED,
connectionToId.id,
0, 0, 0, 0.0f,
@@ -844,7 +846,7 @@ void RackGraph::refresh(const bool sendHost, const bool sendOsc, const char* con

std::snprintf(strBuf, STR_MAX, "%i:%i:%i:%i", connectionToId.groupA, connectionToId.portA, connectionToId.groupB, connectionToId.portB);

kEngine->callback(sendHost, sendOsc,
kEngine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED,
connectionToId.id,
0, 0, 0, 0.0f,
@@ -864,7 +866,7 @@ void RackGraph::refresh(const bool sendHost, const bool sendOsc, const char* con

std::snprintf(strBuf, STR_MAX, "%i:%i:%i:%i", connectionToId.groupA, connectionToId.portA, connectionToId.groupB, connectionToId.portB);

kEngine->callback(sendHost, sendOsc,
kEngine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED,
connectionToId.id,
0, 0, 0, 0.0f,
@@ -1191,12 +1193,13 @@ const String getProcessorFullPortName(AudioProcessor* const proc, const uint32_t
}

static inline
void addNodeToPatchbay(CarlaEngine* const engine, const uint32_t groupId, const int clientId, const AudioProcessor* const proc)
void addNodeToPatchbay(const bool sendHost, const bool sendOSC, CarlaEngine* const engine,
const uint32_t groupId, const int clientId, const AudioProcessor* const proc)
{
CARLA_SAFE_ASSERT_RETURN(engine != nullptr,);
CARLA_SAFE_ASSERT_RETURN(proc != nullptr,);

engine->callback(true, true,
engine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED,
groupId,
clientId >= 0 ? PATCHBAY_ICON_PLUGIN : PATCHBAY_ICON_HARDWARE,
@@ -1206,7 +1209,7 @@ void addNodeToPatchbay(CarlaEngine* const engine, const uint32_t groupId, const

for (int i=0, numInputs=proc->getTotalNumInputChannels(); i<numInputs; ++i)
{
engine->callback(true, true,
engine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_PORT_ADDED,
groupId,
static_cast<int>(kAudioInputPortOffset)+i,
@@ -1217,7 +1220,7 @@ void addNodeToPatchbay(CarlaEngine* const engine, const uint32_t groupId, const

for (int i=0, numOutputs=proc->getTotalNumOutputChannels(); i<numOutputs; ++i)
{
engine->callback(true, true,
engine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_PORT_ADDED,
groupId,
static_cast<int>(kAudioOutputPortOffset)+i,
@@ -1228,7 +1231,7 @@ void addNodeToPatchbay(CarlaEngine* const engine, const uint32_t groupId, const

if (proc->acceptsMidi())
{
engine->callback(true, true,
engine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_PORT_ADDED,
groupId,
static_cast<int>(kMidiInputPortOffset),
@@ -1239,7 +1242,7 @@ void addNodeToPatchbay(CarlaEngine* const engine, const uint32_t groupId, const

if (proc->producesMidi())
{
engine->callback(true, true,
engine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_PORT_ADDED,
groupId,
static_cast<int>(kMidiOutputPortOffset),
@@ -1250,14 +1253,15 @@ void addNodeToPatchbay(CarlaEngine* const engine, const uint32_t groupId, const
}

static inline
void removeNodeFromPatchbay(CarlaEngine* const engine, const uint32_t groupId, const AudioProcessor* const proc)
void removeNodeFromPatchbay(const bool sendHost, const bool sendOSC, CarlaEngine* const engine,
const uint32_t groupId, const AudioProcessor* const proc)
{
CARLA_SAFE_ASSERT_RETURN(engine != nullptr,);
CARLA_SAFE_ASSERT_RETURN(proc != nullptr,);

for (int i=0, numInputs=proc->getTotalNumInputChannels(); i<numInputs; ++i)
{
engine->callback(true, true,
engine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED,
groupId,
static_cast<int>(kAudioInputPortOffset)+i,
@@ -1266,7 +1270,7 @@ void removeNodeFromPatchbay(CarlaEngine* const engine, const uint32_t groupId, c

for (int i=0, numOutputs=proc->getTotalNumOutputChannels(); i<numOutputs; ++i)
{
engine->callback(true, true,
engine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED,
groupId,
static_cast<int>(kAudioOutputPortOffset)+i,
@@ -1276,7 +1280,7 @@ void removeNodeFromPatchbay(CarlaEngine* const engine, const uint32_t groupId, c

if (proc->acceptsMidi())
{
engine->callback(true, true,
engine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED,
groupId,
static_cast<int>(kMidiInputPortOffset),
@@ -1285,14 +1289,14 @@ void removeNodeFromPatchbay(CarlaEngine* const engine, const uint32_t groupId, c

if (proc->producesMidi())
{
engine->callback(true, true,
engine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED,
groupId,
static_cast<int>(kMidiOutputPortOffset),
0, 0, 0.0f, nullptr);
}

engine->callback(true, true,
engine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED,
groupId,
0, 0, 0, 0.0f, nullptr);
@@ -1472,7 +1476,8 @@ PatchbayGraph::PatchbayGraph(CarlaEngine* const engine, const uint32_t ins, cons
inputs(carla_fixedValue(0U, 32U, ins)),
outputs(carla_fixedValue(0U, 32U, outs)),
retCon(),
usingExternal(false),
usingExternalHost(false),
usingExternalOSC(false),
extGraph(engine),
kEngine(engine)
{
@@ -1600,13 +1605,15 @@ void PatchbayGraph::addPlugin(CarlaPlugin* const plugin)
AudioProcessorGraph::Node* const node(graph.addNode(instance));
CARLA_SAFE_ASSERT_RETURN(node != nullptr,);

const bool sendHost = !usingExternalHost;
const bool sendOSC = !usingExternalOSC;

plugin->setPatchbayNodeId(node->nodeId);

node->properties.set("isPlugin", true);
node->properties.set("pluginId", static_cast<int>(plugin->getId()));

if (! usingExternal)
addNodeToPatchbay(plugin->getEngine(), node->nodeId, static_cast<int>(plugin->getId()), instance);
addNodeToPatchbay(sendHost, sendOSC, kEngine, node->nodeId, static_cast<int>(plugin->getId()), instance);
}

void PatchbayGraph::replacePlugin(CarlaPlugin* const oldPlugin, CarlaPlugin* const newPlugin)
@@ -1619,11 +1626,11 @@ void PatchbayGraph::replacePlugin(CarlaPlugin* const oldPlugin, CarlaPlugin* con
AudioProcessorGraph::Node* const oldNode(graph.getNodeForId(oldPlugin->getPatchbayNodeId()));
CARLA_SAFE_ASSERT_RETURN(oldNode != nullptr,);

if (! usingExternal)
{
disconnectInternalGroup(oldNode->nodeId);
removeNodeFromPatchbay(kEngine, oldNode->nodeId, oldNode->getProcessor());
}
const bool sendHost = !usingExternalHost;
const bool sendOSC = !usingExternalOSC;
disconnectInternalGroup(oldNode->nodeId);
removeNodeFromPatchbay(sendHost, sendOSC, kEngine, oldNode->nodeId, oldNode->getProcessor());

((CarlaPluginInstance*)oldNode->getProcessor())->invalidatePlugin();

@@ -1638,8 +1645,7 @@ void PatchbayGraph::replacePlugin(CarlaPlugin* const oldPlugin, CarlaPlugin* con
node->properties.set("isPlugin", true);
node->properties.set("pluginId", static_cast<int>(newPlugin->getId()));

if (! usingExternal)
addNodeToPatchbay(newPlugin->getEngine(), node->nodeId, static_cast<int>(newPlugin->getId()), instance);
addNodeToPatchbay(sendHost, sendOSC, kEngine, node->nodeId, static_cast<int>(newPlugin->getId()), instance);
}

void PatchbayGraph::renamePlugin(CarlaPlugin* const plugin, const char* const newName)
@@ -1650,12 +1656,14 @@ void PatchbayGraph::renamePlugin(CarlaPlugin* const plugin, const char* const ne
AudioProcessorGraph::Node* const node(graph.getNodeForId(plugin->getPatchbayNodeId()));
CARLA_SAFE_ASSERT_RETURN(node != nullptr,);

if (! usingExternal)
kEngine->callback(true, true,
ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED,
node->nodeId,
0, 0, 0, 0.0f,
newName);
const bool sendHost = !usingExternalHost;
const bool sendOSC = !usingExternalOSC;

kEngine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED,
node->nodeId,
0, 0, 0, 0.0f,
newName);
}

void PatchbayGraph::removePlugin(CarlaPlugin* const plugin)
@@ -1666,11 +1674,11 @@ void PatchbayGraph::removePlugin(CarlaPlugin* const plugin)
AudioProcessorGraph::Node* const node(graph.getNodeForId(plugin->getPatchbayNodeId()));
CARLA_SAFE_ASSERT_RETURN(node != nullptr,);

if (! usingExternal)
{
disconnectInternalGroup(node->nodeId);
removeNodeFromPatchbay(kEngine, node->nodeId, node->getProcessor());
}
const bool sendHost = !usingExternalHost;
const bool sendOSC = !usingExternalOSC;
disconnectInternalGroup(node->nodeId);
removeNodeFromPatchbay(sendHost, sendOSC, kEngine, node->nodeId, node->getProcessor());

((CarlaPluginInstance*)node->getProcessor())->invalidatePlugin();

@@ -1694,6 +1702,9 @@ void PatchbayGraph::removeAllPlugins()
{
carla_debug("PatchbayGraph::removeAllPlugins()");

const bool sendHost = !usingExternalHost;
const bool sendOSC = !usingExternalOSC;

for (uint i=0, count=kEngine->getCurrentPluginCount(); i<count; ++i)
{
CarlaPlugin* const plugin(kEngine->getPlugin(i));
@@ -1702,11 +1713,8 @@ void PatchbayGraph::removeAllPlugins()
AudioProcessorGraph::Node* const node(graph.getNodeForId(plugin->getPatchbayNodeId()));
CARLA_SAFE_ASSERT_CONTINUE(node != nullptr);

if (! usingExternal)
{
disconnectInternalGroup(node->nodeId);
removeNodeFromPatchbay(kEngine, node->nodeId, node->getProcessor());
}
disconnectInternalGroup(node->nodeId);
removeNodeFromPatchbay(sendHost, sendOSC, kEngine, node->nodeId, node->getProcessor());

((CarlaPluginInstance*)node->getProcessor())->invalidatePlugin();

@@ -1714,10 +1722,11 @@ void PatchbayGraph::removeAllPlugins()
}
}

bool PatchbayGraph::connect(const bool external, const uint groupA, const uint portA, const uint groupB, const uint portB, const bool sendCallback)
bool PatchbayGraph::connect(const bool external,
const uint groupA, const uint portA, const uint groupB, const uint portB)
{
if (external)
return extGraph.connect(groupA, portA, groupB, portB, sendCallback);
return extGraph.connect(usingExternalHost, usingExternalOSC, groupA, portA, groupB, portB);

uint adjustedPortA = portA;
uint adjustedPortB = portB;
@@ -1740,21 +1749,20 @@ bool PatchbayGraph::connect(const bool external, const uint groupA, const uint p
strBuf[STR_MAX] = '\0';
std::snprintf(strBuf, STR_MAX, "%u:%u:%u:%u", groupA, portA, groupB, portB);

if (sendCallback)
kEngine->callback(true, true,
ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED,
connectionToId.id,
0, 0, 0, 0.0f,
strBuf);
kEngine->callback(!usingExternalHost, !usingExternalOSC,
ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED,
connectionToId.id,
0, 0, 0, 0.0f,
strBuf);

connections.list.append(connectionToId);
return true;
}

bool PatchbayGraph::disconnect(const uint connectionId)
bool PatchbayGraph::disconnect(const bool external, const uint connectionId)
{
if (usingExternal)
return extGraph.disconnect(connectionId);
if (external)
return extGraph.disconnect(usingExternalHost, usingExternalOSC, connectionId);

for (LinkedList<ConnectionToId>::Itenerator it=connections.list.begin2(); it.valid(); it.next())
{
@@ -1778,7 +1786,7 @@ bool PatchbayGraph::disconnect(const uint connectionId)
connectionToId.groupB, static_cast<int>(adjustedPortB)))
return false;

kEngine->callback(true, true,
kEngine->callback(!usingExternalHost, !usingExternalOSC,
ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED,
connectionToId.id,
0, 0, 0, 0.0f,
@@ -1794,8 +1802,6 @@ bool PatchbayGraph::disconnect(const uint connectionId)

void PatchbayGraph::disconnectInternalGroup(const uint groupId) noexcept
{
CARLA_SAFE_ASSERT(! usingExternal);

for (LinkedList<ConnectionToId>::Itenerator it=connections.list.begin2(); it.valid(); it.next())
{
static const ConnectionToId fallback = { 0, 0, 0, 0, 0 };
@@ -1819,21 +1825,20 @@ void PatchbayGraph::disconnectInternalGroup(const uint groupId) noexcept
connectionToId.groupB, static_cast<int>(adjustedPortB));
*/

if (! usingExternal)
kEngine->callback(true, true,
ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED,
connectionToId.id,
0, 0, 0, 0.0f,
nullptr);
kEngine->callback(!usingExternalHost, !usingExternalOSC,
ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED,
connectionToId.id,
0, 0, 0, 0.0f,
nullptr);

connections.list.remove(it);
}
}

void PatchbayGraph::refresh(const bool sendHost, const bool sendOsc, const char* const deviceName)
void PatchbayGraph::refresh(const bool sendHost, const bool sendOSC, const bool external, const char* const deviceName)
{
if (usingExternal)
return extGraph.refresh(sendHost, sendOsc, deviceName);
if (external)
return extGraph.refresh(sendHost, sendOSC, deviceName);

CARLA_SAFE_ASSERT_RETURN(deviceName != nullptr,);

@@ -1854,7 +1859,7 @@ void PatchbayGraph::refresh(const bool sendHost, const bool sendOsc, const char*
if (node->properties.getWithDefault("isPlugin", false) == water::var(true))
clientId = node->properties.getWithDefault("pluginId", -1);

addNodeToPatchbay(kEngine, node->nodeId, clientId, proc);
addNodeToPatchbay(sendHost, sendOSC, kEngine, node->nodeId, clientId, proc);
}

char strBuf[STR_MAX+1];
@@ -1888,7 +1893,7 @@ void PatchbayGraph::refresh(const bool sendHost, const bool sendOsc, const char*

std::snprintf(strBuf, STR_MAX, "%i:%i:%i:%i", groupA, portA, groupB, portB);

kEngine->callback(true, true,
kEngine->callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED,
connectionToId.id,
0, 0, 0, 0.0f,
@@ -2231,26 +2236,44 @@ void EngineInternalGraph::removeAllPlugins()
fPatchbay->removeAllPlugins();
}

bool EngineInternalGraph::isUsingExternal() const noexcept
bool EngineInternalGraph::isUsingExternalHost() const noexcept
{
if (fIsRack)
return true;

CARLA_SAFE_ASSERT_RETURN(fPatchbay != nullptr, false);
return fPatchbay->usingExternal;
return fPatchbay->usingExternalHost;
}

void EngineInternalGraph::setUsingExternal(const bool usingExternal) noexcept
bool EngineInternalGraph::isUsingExternalOSC() const noexcept
{
if (fIsRack)
return true;

CARLA_SAFE_ASSERT_RETURN(fPatchbay != nullptr, false);
return fPatchbay->usingExternalOSC;
}

void EngineInternalGraph::setUsingExternalHost(const bool usingExternal) noexcept
{
CARLA_SAFE_ASSERT_RETURN(! fIsRack,);
CARLA_SAFE_ASSERT_RETURN(fPatchbay != nullptr,);
fPatchbay->usingExternal = usingExternal;
fPatchbay->usingExternalHost = usingExternal;
}

void EngineInternalGraph::setUsingExternalOSC(const bool usingExternal) noexcept
{
CARLA_SAFE_ASSERT_RETURN(! fIsRack,);
CARLA_SAFE_ASSERT_RETURN(fPatchbay != nullptr,);
fPatchbay->usingExternalOSC = usingExternal;
}

// -----------------------------------------------------------------------
// CarlaEngine Patchbay stuff

bool CarlaEngine::patchbayConnect(const uint groupA, const uint portA, const uint groupB, const uint portB)
bool CarlaEngine::patchbayConnect(const bool external,
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);
@@ -2268,13 +2291,13 @@ bool CarlaEngine::patchbayConnect(const uint groupA, const uint portA, const uin
PatchbayGraph* const graph = pData->graph.getPatchbayGraph();
CARLA_SAFE_ASSERT_RETURN(graph != nullptr, false);

return graph->connect(graph->usingExternal, groupA, portA, groupB, portB, true);
return graph->connect(external, groupA, portA, groupB, portB);
}

return false;
}

bool CarlaEngine::patchbayDisconnect(const uint connectionId)
bool CarlaEngine::patchbayDisconnect(const bool external, 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);
@@ -2292,13 +2315,13 @@ bool CarlaEngine::patchbayDisconnect(const uint connectionId)
PatchbayGraph* const graph = pData->graph.getPatchbayGraph();
CARLA_SAFE_ASSERT_RETURN(graph != nullptr, false);

return graph->disconnect(connectionId);
return graph->disconnect(external, connectionId);
}

return false;
}

bool CarlaEngine::patchbayRefresh(const bool sendHost, const bool sendOsc, const bool external)
bool CarlaEngine::patchbayRefresh(const bool sendHost, const bool sendOSC, const bool external)
{
// subclasses should handle this
CARLA_SAFE_ASSERT_RETURN(! external, false);
@@ -2315,7 +2338,7 @@ bool CarlaEngine::patchbayRefresh(const bool sendHost, const bool sendOsc, const
PatchbayGraph* const graph = pData->graph.getPatchbayGraph();
CARLA_SAFE_ASSERT_RETURN(graph != nullptr, false);

graph->refresh(sendHost, sendOsc, "");
graph->refresh(sendHost, sendOSC, external, "");
return true;
}

@@ -2349,7 +2372,9 @@ const char* const* CarlaEngine::getPatchbayConnections(const bool external) cons
return nullptr;
}

void CarlaEngine::restorePatchbayConnection(const bool external, const char* const sourcePort, const char* const targetPort, const bool sendCallback)
void CarlaEngine::restorePatchbayConnection(const bool external,
const char* const sourcePort,
const char* const targetPort)
{
CARLA_SAFE_ASSERT_RETURN(pData->graph.isReady(),);
CARLA_SAFE_ASSERT_RETURN(sourcePort != nullptr && sourcePort[0] != '\0',);
@@ -2382,7 +2407,7 @@ void CarlaEngine::restorePatchbayConnection(const bool external, const char* con
if (! graph->getGroupAndPortIdFromFullName(external, targetPort, groupB, portB))
return;

graph->connect(external, groupA, portA, groupB, portB, sendCallback);
graph->connect(external, groupA, portA, groupB, portB);
}
}



+ 13
- 8
source/backend/engine/CarlaEngineGraph.hpp View File

@@ -84,9 +84,13 @@ struct ExternalGraph {
ExternalGraph(CarlaEngine* const engine) noexcept;

void clear() noexcept;
bool connect(const uint groupA, const uint portA, const uint groupB, const uint portB, const bool sendCallback) noexcept;
bool disconnect(const uint connectionId) noexcept;
void refresh(const bool sendHost, const bool sendOsc, const char* const deviceName);

bool connect(const bool sendHost, const bool sendOSC,
const uint groupA, const uint portA, const uint groupB, const uint portB) noexcept;
bool disconnect(const bool sendHost, const bool sendOSC,
const uint connectionId) noexcept;
void refresh(const bool sendHost, const bool sendOSC,
const char* const deviceName);

const char* const* getConnections() const noexcept;
bool getGroupAndPortIdFromFullName(const char* const fullPortName, uint& groupId, uint& portId) const noexcept;
@@ -130,7 +134,7 @@ struct RackGraph {

bool connect(const uint groupA, const uint portA, const uint groupB, const uint portB) noexcept;
bool disconnect(const uint connectionId) noexcept;
void refresh(const bool sendHost, const bool sendOsc, const char* const deviceName);
void refresh(const bool sendHost, const bool sendOsc, const bool ignored, const char* const deviceName);

const char* const* getConnections() const noexcept;
bool getGroupAndPortIdFromFullName(const char* const fullPortName, uint& groupId, uint& portId) const noexcept;
@@ -157,7 +161,8 @@ public:
const uint32_t inputs;
const uint32_t outputs;
mutable CharStringListPtr retCon;
bool usingExternal;
bool usingExternalHost;
bool usingExternalOSC;

ExternalGraph extGraph;

@@ -174,10 +179,10 @@ public:
void removePlugin(CarlaPlugin* const plugin);
void removeAllPlugins();

bool connect(const bool external, const uint groupA, const uint portA, const uint groupB, const uint portB, const bool sendCallback);
bool disconnect(const uint connectionId);
bool connect(const bool external, const uint groupA, const uint portA, const uint groupB, const uint portB);
bool disconnect(const bool external, const uint connectionId);
void disconnectInternalGroup(const uint groupId) noexcept;
void refresh(const bool sendHost, const bool sendOsc, const char* const deviceName);
void refresh(const bool sendHost, const bool sendOsc, const bool external, const char* const deviceName);

const char* const* getConnections(const bool external) const;
bool getGroupAndPortIdFromFullName(const bool external, const char* const fullPortName, uint& groupId, uint& portId) const;


+ 4
- 2
source/backend/engine/CarlaEngineInternal.hpp View File

@@ -98,8 +98,10 @@ public:
void removePlugin(CarlaPlugin* const plugin);
void removeAllPlugins();

bool isUsingExternal() const noexcept;
void setUsingExternal(const bool usingExternal) noexcept;
bool isUsingExternalHost() const noexcept;
bool isUsingExternalOSC() const noexcept;
void setUsingExternalHost(const bool usingExternal) noexcept;
void setUsingExternalOSC(const bool usingExternal) noexcept;

private:
bool fIsRack;


+ 59
- 40
source/backend/engine/CarlaEngineJack.cpp View File

@@ -805,7 +805,8 @@ public:
CarlaThread("CarlaEngineJackCallbacks"),
#endif
fClient(nullptr),
fExternalPatchbay(true),
fExternalPatchbayHost(true),
fExternalPatchbayOsc(true),
fFreewheel(false),
#ifdef BUILD_BRIDGE
fIsRunning(false)
@@ -885,8 +886,9 @@ public:
CARLA_SAFE_ASSERT_RETURN(jackbridge_is_ok(), false);
carla_debug("CarlaEngineJack::init(\"%s\")", clientName);

fFreewheel = false;
fExternalPatchbay = true;
fFreewheel = false;
fExternalPatchbayHost = true;
fExternalPatchbayOsc = true;

CarlaString truncatedClientName(clientName);
truncatedClientName.truncate(getMaxClientNameSize());
@@ -986,6 +988,8 @@ public:
else
{
pData->graph.create(2, 2);
// pData->graph.setUsingExternalHost(true);
// pData->graph.setUsingExternalOSC(true);
patchbayRefresh(true, false, false);
}
}
@@ -1362,7 +1366,7 @@ public:
if (connectionToId.groupA != groupId && connectionToId.groupB != groupId)
continue;

callback(true, true,
callback(fExternalPatchbayHost, fExternalPatchbayOsc,
ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED,
connectionToId.id,
0, 0, 0, 0.0f, nullptr);
@@ -1377,7 +1381,7 @@ public:
if (portNameToId.group != groupId)
continue;

callback(true, true,
callback(fExternalPatchbayHost, fExternalPatchbayOsc,
ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED,
portNameToId.group,
static_cast<int>(portNameToId.port),
@@ -1412,12 +1416,13 @@ public:
// -------------------------------------------------------------------
// Patchbay

bool patchbayConnect(const uint groupA, const uint portA, const uint groupB, const uint portB) override
bool patchbayConnect(const bool external,
const uint groupA, const uint portA, const uint groupB, const uint portB) override
{
CARLA_SAFE_ASSERT_RETURN(fClient != nullptr, false);

if (pData->options.processMode == ENGINE_PROCESS_MODE_PATCHBAY && ! fExternalPatchbay)
return CarlaEngine::patchbayConnect(groupA, portA, groupB, portB);
if (pData->options.processMode == ENGINE_PROCESS_MODE_PATCHBAY && ! external)
return CarlaEngine::patchbayConnect(false, groupA, portA, groupB, portB);

const char* const fullPortNameA = fUsedPorts.getFullPortName(groupA, portA);
CARLA_SAFE_ASSERT_RETURN(fullPortNameA != nullptr && fullPortNameA[0] != '\0', false);
@@ -1434,12 +1439,12 @@ public:
return true;
}

bool patchbayDisconnect(const uint connectionId) override
bool patchbayDisconnect(const bool external, const uint connectionId) override
{
CARLA_SAFE_ASSERT_RETURN(fClient != nullptr, false);

if (pData->options.processMode == ENGINE_PROCESS_MODE_PATCHBAY && ! fExternalPatchbay)
return CarlaEngine::patchbayDisconnect(connectionId);
if (pData->options.processMode == ENGINE_PROCESS_MODE_PATCHBAY && ! external)
return CarlaEngine::patchbayDisconnect(false, connectionId);

ConnectionToId connectionToId = { 0, 0, 0, 0, 0 };

@@ -1477,17 +1482,25 @@ public:
return true;
}

bool patchbayRefresh(const bool sendHost, const bool sendOsc, const bool external) override
bool patchbayRefresh(const bool sendHost, const bool sendOSC, const bool external) override
{
CARLA_SAFE_ASSERT_RETURN(fClient != nullptr, false);

if (pData->options.processMode == ENGINE_PROCESS_MODE_PATCHBAY)
{
fExternalPatchbay = external;
pData->graph.setUsingExternal(external);
if (sendHost)
{
fExternalPatchbayHost = external;
pData->graph.setUsingExternalHost(external);
}
if (sendOSC)
{
fExternalPatchbayOsc = external;
pData->graph.setUsingExternalOSC(external);
}

if (! external)
return CarlaEngine::patchbayRefresh(sendHost, sendOsc, false);
return CarlaEngine::patchbayRefresh(sendHost, sendOSC, false);
}

fUsedGroups.clear();
@@ -1495,7 +1508,7 @@ public:
fUsedConnections.clear();
fNewGroups.clear();

initJackPatchbay(sendHost, sendOsc, jackbridge_get_client_name(fClient));
initJackPatchbay(sendHost, sendOSC, jackbridge_get_client_name(fClient));
return true;
}

@@ -1619,15 +1632,16 @@ public:
return fRetConns;
}

void restorePatchbayConnection(const bool external, const char* const connSource, const char* const connTarget, const bool sendCallback) override
void restorePatchbayConnection(const bool external, const char* const connSource, const char* const connTarget) override
{
CARLA_SAFE_ASSERT_RETURN(fClient != nullptr,);
CARLA_SAFE_ASSERT_RETURN(connSource != nullptr && connSource[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(connTarget != nullptr && connTarget[0] != '\0',);
carla_debug("CarlaEngineJack::restorePatchbayConnection(\"%s\", \"%s\")", connSource, connTarget);
carla_debug("CarlaEngineJack::restorePatchbayConnection(%s, \"%s\", \"%s\")",
bool2str(external), connSource, connTarget);

if (pData->options.processMode == ENGINE_PROCESS_MODE_PATCHBAY && ! external)
return CarlaEngine::restorePatchbayConnection(external, connSource, connTarget, sendCallback);
return CarlaEngine::restorePatchbayConnection(external, connSource, connTarget);

if (const jack_port_t* const port = jackbridge_port_by_name(fClient, connSource))
{
@@ -1961,7 +1975,7 @@ protected:
CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0',);

// ignore this if on internal patchbay mode
if (! fExternalPatchbay) return;
if (! (fExternalPatchbayHost || (fExternalPatchbayOsc && pData->osc.isControlRegisteredForTCP()))) return;

// do nothing on client registration, wait for first port
if (reg) return;
@@ -1974,14 +1988,16 @@ protected:
GroupNameToId groupNameToId;
groupNameToId.setData(groupId, name);

callback(true, true, ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED, groupNameToId.group, 0, 0, 0, 0.0f, nullptr);
callback(fExternalPatchbayHost, fExternalPatchbayOsc,
ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED, groupNameToId.group, 0, 0, 0, 0.0f, nullptr);

fUsedGroups.list.removeOne(groupNameToId);
}

void handleJackPortRegistrationCallback(const jack_port_id_t port, const bool reg)
{
// ignore this if on internal patchbay mode
if (! fExternalPatchbay) return;
if (! (fExternalPatchbayHost || (fExternalPatchbayOsc && pData->osc.isControlRegisteredForTCP()))) return;

const jack_port_t* const jackPort(jackbridge_port_by_id(fClient, port));
CARLA_SAFE_ASSERT_RETURN(jackPort != nullptr,);
@@ -2011,7 +2027,7 @@ protected:
GroupNameToId groupNameToId;
groupNameToId.setData(groupId, groupName);

callback(true, true,
callback(fExternalPatchbayHost, fExternalPatchbayOsc,
ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED,
groupNameToId.group,
(jackPortFlags & JackPortIsPhysical) ? PATCHBAY_ICON_HARDWARE : PATCHBAY_ICON_APPLICATION,
@@ -2023,7 +2039,8 @@ protected:
fUsedGroups.list.append(groupNameToId);
}

addPatchbayJackPort(true, true, groupId, jackPort, shortPortName, fullPortName, jackPortFlags);
addPatchbayJackPort(fExternalPatchbayHost, fExternalPatchbayOsc,
groupId, jackPort, shortPortName, fullPortName, jackPortFlags);
}
else
{
@@ -2033,7 +2050,7 @@ protected:
See the comment on CarlaEngineJack::renamePlugin() for more information. */
if (portNameToId.group <= 0 || portNameToId.port <= 0) return;

callback(true, true,
callback(fExternalPatchbayHost, fExternalPatchbayOsc,
ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED,
portNameToId.group,
static_cast<int>(portNameToId.port),
@@ -2045,7 +2062,7 @@ protected:
void handleJackPortConnectCallback(const jack_port_id_t a, const jack_port_id_t b, const bool connect)
{
// ignore this if on internal patchbay mode
if (! fExternalPatchbay) return;
if (! (fExternalPatchbayHost || (fExternalPatchbayOsc && pData->osc.isControlRegisteredForTCP()))) return;

const jack_port_t* const jackPortA(jackbridge_port_by_id(fClient, a));
CARLA_SAFE_ASSERT_RETURN(jackPortA != nullptr,);
@@ -2076,7 +2093,7 @@ protected:
ConnectionToId connectionToId;
connectionToId.setData(++fUsedConnections.lastId, portNameToIdA.group, portNameToIdA.port, portNameToIdB.group, portNameToIdB.port);

callback(true, true,
callback(fExternalPatchbayHost, fExternalPatchbayOsc,
ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED,
connectionToId.id,
0, 0, 0, 0.0f,
@@ -2107,7 +2124,7 @@ protected:
}

if (found) {
callback(true, true,
callback(fExternalPatchbayHost, fExternalPatchbayOsc,
ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED,
connectionToId.id,
0, 0, 0, 0.0f, nullptr);
@@ -2118,7 +2135,7 @@ protected:
void handleJackPortRenameCallback(const jack_port_id_t port, const char* const oldFullName, const char* const newFullName)
{
// ignore this if on internal patchbay mode
if (! fExternalPatchbay) return;
if (! (fExternalPatchbayHost || (fExternalPatchbayOsc && pData->osc.isControlRegisteredForTCP()))) return;

CARLA_SAFE_ASSERT_RETURN(oldFullName != nullptr && oldFullName[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(newFullName != nullptr && newFullName[0] != '\0',);
@@ -2150,7 +2167,7 @@ protected:
CARLA_SAFE_ASSERT_CONTINUE(portNameToId.group == groupId);

portNameToId.rename(shortPortName, newFullName);
callback(true, true,
callback(fExternalPatchbayHost, fExternalPatchbayOsc,
ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED,
portNameToId.group,
static_cast<int>(portNameToId.port),
@@ -2212,7 +2229,8 @@ protected:

private:
jack_client_t* fClient;
bool fExternalPatchbay;
bool fExternalPatchbayHost;
bool fExternalPatchbayOsc;
bool fFreewheel;

// -------------------------------------------------------------------
@@ -2295,9 +2313,10 @@ private:
return false;
}

void initJackPatchbay(const bool sendHost, const bool sendOsc, const char* const ourName)
void initJackPatchbay(const bool sendHost, const bool sendOSC, const char* const ourName)
{
CARLA_SAFE_ASSERT_RETURN(pData->options.processMode != ENGINE_PROCESS_MODE_PATCHBAY || fExternalPatchbay,);
CARLA_SAFE_ASSERT_RETURN(pData->options.processMode != ENGINE_PROCESS_MODE_PATCHBAY ||
(fExternalPatchbayHost && sendHost) || (fExternalPatchbayOsc && sendOSC),);
CARLA_SAFE_ASSERT_RETURN(ourName != nullptr && ourName[0] != '\0',);

CarlaStringList parsedGroups;
@@ -2309,7 +2328,7 @@ private:
GroupNameToId groupNameToId;
groupNameToId.setData(++fUsedGroups.lastId, ourName);

callback(sendHost, sendOsc,
callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED,
groupNameToId.group,
PATCHBAY_ICON_CARLA,
@@ -2361,7 +2380,7 @@ private:
GroupNameToId groupNameToId;
groupNameToId.setData(groupId, groupName);

callback(sendHost, sendOsc,
callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED,
groupNameToId.group,
icon,
@@ -2371,7 +2390,7 @@ private:
fUsedGroups.list.append(groupNameToId);
}

addPatchbayJackPort(sendHost, sendOsc, groupId, jackPort, shortPortName, fullPortName, jackPortFlags);
addPatchbayJackPort(sendHost, sendOSC, groupId, jackPort, shortPortName, fullPortName, jackPortFlags);
}

jackbridge_free(ports);
@@ -2413,7 +2432,7 @@ private:
ConnectionToId connectionToId;
connectionToId.setData(++fUsedConnections.lastId, thisPort.group, thisPort.port, targetPort.group, targetPort.port);

callback(sendHost, sendOsc,
callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED,
connectionToId.id,
0, 0, 0, 0.0f,
@@ -2429,7 +2448,7 @@ private:
}
}

void addPatchbayJackPort(const bool sendHost, const bool sendOsc,
void addPatchbayJackPort(const bool sendHost, const bool sendOSC,
const uint groupId, const jack_port_t* const jackPort,
const char* const shortPortName, const char* const fullPortName, const int jackPortFlags)
{
@@ -2469,7 +2488,7 @@ private:
PortNameToId portNameToId;
portNameToId.setData(groupId, ++fUsedPorts.lastId, shortPortName, fullPortName);

callback(sendHost, sendOsc,
callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_PORT_ADDED,
portNameToId.group,
static_cast<int>(portNameToId.port),
@@ -2642,7 +2661,7 @@ private:
PatchbayIcon icon = PATCHBAY_ICON_PLUGIN;

if (findPluginIdAndIcon(groupName, pluginId, icon)) {
callback(true, true,
callback(fExternalPatchbayHost, fExternalPatchbayOsc,
ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED,
groupId,
icon,


+ 13
- 10
source/backend/engine/CarlaEngineJuce.cpp View File

@@ -343,7 +343,7 @@ public:
// Patchbay

template<class Graph>
bool refreshExternalGraphPorts(Graph* const graph, const bool sendHost, const bool sendOsc)
bool refreshExternalGraphPorts(Graph* const graph, const bool sendHost, const bool sendOSC)
{
CARLA_SAFE_ASSERT_RETURN(graph != nullptr, false);

@@ -412,14 +412,14 @@ public:
// ---------------------------------------------------------------
// now refresh

if (sendHost || sendOsc)
if (sendHost || sendOSC)
{
juce::String deviceName(fDevice->getName());

if (deviceName.isNotEmpty())
deviceName = deviceName.dropLastCharacters(deviceName.fromFirstOccurrenceOf(", ", true, false).length());

graph->refresh(sendHost, sendOsc, deviceName.toRawUTF8());
graph->refresh(sendHost, sendOSC, true, deviceName.toRawUTF8());
}

// ---------------------------------------------------------------
@@ -439,7 +439,7 @@ public:
std::snprintf(strBuf, STR_MAX-1, "%i:%i:%i:%i", connectionToId.groupA, connectionToId.portA, connectionToId.groupB, connectionToId.portB);
strBuf[STR_MAX-1] = '\0';

callback(sendHost, sendOsc,
callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED,
connectionToId.id,
0, 0, 0, 0.0f,
@@ -464,7 +464,7 @@ public:
std::snprintf(strBuf, STR_MAX-1, "%i:%i:%i:%i", connectionToId.groupA, connectionToId.portA, connectionToId.groupB, connectionToId.portB);
strBuf[STR_MAX-1] = '\0';

callback(sendHost, sendOsc,
callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED,
connectionToId.id,
0, 0, 0, 0.0f,
@@ -478,19 +478,22 @@ public:
return true;
}

bool patchbayRefresh(const bool sendHost, const bool sendOsc, const bool external) override
bool patchbayRefresh(const bool sendHost, const bool sendOSC, const bool external) override
{
CARLA_SAFE_ASSERT_RETURN(pData->graph.isReady(), false);

if (pData->options.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK)
return refreshExternalGraphPorts<RackGraph>(pData->graph.getRackGraph(), sendHost, sendOsc);
return refreshExternalGraphPorts<RackGraph>(pData->graph.getRackGraph(), sendHost, sendOSC);

pData->graph.setUsingExternal(external);
if (sendHost)
pData->graph.setUsingExternalHost(external);
if (sendOSC)
pData->graph.setUsingExternalOSC(external);

if (external)
return refreshExternalGraphPorts<PatchbayGraph>(pData->graph.getPatchbayGraph(), sendHost, sendOsc);
return refreshExternalGraphPorts<PatchbayGraph>(pData->graph.getPatchbayGraph(), sendHost, sendOSC);

return CarlaEngine::patchbayRefresh(sendHost, sendOsc, false);
return CarlaEngine::patchbayRefresh(sendHost, sendOSC, false);
}

// -------------------------------------------------------------------


+ 6
- 2
source/backend/engine/CarlaEngineNative.cpp View File

@@ -215,25 +215,29 @@ protected:
}
else if (std::strcmp(msg, "patchbay_connect") == 0)
{
bool external;
uint32_t groupA, portA, groupB, portB;

CARLA_SAFE_ASSERT_RETURN(readNextLineAsBool(external), true);
CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(groupA), true);
CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(portA), true);
CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(groupB), true);
CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(portB), true);

try {
ok = fEngine->patchbayConnect(groupA, portA, groupB, portB);
ok = fEngine->patchbayConnect(external, groupA, portA, groupB, portB);
} CARLA_SAFE_EXCEPTION("patchbayConnect");
}
else if (std::strcmp(msg, "patchbay_disconnect") == 0)
{
bool external;
uint32_t connectionId;

CARLA_SAFE_ASSERT_RETURN(readNextLineAsBool(external), true);
CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(connectionId), true);

try {
ok = fEngine->patchbayDisconnect(connectionId);
ok = fEngine->patchbayDisconnect(external, connectionId);
} CARLA_SAFE_EXCEPTION("patchbayDisconnect");
}
else if (std::strcmp(msg, "patchbay_refresh") == 0)


+ 19
- 12
source/backend/engine/CarlaEngineOscHandlers.cpp View File

@@ -242,7 +242,7 @@ int CarlaEngineOsc::handleMsgRegister(const bool isTCP,
fEngine->callback(false, true, ENGINE_CALLBACK_PLUGIN_ADDED, i, 0, 0, 0, 0.0f, plugin->getName());
}

fEngine->patchbayRefresh(false, true, fEngine->pData->graph.isUsingExternal());
fEngine->patchbayRefresh(false, true, fEngine->pData->graph.isUsingExternalOSC());

#if 0
void CarlaPlugin::registerToOscClient() noexcept
@@ -332,14 +332,14 @@ int CarlaEngineOsc::handleMsgControl(const char* const method,
}
else if (std::strcmp(method, "patchbay_connect") == 0)
{
CARLA_SAFE_ASSERT_INT_RETURN(argc == 4, argc, 0);
CARLA_SAFE_ASSERT_INT_RETURN(argc == 5, argc, 0);
CARLA_SAFE_ASSERT_RETURN(types[0] == 'i', 0);
CARLA_SAFE_ASSERT_RETURN(types[1] == 'i', 0);
CARLA_SAFE_ASSERT_RETURN(types[2] == 'i', 0);
CARLA_SAFE_ASSERT_RETURN(types[3] == 'i', 0);
CARLA_SAFE_ASSERT_RETURN(types[4] == 'i', 0);

const int32_t i0 = argv[0]->i;
CARLA_SAFE_ASSERT_RETURN(i0 >= 0, 0);
const bool ext = argv[0]->i != 0;

const int32_t i1 = argv[1]->i;
CARLA_SAFE_ASSERT_RETURN(i1 >= 0, 0);
@@ -350,28 +350,35 @@ int CarlaEngineOsc::handleMsgControl(const char* const method,
const int32_t i3 = argv[3]->i;
CARLA_SAFE_ASSERT_RETURN(i3 >= 0, 0);

fEngine->patchbayConnect(static_cast<uint32_t>(i0),
const int32_t i4 = argv[4]->i;
CARLA_SAFE_ASSERT_RETURN(i4 >= 0, 0);

fEngine->patchbayConnect(ext,
static_cast<uint32_t>(i1),
static_cast<uint32_t>(i2),
static_cast<uint32_t>(i3));
static_cast<uint32_t>(i3),
static_cast<uint32_t>(i4));
}
else if (std::strcmp(method, "patchbay_disconnect") == 0)
{
CARLA_SAFE_ASSERT_INT_RETURN(argc == 1, argc, 0);
CARLA_SAFE_ASSERT_INT_RETURN(argc == 2, argc, 0);
CARLA_SAFE_ASSERT_RETURN(types[0] == 'i', 0);
CARLA_SAFE_ASSERT_RETURN(types[1] == 'i', 0);

const int32_t i = argv[0]->i;
CARLA_SAFE_ASSERT_RETURN(i >= 0, 0);
const bool ext = argv[0]->i != 0;

fEngine->patchbayDisconnect(static_cast<uint32_t>(i));
const int32_t id = argv[1]->i;
CARLA_SAFE_ASSERT_RETURN(id >= 0, 0);

fEngine->patchbayDisconnect(ext, static_cast<uint32_t>(id));
}
else if (std::strcmp(method, "patchbay_refresh") == 0)
{
CARLA_SAFE_ASSERT_INT_RETURN(argc == 1, argc, 0);
CARLA_SAFE_ASSERT_RETURN(types[0] == 'i', 0);

const int32_t i = argv[0]->i;
fEngine->patchbayRefresh(false, true, i != 0);
const bool ext = argv[0]->i != 0;
fEngine->patchbayRefresh(false, true, ext);
}
else if (std::strcmp(method, "transport_play") == 0)
{


+ 13
- 10
source/backend/engine/CarlaEngineRtAudio.cpp View File

@@ -463,7 +463,7 @@ public:
// Patchbay

template<class Graph>
bool refreshExternalGraphPorts(Graph* const graph, const bool sendHost, const bool sendOsc)
bool refreshExternalGraphPorts(Graph* const graph, const bool sendHost, const bool sendOSC)
{
CARLA_SAFE_ASSERT_RETURN(graph != nullptr, false);

@@ -533,8 +533,8 @@ public:
// ---------------------------------------------------------------
// now refresh

if (sendHost || sendOsc)
graph->refresh(sendHost, sendOsc, fDeviceName.buffer());
if (sendHost || sendOSC)
graph->refresh(sendHost, sendOSC, true, fDeviceName.buffer());

// ---------------------------------------------------------------
// add midi connections
@@ -556,7 +556,7 @@ public:

extGraph.connections.list.append(connectionToId);

callback(sendHost, sendOsc,
callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED,
connectionToId.id,
0, 0, 0, 0.0f,
@@ -582,7 +582,7 @@ public:

extGraph.connections.list.append(connectionToId);

callback(sendHost, sendOsc,
callback(sendHost, sendOSC,
ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED,
connectionToId.id,
0, 0, 0, 0.0f,
@@ -594,19 +594,22 @@ public:
return true;
}

bool patchbayRefresh(const bool sendHost, const bool sendOsc, const bool external) override
bool patchbayRefresh(const bool sendHost, const bool sendOSC, const bool external) override
{
CARLA_SAFE_ASSERT_RETURN(pData->graph.isReady(), false);

if (pData->options.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK)
return refreshExternalGraphPorts<RackGraph>(pData->graph.getRackGraph(), sendHost, sendOsc);
return refreshExternalGraphPorts<RackGraph>(pData->graph.getRackGraph(), sendHost, sendOSC);

pData->graph.setUsingExternal(external);
if (sendHost)
pData->graph.setUsingExternalHost(external);
if (sendOSC)
pData->graph.setUsingExternalOSC(external);

if (external)
return refreshExternalGraphPorts<PatchbayGraph>(pData->graph.getPatchbayGraph(), sendHost, sendOsc);
return refreshExternalGraphPorts<PatchbayGraph>(pData->graph.getPatchbayGraph(), sendHost, sendOSC);

return CarlaEngine::patchbayRefresh(sendHost, sendOsc, false);
return CarlaEngine::patchbayRefresh(sendHost, sendOSC, false);
}

// -------------------------------------------------------------------


+ 14
- 14
source/frontend/carla_backend.py View File

@@ -1481,14 +1481,14 @@ class CarlaHostMeta(object):
# @param portIdB Input port
# @see ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED
@abstractmethod
def patchbay_connect(self, groupIdA, portIdA, groupIdB, portIdB):
def patchbay_connect(self, external, groupIdA, portIdA, groupIdB, portIdB):
raise NotImplementedError

# Disconnect two patchbay ports.
# @param connectionId Connection Id
# @see ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED
@abstractmethod
def patchbay_disconnect(self, connectionId):
def patchbay_disconnect(self, external, connectionId):
raise NotImplementedError

# Force the engine to resend all patchbay clients, ports and connections again.
@@ -2083,10 +2083,10 @@ class CarlaHostNull(CarlaHostMeta):
def clear_project_filename(self):
return

def patchbay_connect(self, groupIdA, portIdA, groupIdB, portIdB):
def patchbay_connect(self, external, groupIdA, portIdA, groupIdB, portIdB):
return False

def patchbay_disconnect(self, connectionId):
def patchbay_disconnect(self, external, connectionId):
return False

def patchbay_refresh(self, external):
@@ -2380,10 +2380,10 @@ class CarlaHostDLL(CarlaHostMeta):
self.lib.carla_clear_project_filename.argtypes = None
self.lib.carla_clear_project_filename.restype = None

self.lib.carla_patchbay_connect.argtypes = [c_uint, c_uint, c_uint, c_uint]
self.lib.carla_patchbay_connect.argtypes = [c_bool, c_uint, c_uint, c_uint, c_uint]
self.lib.carla_patchbay_connect.restype = c_bool

self.lib.carla_patchbay_disconnect.argtypes = [c_uint]
self.lib.carla_patchbay_disconnect.argtypes = [c_bool, c_uint]
self.lib.carla_patchbay_disconnect.restype = c_bool

self.lib.carla_patchbay_refresh.argtypes = [c_bool]
@@ -2669,11 +2669,11 @@ class CarlaHostDLL(CarlaHostMeta):
def clear_project_filename(self):
self.lib.carla_clear_project_filename()

def patchbay_connect(self, groupIdA, portIdA, groupIdB, portIdB):
return bool(self.lib.carla_patchbay_connect(groupIdA, portIdA, groupIdB, portIdB))
def patchbay_connect(self, external, groupIdA, portIdA, groupIdB, portIdB):
return bool(self.lib.carla_patchbay_connect(external, groupIdA, portIdA, groupIdB, portIdB))

def patchbay_disconnect(self, connectionId):
return bool(self.lib.carla_patchbay_disconnect(connectionId))
def patchbay_disconnect(self, external, connectionId):
return bool(self.lib.carla_patchbay_disconnect(external, connectionId))

def patchbay_refresh(self, external):
return bool(self.lib.carla_patchbay_refresh(external))
@@ -3027,11 +3027,11 @@ class CarlaHostPlugin(CarlaHostMeta):
def clear_project_filename(self):
return self.sendMsgAndSetError(["clear_project_filename"])

def patchbay_connect(self, groupIdA, portIdA, groupIdB, portIdB):
return self.sendMsgAndSetError(["patchbay_connect", groupIdA, portIdA, groupIdB, portIdB])
def patchbay_connect(self, external, groupIdA, portIdA, groupIdB, portIdB):
return self.sendMsgAndSetError(["patchbay_connect", external, groupIdA, portIdA, groupIdB, portIdB])

def patchbay_disconnect(self, connectionId):
return self.sendMsgAndSetError(["patchbay_disconnect", connectionId])
def patchbay_disconnect(self, external, connectionId):
return self.sendMsgAndSetError(["patchbay_disconnect", external, connectionId])

def patchbay_refresh(self, external):
return self.sendMsgAndSetError(["patchbay_refresh", external])


+ 2
- 2
source/frontend/carla_host.py View File

@@ -2531,13 +2531,13 @@ def canvasCallback(action, value1, value2, valueStr):
elif action == patchcanvas.ACTION_PORTS_CONNECT:
gOut, pOut, gIn, pIn = [int(i) for i in valueStr.split(":")]

if not host.patchbay_connect(gOut, pOut, gIn, pIn):
if not host.patchbay_connect(gCarla.gui.fExternalPatchbay, gOut, pOut, gIn, pIn):
print("Connection failed:", host.get_last_error())

elif action == patchcanvas.ACTION_PORTS_DISCONNECT:
connectionId = value1

if not host.patchbay_disconnect(connectionId):
if not host.patchbay_disconnect(gCarla.gui.fExternalPatchbay, connectionId):
print("Disconnect failed:", host.get_last_error())

elif action == patchcanvas.ACTION_PLUGIN_CLONE:


Loading…
Cancel
Save