Browse Source

Implement patchbay state for JACK

tags/1.9.4
falkTX 10 years ago
parent
commit
af07ecf483
2 changed files with 71 additions and 2 deletions
  1. +4
    -2
      source/backend/engine/CarlaEngine.cpp
  2. +67
    -0
      source/backend/engine/CarlaEngineJack.cpp

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

@@ -1469,6 +1469,9 @@ bool CarlaEngine::saveProject(const char* const filename)

if (const char* const* patchbayConns = getPatchbayConnections())
{
if (! firstPlugin)
out << "\n";

out << " <Patchbay>\n";

for (int i=0; patchbayConns[i] != nullptr && patchbayConns[i+1] != nullptr; ++i, ++i )
@@ -2074,10 +2077,9 @@ static int getCarlaPortIdFromName(const char* const shortname) noexcept

void CarlaEngine::restorePatchbayConnection(const char* const connSource, const char* const connTarget)
{
carla_debug("CarlaEngine::restorePatchbayConnection(\"%s\", \"%s\")", connSource, connTarget);

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);

if (pData->bufAudio.usePatchbay)
{


+ 67
- 0
source/backend/engine/CarlaEngineJack.cpp View File

@@ -982,6 +982,73 @@ public:
#endif

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

const char* const* getPatchbayConnections() const override
{
CARLA_SAFE_ASSERT_RETURN(fClient != nullptr, nullptr);
carla_debug("CarlaEngineJack::getPatchbayConnections()");

LinkedList<const char*> connList;

if (const char** ports = jackbridge_get_ports(fClient, nullptr, nullptr, 0))
{
for (int i=0; ports[i] != nullptr; ++i)
{
jack_port_t* const jackPort(jackbridge_port_by_name(fClient, ports[i]));
const char* const fullPortName(ports[i]);

CARLA_SAFE_ASSERT_CONTINUE(jackPort != nullptr);

if (const char** connections = jackbridge_port_get_all_connections(fClient, jackPort))
{
for (int j=0; connections[j] != nullptr; ++j)
{
connList.append(carla_strdup(fullPortName));
connList.append(carla_strdup(connections[j]));
}

jackbridge_free(connections);
}
}

jackbridge_free(ports);
}

const size_t connCount(connList.count());

if (connCount == 0)
return nullptr;

const char** const retConns = new const char*[connCount+1];

for (size_t i=0; i < connCount; ++i)
retConns[i] = connList.getAt(i);

retConns[connCount] = nullptr;
connList.clear();

return retConns;
}

void restorePatchbayConnection(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);

if (jack_port_t* const port = jackbridge_port_by_name(fClient, connTarget))
{
if (jackbridge_port_by_name(fClient, connSource) == nullptr)
return;

if (! jackbridge_port_connected_to(port, connSource))
jackbridge_connect(fClient, connTarget, connSource);
}
}

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

protected:
void handleJackBufferSizeCallback(const uint32_t newBufferSize)


Loading…
Cancel
Save