diff options
author | David Robillard <d@drobilla.net> | 2010-12-15 16:39:45 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-12-15 16:39:45 +0000 |
commit | aea13cac2a4106bbca28fc062d60e18ca4990c6c (patch) | |
tree | 62f56d61b9a6a4fc218e34efd8ad6bf526384785 /src/JackDriver.cpp | |
parent | 7d4e3fc0f17c72e94a1be2fae03d8a5b5af0ef7a (diff) | |
download | patchage-aea13cac2a4106bbca28fc062d60e18ca4990c6c.tar.gz patchage-aea13cac2a4106bbca28fc062d60e18ca4990c6c.tar.bz2 patchage-aea13cac2a4106bbca28fc062d60e18ca4990c6c.zip |
Improve JACK refresh performance significantly.
Remove (slow) PatchageCanvas::get_item and PatchageCanvas::get_port.
git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@2711 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/JackDriver.cpp')
-rw-r--r-- | src/JackDriver.cpp | 34 |
1 files changed, 22 insertions, 12 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; |