summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-02-22 18:41:10 +0000
committerDavid Robillard <d@drobilla.net>2008-02-22 18:41:10 +0000
commitc253bafb7b5cfa510aaa6f7b5aa561bd42b007da (patch)
treedb0f1c86f9bc70fee025328c27c19276b82a241d
parent75b652d59639cf0171fe51a0c1442d03081f3b2f (diff)
downloadpatchage-c253bafb7b5cfa510aaa6f7b5aa561bd42b007da.tar.gz
patchage-c253bafb7b5cfa510aaa6f7b5aa561bd42b007da.tar.bz2
patchage-c253bafb7b5cfa510aaa6f7b5aa561bd42b007da.zip
Minor refresh/initial display speedups.
Show window immediately (i.e. don't wait for driving attaching). git-svn-id: http://svn.drobilla.net/lad/patchage@1153 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/JackDriver.cpp43
-rw-r--r--src/JackDriver.hpp2
-rw-r--r--src/Patchage.cpp56
-rw-r--r--src/Patchage.hpp1
-rw-r--r--src/main.cpp2
5 files changed, 47 insertions, 57 deletions
diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp
index 0586717..8fccde6 100644
--- a/src/JackDriver.cpp
+++ b/src/JackDriver.cpp
@@ -102,9 +102,9 @@ JackDriver::detach()
if (_client) {
jack_deactivate(_client);
jack_client_close(_client);
- _mutex.lock();
+ _shutdown_mutex.lock();
_client = NULL;
- _mutex.unlock();
+ _shutdown_mutex.unlock();
destroy_all_ports();
_is_activated = false;
signal_detached.emit();
@@ -225,17 +225,15 @@ JackDriver::refresh()
// Jack can take _client away from us at any time throughout here :/
// Shortest locks possible is the best solution I can figure out
- _mutex.lock();
+ _shutdown_mutex.lock();
if (_client == NULL) {
- _mutex.unlock();
+ _shutdown_mutex.unlock();
shutdown();
return;
}
ports = jack_get_ports(_client, NULL, NULL, 0); // get all existing ports
-
- _mutex.unlock();
string client1_name;
string port1_name;
@@ -245,14 +243,7 @@ JackDriver::refresh()
// Add all ports
if (ports)
for (int i=0; ports[i]; ++i) {
- _mutex.lock();
- if (!_client) {
- _mutex.unlock();
- shutdown();
- return;
- }
port = jack_port_by_name(_client, ports[i]);
- _mutex.unlock();
client1_name = ports[i];
client1_name = client1_name.substr(0, client1_name.find(":"));
@@ -298,14 +289,6 @@ JackDriver::refresh()
// Add all connections
if (ports) {
- _mutex.lock();
-
- if (!_client) {
- _mutex.unlock();
- shutdown();
- return;
- }
-
for (int i=0; ports[i]; ++i) {
port = jack_port_by_name(_client, ports[i]);
@@ -314,12 +297,14 @@ JackDriver::refresh()
if (connected_ports) {
for (int j=0; connected_ports[j]; ++j) {
client1_name = ports[i];
- port1_name = client1_name.substr(client1_name.find(':')+1);
- client1_name = client1_name.substr(0, client1_name.find(':'));
+ size_t colon = client1_name.find(':');
+ port1_name = client1_name.substr(colon+1);
+ client1_name = client1_name.substr(0, colon);
client2_name = connected_ports[j];
- port2_name = client2_name.substr(client2_name.find(':')+1);
- client2_name = client2_name.substr(0, client2_name.find(':'));
+ 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);
@@ -347,10 +332,10 @@ JackDriver::refresh()
free(connected_ports);
}
}
-
- _mutex.unlock();
}
+
+ _shutdown_mutex.unlock();
free(ports);
}
@@ -570,9 +555,9 @@ JackDriver::jack_shutdown_cb(void* jack_driver)
jack_reset_max_delayed_usecs(me->_client);
- me->_mutex.lock();
+ me->_shutdown_mutex.lock();
me->_client = NULL;
- me->_mutex.unlock();
+ me->_shutdown_mutex.unlock();
}
diff --git a/src/JackDriver.hpp b/src/JackDriver.hpp
index b22f13e..2b0e79b 100644
--- a/src/JackDriver.hpp
+++ b/src/JackDriver.hpp
@@ -115,7 +115,7 @@ private:
Patchage* _app;
jack_client_t* _client;
- Glib::Mutex _mutex;
+ Glib::Mutex _shutdown_mutex;
bool _is_activated;
jack_position_t _last_pos;
diff --git a/src/Patchage.cpp b/src/Patchage.cpp
index 165178b..b5e195e 100644
--- a/src/Patchage.cpp
+++ b/src/Patchage.cpp
@@ -94,6 +94,7 @@ Patchage::Patchage(int argc, char** argv)
#endif
, _jack_driver(NULL)
, _state_manager(NULL)
+ , _attach(true)
, _refresh(false)
, _enable_refresh(true)
, _jack_settings_dialog(NULL)
@@ -131,19 +132,6 @@ Patchage::Patchage(int argc, char** argv)
_state_manager = new StateManager();
_canvas = boost::shared_ptr<PatchageCanvas>(new PatchageCanvas(this, 1600*2, 1200*2));
- _jack_driver = new JackDriver(this);
- _jack_driver->signal_detached.connect(sigc::mem_fun(this, &Patchage::queue_refresh));
-
-#ifdef HAVE_ALSA
- _alsa_driver = new AlsaDriver(this);
-#endif
-
- _state_manager->load(_settings_filename);
-
-#ifdef HAVE_LASH
- _lash_driver = new LashDriver(this, argc, argv);
-#endif
-
while (argc > 0) {
if (!strcmp(*argv, "--help")) {
cout << "Usage: patchage [OPTIONS]\nOptions: --no-alsa" << endl;
@@ -239,16 +227,7 @@ Patchage::Patchage(int argc, char** argv)
_messages_win->signal_delete_event().connect(
sigc::mem_fun(this, &Patchage::on_messages_delete));
- connect_widgets();
- update_state();
-
_canvas->show();
- _main_win->present();
- _about_win->set_transient_for(*_main_win);
-
- // Idle callback, check if we need to refresh
- Glib::signal_timeout().connect(
- sigc::mem_fun(this, &Patchage::idle_callback), 100);
_main_win->resize(
static_cast<int>(_state_manager->get_window_size().x),
@@ -257,6 +236,29 @@ Patchage::Patchage(int argc, char** argv)
_main_win->move(
static_cast<int>(_state_manager->get_window_location().x),
static_cast<int>(_state_manager->get_window_location().y));
+
+ _main_win->present();
+ _about_win->set_transient_for(*_main_win);
+
+ _jack_driver = new JackDriver(this);
+ _jack_driver->signal_detached.connect(sigc::mem_fun(this, &Patchage::queue_refresh));
+
+#ifdef HAVE_ALSA
+ _alsa_driver = new AlsaDriver(this);
+#endif
+
+ _state_manager->load(_settings_filename);
+
+#ifdef HAVE_LASH
+ _lash_driver = new LashDriver(this, argc, argv);
+#endif
+
+ connect_widgets();
+ update_state();
+
+ // Idle callback, check if we need to refresh
+ Glib::signal_timeout().connect(
+ sigc::mem_fun(this, &Patchage::idle_callback), 100);
}
@@ -301,6 +303,12 @@ Patchage::attach()
bool
Patchage::idle_callback()
{
+ // Initial run, attach
+ if (_attach) {
+ attach();
+ _attach = false;
+ }
+
// Process any JACK events
if (_jack_driver) {
while (!_jack_driver->events().empty()) {
@@ -414,9 +422,7 @@ Patchage::refresh()
#endif
for (ItemList::iterator i = _canvas->items().begin(); i != _canvas->items().end(); ++i) {
- SharedPtr<Module> module = PtrCast<Module>(*i);
- if (module)
- module->resize();
+ (*i)->resize();
}
}
}
diff --git a/src/Patchage.hpp b/src/Patchage.hpp
index d50084e..c48fdd8 100644
--- a/src/Patchage.hpp
+++ b/src/Patchage.hpp
@@ -116,6 +116,7 @@ protected:
Gtk::Main* _gtk_main;
std::string _settings_filename;
+ bool _attach;
bool _refresh;
bool _enable_refresh;
bool _pane_closed;
diff --git a/src/main.cpp b/src/main.cpp
index ffc5761..6cf479c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -38,8 +38,6 @@ int main(int argc, char** argv)
Gtk::Main app(argc, argv);
Patchage patchage(argc, argv);
- patchage.attach();
-
app.run(*patchage.window());
} catch (std::exception& e) {