--- a/src/JackCommand.h Thu Oct 08 17:23:07 2020 +0200
+++ b/src/JackCommand.h Sun Oct 11 17:13:02 2020 +0200
@@ -29,6 +29,8 @@
#include <regex>
#include <jack/jack.h>
+#include <jack/metadata.h>
+#include <jack/uuid.h>
#include <jack/midiport.h>
#include <jack/ringbuffer.h>
@@ -177,6 +179,7 @@
vector<AttributeMetadata> metadata;
metadata.push_back({L"name", TypeId::STRING});
+ metadata.push_back({L"uuid", TypeId::STRING});
metadata.push_back({L"input", TypeId::BOOLEAN});
metadata.push_back({L"output", TypeId::BOOLEAN});
metadata.push_back({L"physical", TypeId::BOOLEAN});
@@ -204,6 +207,7 @@
bool isMidi = std::regex_search(portType, midiTypePattern);
writer->writeAttribute(convertor.from_bytes(*portName));
+ writer->writeAttribute(convertor.from_bytes(uuidToString(jack_port_uuid(port))));
writer->writeAttribute(&isInput, typeid (isInput));
writer->writeAttribute(&isOuputput, typeid (isOuputput));
writer->writeAttribute(&isPhysical, typeid (isPhysical));
@@ -246,6 +250,42 @@
jack_free(sourcePortNames);
}
+ std::string uuidToString(jack_uuid_t uuid) {
+ char buffer[JACK_UUID_STRING_SIZE] = {0};
+ jack_uuid_unparse(uuid, buffer);
+ return buffer;
+ }
+
+ void listProperties(std::shared_ptr<relpipe::writer::RelationalWriter> writer) {
+ using namespace relpipe::writer;
+ vector<AttributeMetadata> metadata;
+
+ metadata.push_back({L"uuid", TypeId::STRING});
+ //metadata.push_back({L"port", TypeId::STRING}); // TODO: port name
+ metadata.push_back({L"name", TypeId::STRING});
+ metadata.push_back({L"type", TypeId::STRING});
+ metadata.push_back({L"value", TypeId::STRING});
+ writer->startRelation(L"property", metadata, true);
+
+ jack_description_t* descriptions = nullptr;
+
+ int descriptionsCount = jack_get_all_properties(&descriptions);
+
+ for (int i = 0; i < descriptionsCount; i++) {
+ jack_description_t* description = &descriptions[i];
+ for (uint32_t j = 0; j < description->property_cnt; j++) {
+ jack_property_t* property = &description->properties[j];
+ writer->writeAttribute(convertor.from_bytes(uuidToString(description->subject)));
+ //writer->writeAttribute(L"TODO: port name"); // TODO: port name
+ writer->writeAttribute(convertor.from_bytes(property->key));
+ writer->writeAttribute(convertor.from_bytes(property->type));
+ writer->writeAttribute(convertor.from_bytes(property->data)); // TODO: format value (some in HEX), according to .type
+ }
+ jack_free_description(description, false);
+ }
+ jack_free(descriptions);
+ }
+
void applyConnectionRecipes() {
for (Configuration::ConnectionRecipe recipe : configuration.connectionRecipes) {
auto operation = recipe.connected ? jack_connect : jack_disconnect;
@@ -323,6 +363,7 @@
if (configuration.listPorts) listPorts(writer);
if (configuration.listConnections) listConnections(writer);
+ if (configuration.listProperties) listProperties(writer);
if (!configuration.listMidiMessages) return;
metadata.push_back({L"event", TypeId::STRING});