src/JackCommand.h
branchv_0
changeset 14 cde9bb07ea0a
parent 13 326935d1bfab
child 15 463ce61415f1
--- a/src/JackCommand.h	Thu Oct 08 16:45:50 2020 +0200
+++ b/src/JackCommand.h	Thu Oct 08 17:23:07 2020 +0200
@@ -246,6 +246,14 @@
 		jack_free(sourcePortNames);
 	}
 
+	void applyConnectionRecipes() {
+		for (Configuration::ConnectionRecipe recipe : configuration.connectionRecipes) {
+			auto operation = recipe.connected ? jack_connect : jack_disconnect;
+			int result = operation(realTimeContext.jackClient, convertor.to_bytes(recipe.sourcePort).c_str(), convertor.to_bytes(recipe.destinationPort).c_str());
+			if (result != 0 && result != EEXIST) std::wcerr << L"Unable to " << (recipe.connected ? L"connect" : L"disconnect") << L": „" << recipe.sourcePort << L"“ to: „" << recipe.destinationPort << L"“." << std::endl;
+		}
+	}
+
 	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;
@@ -311,6 +319,8 @@
 		using namespace relpipe::writer;
 		vector<AttributeMetadata> metadata;
 
+		applyConnectionRecipes();
+
 		if (configuration.listPorts) listPorts(writer);
 		if (configuration.listConnections) listConnections(writer);
 		if (!configuration.listMidiMessages) return;