--- a/src/JackCommand.h Wed Oct 07 22:29:38 2020 +0200
+++ b/src/JackCommand.h Thu Oct 08 16:45:50 2020 +0200
@@ -187,7 +187,7 @@
writer->startRelation(L"port", metadata, true);
const char** portNames = jack_get_ports(realTimeContext.jackClient, nullptr, nullptr, 0);
-
+
std::regex midiTypePattern(".*midi$");
for (const char** portName = portNames; *portName; portName++) {
@@ -216,6 +216,36 @@
jack_free(portNames);
}
+ void listConnections(std::shared_ptr<relpipe::writer::RelationalWriter> writer) {
+ using namespace relpipe::writer;
+ vector<AttributeMetadata> metadata;
+
+ metadata.push_back({L"event", TypeId::STRING});
+ metadata.push_back({L"source_port", TypeId::STRING});
+ metadata.push_back({L"destination_port", TypeId::STRING});
+ writer->startRelation(L"connection", metadata, true);
+
+ const relpipe::common::type::StringX event = L"connect";
+
+ const char** sourcePortNames = jack_get_ports(realTimeContext.jackClient, nullptr, nullptr, JackPortFlags::JackPortIsOutput);
+
+ for (const char** sourcePortName = sourcePortNames; *sourcePortName; sourcePortName++) {
+ jack_port_t* sourcePort = jack_port_by_name(realTimeContext.jackClient, *sourcePortName);
+
+ const char** destinationPortNames = jack_port_get_all_connections(realTimeContext.jackClient, sourcePort);
+
+ for (const char** destinationPortName = destinationPortNames; destinationPortNames && *destinationPortName; destinationPortName++) {
+ writer->writeAttribute(event);
+ writer->writeAttribute(convertor.from_bytes(*sourcePortName));
+ writer->writeAttribute(convertor.from_bytes(*destinationPortName));
+ }
+
+ jack_free(destinationPortNames);
+ }
+
+ jack_free(sourcePortNames);
+ }
+
static void jackErrorCallback(const char * message) {
std::wstring_convert < std::codecvt_utf8<wchar_t>> convertor; // TODO: local system encoding
std::wcerr << L"JACK: " << convertor.from_bytes(message) << std::endl;
@@ -282,6 +312,7 @@
vector<AttributeMetadata> metadata;
if (configuration.listPorts) listPorts(writer);
+ if (configuration.listConnections) listConnections(writer);
if (!configuration.listMidiMessages) return;
metadata.push_back({L"event", TypeId::STRING});