diff options
-rw-r--r-- | src/JackDriver.cpp | 34 | ||||
-rw-r--r-- | src/PatchageCanvas.cpp | 32 | ||||
-rw-r--r-- | src/PatchageCanvas.hpp | 4 |
3 files changed, 22 insertions, 48 deletions
diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp index 32b7237..4b2807f 100644 --- a/src/JackDriver.cpp +++ b/src/JackDriver.cpp @@ -262,6 +262,7 @@ JackDriver::refresh() string port1_name; string client2_name; string port2_name; + size_t colon; // Add all ports for (int i=0; ports[i]; ++i) { @@ -310,27 +311,36 @@ JackDriver::refresh() } // Add all connections - for (int i=0; ports[i]; ++i) { + for (int i = 0; ports[i]; ++i) { port = jack_port_by_name(_client, ports[i]); const char** connected_ports = jack_port_get_all_connections(_client, port); + client1_name = ports[i]; + colon = client1_name.find(':'); + port1_name = client1_name.substr(colon + 1); + client1_name = client1_name.substr(0, colon); + + const ModuleType port1_type = (jack_port_flags(port) & JackPortIsInput) ? Input : Output; + + boost::shared_ptr<PatchageModule> client1_module + = _app->canvas()->find_module(client1_name, port1_type); + if (connected_ports) { - for (int j=0; connected_ports[j]; ++j) { - client1_name = ports[i]; - size_t colon = client1_name.find(':'); - port1_name = client1_name.substr(colon+1); - client1_name = client1_name.substr(0, colon); + for (int j = 0; connected_ports[j]; ++j) { client2_name = connected_ports[j]; - colon = client2_name.find(':'); - port2_name = client2_name.substr(colon+1); + colon = client2_name.find(':'); + port2_name = client2_name.substr(colon+1); client2_name = client2_name.substr(0, colon); - boost::shared_ptr<Port> port1 - = _app->canvas()->get_port(client1_name, port1_name); - boost::shared_ptr<Port> port2 - = _app->canvas()->get_port(client2_name, port2_name); + const ModuleType port2_type = (port1_type == Input) ? Output : Input; + + boost::shared_ptr<PatchageModule> client2_module + = _app->canvas()->find_module(client2_name, port2_type); + + boost::shared_ptr<Port> port1 = client1_module->get_port(port1_name); + boost::shared_ptr<Port> port2 = client2_module->get_port(port2_name); if (!port1 || !port2) continue; diff --git a/src/PatchageCanvas.cpp b/src/PatchageCanvas.cpp index c172a12..3c63503 100644 --- a/src/PatchageCanvas.cpp +++ b/src/PatchageCanvas.cpp @@ -40,19 +40,6 @@ PatchageCanvas::PatchageCanvas(Patchage* app, int width, int height) } -boost::shared_ptr<Item> -PatchageCanvas::get_item(const string& name) -{ - ItemList::iterator m = _items.begin(); - - for ( ; m != _items.end(); ++m) - if ((*m)->name() == name) - break; - - return (m == _items.end()) ? boost::shared_ptr<Item>() : *m; -} - - boost::shared_ptr<PatchageModule> PatchageCanvas::find_module(const string& name, ModuleType type) { @@ -199,22 +186,3 @@ PatchageCanvas::status_message(const string& msg) { _app->status_msg(string("[Canvas] ").append(msg)); } - - -boost::shared_ptr<Port> -PatchageCanvas::get_port(const string& node_name, const string& port_name) -{ - for (ItemList::iterator i = _items.begin(); i != _items.end(); ++i) { - const boost::shared_ptr<Item> item = *i; - const boost::shared_ptr<Module> module - = boost::dynamic_pointer_cast<Module>(item); - if (!module) - continue; - const boost::shared_ptr<Port> port = module->get_port(port_name); - if (module->name() == node_name && port) - return port; - } - - return boost::shared_ptr<Port>(); -} - diff --git a/src/PatchageCanvas.hpp b/src/PatchageCanvas.hpp index 66daf90..ef599ba 100644 --- a/src/PatchageCanvas.hpp +++ b/src/PatchageCanvas.hpp @@ -50,10 +50,6 @@ public: void status_message(const string& msg); - boost::shared_ptr<Item> get_item(const string& name); - boost::shared_ptr<Port> get_port(const string& module_name, - const string& port_name); - private: Patchage* _app; }; |