From 8977d27c4a038ce640d1726d48a1f8fc597eb90b Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 9 Jan 2008 03:22:27 +0000 Subject: More patchage refresh performance improvements. git-svn-id: http://svn.drobilla.net/lad/patchage@1044 a436a847-0d15-0410-975c-d299462d15a1 --- src/AlsaDriver.cpp | 10 ++-------- src/JackDriver.cpp | 42 ++++++++++++++++++------------------------ 2 files changed, 20 insertions(+), 32 deletions(-) diff --git a/src/AlsaDriver.cpp b/src/AlsaDriver.cpp index 8047318..340d050 100644 --- a/src/AlsaDriver.cpp +++ b/src/AlsaDriver.cpp @@ -311,14 +311,8 @@ AlsaDriver::add_connections(boost::shared_ptr port) connected_port = _app->canvas()->find_port(*connected_addr, true); - if (connected_port) { - boost::shared_ptr existing = _app->canvas()->get_connection(port, connected_port); - if (existing) { - existing->set_flagged(false); - } else { - _app->canvas()->add_connection(port, connected_port, port->color() + 0x22222200); - } - } + if (connected_port && !port->is_connected_to(connected_port)) + _app->canvas()->add_connection(port, connected_port, port->color() + 0x22222200); snd_seq_query_subscribe_set_index(subsinfo, snd_seq_query_subscribe_get_index(subsinfo) + 1); } diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp index 7a3e66d..adf380c 100644 --- a/src/JackDriver.cpp +++ b/src/JackDriver.cpp @@ -222,8 +222,6 @@ JackDriver::refresh() client1_name = client1_name.substr(0, client1_name.find(":")); ModuleType type = InputOutput; - //if (_app->state_manager()->get_module_split(client1_name) - // || jack_port_flags(port) & JackPortIsTerminal) if (_app->state_manager()->get_module_split(client1_name, (jack_port_flags(port) & JackPortIsTerminal))) { if (jack_port_flags(port) & JackPortIsInput) { @@ -238,7 +236,6 @@ JackDriver::refresh() if (!m) { m = boost::shared_ptr(new PatchageModule(_app, client1_name, type)); m->load_location(); - m->store_location(); _app->canvas()->add_item(m); } @@ -263,20 +260,21 @@ JackDriver::refresh() } // Add all connections - if (ports) + if (ports) { + + _mutex.lock(); + + if (!_client) { + _mutex.unlock(); + shutdown(); + return; + } + for (int i=0; ports[i]; ++i) { - _mutex.lock(); - if (!_client) { - _mutex.unlock(); - shutdown(); - return; - } port = jack_port_by_name(_client, ports[i]); const char** connected_ports = jack_port_get_all_connections(_client, port); - - _mutex.unlock(); - + if (connected_ports) { for (int j=0; connected_ports[j]; ++j) { client1_name = ports[i]; @@ -301,26 +299,22 @@ JackDriver::refresh() if (port1->is_output() && port2->is_input()) { src = port1; dst = port2; - } else if (port2->is_output() && port1->is_input()) { + } else { src = port2; dst = port1; } - if (src && dst) { - boost::shared_ptr existing - = _app->canvas()->get_connection(src, dst); - - if (existing) { - existing->set_flagged(false); - } else { - _app->canvas()->add_connection(src, dst, port1->color() + 0x22222200); - } - } + if (src && dst && !src->is_connected_to(dst)) + _app->canvas()->add_connection(src, dst, port1->color() + 0x22222200); } free(connected_ports); } } + + _mutex.unlock(); + + } free(ports); } -- cgit v1.2.1