summaryrefslogtreecommitdiff
path: root/libs/ardour/session.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2016-04-24 16:06:38 +0200
committerRobin Gareus <robin@gareus.org>2016-04-24 18:26:39 +0200
commit36a928f0aef42b3498e63ebfe0af6865887e1712 (patch)
tree9cb0062e388d95921cdf64462fc68e25ea7c2ff0 /libs/ardour/session.cc
parent2fabe64bbbaad5d142bd056943dd3d9fd080ff01 (diff)
we need the process lock after all..
Diffstat (limited to 'libs/ardour/session.cc')
-rw-r--r--libs/ardour/session.cc28
1 files changed, 17 insertions, 11 deletions
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index e9d85300b7..aba1c87460 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -6719,9 +6719,6 @@ Session::auto_connect (const AutoConnectRequest& ar)
return;
}
- //why would we need the process lock ??
- //Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
-
/* If both inputs and outputs are auto-connected to physical ports,
* use the max of input and output offsets to ensure auto-connected
* port numbers always match up (e.g. the first audio input and the
@@ -6853,18 +6850,27 @@ void
Session::auto_connect_thread_run ()
{
pthread_set_name (X_("autoconnect"));
- SessionEvent::create_per_thread_pool (X_("autoconnect"), 256);
- PBD::notify_event_loops_about_thread_creation (pthread_self(), X_("autoconnect"), 256);
+ SessionEvent::create_per_thread_pool (X_("autoconnect"), 1024);
+ PBD::notify_event_loops_about_thread_creation (pthread_self(), X_("autoconnect"), 1024);
pthread_mutex_lock (&_auto_connect_mutex);
while (_ac_thread_active) {
- while (!_auto_connect_queue.empty ()) {
+ if (!_auto_connect_queue.empty ()) {
+ // Why would we need the process lock ??
+ // A: if ports are added while we're connecting, the backend's iterator may be invalidated:
+ // graph_order_callback() -> resort_routes() -> direct_feeds_according_to_reality () -> backend::connected_to()
+ // All ardour-internal backends use a std::vector xxxAudioBackend::find_port()
+ // We have control over those, but what does jack do?
+ Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
+
Glib::Threads::Mutex::Lock lx (_auto_connect_queue_lock);
- if (_auto_connect_queue.empty ()) { break; } // re-check with lock
- const AutoConnectRequest ar (_auto_connect_queue.front());
- _auto_connect_queue.pop ();
- lx.release ();
- auto_connect (ar);
+ while (!_auto_connect_queue.empty ()) {
+ const AutoConnectRequest ar (_auto_connect_queue.front());
+ _auto_connect_queue.pop ();
+ lx.release ();
+ auto_connect (ar);
+ lx.acquire ();
+ }
}
pthread_cond_wait (&_auto_connect_cond, &_auto_connect_mutex);