From bd229936ec2cb30fe3360f2d83ffc7197fd6fb97 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 17 Sep 2019 18:26:03 -0600 Subject: add finite state machine to control/manage transport state --- libs/ardour/rt_tasklist.cc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'libs/ardour/rt_tasklist.cc') diff --git a/libs/ardour/rt_tasklist.cc b/libs/ardour/rt_tasklist.cc index a0671968bf..9dc9b635b4 100644 --- a/libs/ardour/rt_tasklist.cc +++ b/libs/ardour/rt_tasklist.cc @@ -51,8 +51,7 @@ RTTaskList::drop_threads () for (uint32_t i = 0; i < nt; ++i) { _task_run_sem.signal (); } - for (std::vector::const_iterator i = _threads.begin (); i != _threads.end (); ++i) - { + for (std::vector::const_iterator i = _threads.begin (); i != _threads.end (); ++i) { pthread_join (*i, NULL); } _threads.clear (); @@ -122,7 +121,7 @@ RTTaskList::run () boost::function to_run; tm.acquire (); - if (_tasklist.size () > 0) { + if (!_tasklist.empty ()) { to_run = _tasklist.front(); _tasklist.pop_front (); } @@ -145,20 +144,29 @@ void RTTaskList::process (TaskList const& tl) { Glib::Threads::Mutex::Lock pm (_process_mutex); + Glib::Threads::Mutex::Lock tm (_tasklist_mutex, Glib::Threads::NOT_LOCK); + + tm.acquire (); _tasklist = tl; + tm.release (); + process_tasklist (); + + tm.acquire (); _tasklist.clear (); + tm.release (); } void RTTaskList::process_tasklist () { - if (0 == g_atomic_int_get (&_threads_active) || _threads.size () == 0) { +// if (0 == g_atomic_int_get (&_threads_active) || _threads.size () == 0) { + for (TaskList::iterator i = _tasklist.begin (); i != _tasklist.end(); ++i) { (*i)(); } return; - } +// } uint32_t nt = std::min (_threads.size (), _tasklist.size ()); -- cgit v1.2.3