summaryrefslogtreecommitdiff
path: root/libs/ardour/graph.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2017-04-22 23:01:26 +0200
committerRobin Gareus <robin@gareus.org>2017-04-22 23:06:22 +0200
commit1e8462f45e67c954ce48a46e83c28cffe79b3c46 (patch)
tree867b3faed21331c13c3349897c800e63e37862f4 /libs/ardour/graph.cc
parent9c0ba3b3d53027f5c7c25341529562d41694ef2e (diff)
Reset process-graph semaphores on engine-restart
Diffstat (limited to 'libs/ardour/graph.cc')
-rw-r--r--libs/ardour/graph.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/libs/ardour/graph.cc b/libs/ardour/graph.cc
index 8f021a5695..7b3719605f 100644
--- a/libs/ardour/graph.cc
+++ b/libs/ardour/graph.cc
@@ -88,6 +88,9 @@ Graph::Graph (Session & session)
void
Graph::engine_stopped ()
{
+#ifndef NDEBUG
+ cerr << "Graph::engine_stopped. n_thread: " << AudioEngine::instance()->process_thread_count() << endl;
+#endif
if (AudioEngine::instance()->process_thread_count() != 0) {
drop_threads ();
}
@@ -162,7 +165,24 @@ Graph::drop_threads ()
AudioEngine::instance()->join_process_threads ();
+ /* signal main process thread if it's waiting for an already terminated thread */
+ _callback_done_sem.signal ();
_execution_tokens = 0;
+
+ /* reset semaphores.
+ * This is somewhat ugly, yet if a thread is killed (e.g jackd terminates
+ * abnormally), some semaphores are still unlocked.
+ */
+#ifndef NDEBUG
+ int d1 = _execution_sem.reset ();
+ int d2 = _callback_start_sem.reset ();
+ int d3 = _callback_done_sem.reset ();
+ cerr << "Graph::drop_threads() sema-counts: " << d1 << ", " << d2<< ", " << d3 << endl;
+#else
+ _execution_sem.reset ();
+ _callback_start_sem.reset ();
+ _callback_done_sem.reset ();
+#endif
}
void
@@ -438,6 +458,8 @@ again:
DEBUG_TRACE(DEBUG::ProcessThreads, "main thread is awake\n");
if (!_threads_active) {
+ pt->drop_buffers();
+ delete (pt);
return;
}