diff options
author | David Robillard <d@drobilla.net> | 2009-05-12 19:15:07 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-05-12 19:15:07 +0000 |
commit | ddc09de45b45bdf2afdeff68eb8a17ad237ef6c3 (patch) | |
tree | d71c279860fb016e79be2fb7ea1ba3fa66e6babd /src/JackDriver.cpp | |
parent | 61e8765a7b9afda01eb52b5a240701849fd9e116 (diff) | |
download | patchage-ddc09de45b45bdf2afdeff68eb8a17ad237ef6c3.tar.gz patchage-ddc09de45b45bdf2afdeff68eb8a17ad237ef6c3.tar.bz2 patchage-ddc09de45b45bdf2afdeff68eb8a17ad237ef6c3.zip |
Fix threading issues on Jack exit.
git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@1988 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/JackDriver.cpp')
-rw-r--r-- | src/JackDriver.cpp | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp index 4077b1a..87ab1bf 100644 --- a/src/JackDriver.cpp +++ b/src/JackDriver.cpp @@ -99,14 +99,12 @@ JackDriver::attach(bool launch_daemon) void JackDriver::detach() { + Glib::Mutex::Lock lock(_shutdown_mutex); if (_client) { jack_deactivate(_client); jack_client_close(_client); - _shutdown_mutex.lock(); _client = NULL; - _shutdown_mutex.unlock(); } - destroy_all_ports(); _is_activated = false; signal_detached.emit(); _app->status_msg("[JACK] Detached"); @@ -116,7 +114,7 @@ JackDriver::detach() /** Destroy all JACK (canvas) ports. */ void -JackDriver::destroy_all_ports() +JackDriver::destroy_all() { ItemList modules = _app->canvas()->items(); // copy for (ItemList::iterator m = modules.begin(); m != modules.end(); ++m) { @@ -228,7 +226,6 @@ JackDriver::create_port(boost::shared_ptr<PatchageModule> parent, jack_port_t* p void JackDriver::shutdown() { - destroy_all_ports(); signal_detached.emit(); } @@ -245,10 +242,9 @@ 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 - _shutdown_mutex.lock(); + Glib::Mutex::Lock lock(_shutdown_mutex); if (_client == NULL) { - _shutdown_mutex.unlock(); shutdown(); return; } @@ -256,7 +252,6 @@ JackDriver::refresh() ports = jack_get_ports(_client, NULL, NULL, 0); // get all existing ports if (!ports) { - _shutdown_mutex.unlock(); return; } @@ -356,8 +351,6 @@ JackDriver::refresh() } } - _shutdown_mutex.unlock(); - free(ports); } @@ -535,10 +528,8 @@ JackDriver::jack_shutdown_cb(void* jack_driver) cerr << "[JACK] Shutdown" << endl; assert(jack_driver); JackDriver* me = reinterpret_cast<JackDriver*>(jack_driver); - me->_shutdown_mutex.lock(); + Glib::Mutex::Lock lock(me->_shutdown_mutex); me->_client = NULL; - me->_shutdown_mutex.unlock(); - me->destroy_all_ports(); me->_is_activated = false; me->signal_detached.emit(); } |