src/JackCommand.h
branchv_0
changeset 14 cde9bb07ea0a
parent 13 326935d1bfab
child 15 463ce61415f1
equal deleted inserted replaced
13:326935d1bfab 14:cde9bb07ea0a
   244 		}
   244 		}
   245 
   245 
   246 		jack_free(sourcePortNames);
   246 		jack_free(sourcePortNames);
   247 	}
   247 	}
   248 
   248 
       
   249 	void applyConnectionRecipes() {
       
   250 		for (Configuration::ConnectionRecipe recipe : configuration.connectionRecipes) {
       
   251 			auto operation = recipe.connected ? jack_connect : jack_disconnect;
       
   252 			int result = operation(realTimeContext.jackClient, convertor.to_bytes(recipe.sourcePort).c_str(), convertor.to_bytes(recipe.destinationPort).c_str());
       
   253 			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;
       
   254 		}
       
   255 	}
       
   256 
   249 	static void jackErrorCallback(const char * message) {
   257 	static void jackErrorCallback(const char * message) {
   250 		std::wstring_convert < std::codecvt_utf8<wchar_t>> convertor; // TODO: local system encoding
   258 		std::wstring_convert < std::codecvt_utf8<wchar_t>> convertor; // TODO: local system encoding
   251 		std::wcerr << L"JACK: " << convertor.from_bytes(message) << std::endl;
   259 		std::wcerr << L"JACK: " << convertor.from_bytes(message) << std::endl;
   252 	}
   260 	}
   253 
   261 
   308 
   316 
   309 	void processJackStream(std::shared_ptr<relpipe::writer::RelationalWriter> writer, std::function<void() > relationalWriterFlush) {
   317 	void processJackStream(std::shared_ptr<relpipe::writer::RelationalWriter> writer, std::function<void() > relationalWriterFlush) {
   310 		// Relation headers:
   318 		// Relation headers:
   311 		using namespace relpipe::writer;
   319 		using namespace relpipe::writer;
   312 		vector<AttributeMetadata> metadata;
   320 		vector<AttributeMetadata> metadata;
       
   321 
       
   322 		applyConnectionRecipes();
   313 
   323 
   314 		if (configuration.listPorts) listPorts(writer);
   324 		if (configuration.listPorts) listPorts(writer);
   315 		if (configuration.listConnections) listConnections(writer);
   325 		if (configuration.listConnections) listConnections(writer);
   316 		if (!configuration.listMidiMessages) return;
   326 		if (!configuration.listMidiMessages) return;
   317 
   327