take down backend specific threads with backend
This commit is contained in:
@@ -89,7 +89,7 @@ protected:
|
|||||||
virtual void session_going_away ();
|
virtual void session_going_away ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
volatile bool _quit_threads;
|
volatile bool _threads_active;
|
||||||
|
|
||||||
void reset_thread_list ();
|
void reset_thread_list ();
|
||||||
void drop_threads ();
|
void drop_threads ();
|
||||||
@@ -136,6 +136,10 @@ private:
|
|||||||
bool _process_noroll;
|
bool _process_noroll;
|
||||||
int _process_retval;
|
int _process_retval;
|
||||||
bool _process_need_butler;
|
bool _process_need_butler;
|
||||||
|
|
||||||
|
// enginer / thread connection
|
||||||
|
PBD::ScopedConnectionList engine_connections;
|
||||||
|
void engine_stopped ();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ int alloc_allowed ()
|
|||||||
|
|
||||||
Graph::Graph (Session & session)
|
Graph::Graph (Session & session)
|
||||||
: SessionHandleRef (session)
|
: SessionHandleRef (session)
|
||||||
, _quit_threads (false)
|
, _threads_active (false)
|
||||||
, _execution_sem ("graph_execution", 0)
|
, _execution_sem ("graph_execution", 0)
|
||||||
, _callback_start_sem ("graph_start", 0)
|
, _callback_start_sem ("graph_start", 0)
|
||||||
, _callback_done_sem ("graph_done", 0)
|
, _callback_done_sem ("graph_done", 0)
|
||||||
@@ -71,9 +71,13 @@ Graph::Graph (Session & session)
|
|||||||
_current_chain = 0;
|
_current_chain = 0;
|
||||||
_pending_chain = 0;
|
_pending_chain = 0;
|
||||||
_setup_chain = 1;
|
_setup_chain = 1;
|
||||||
_quit_threads = false;
|
|
||||||
_graph_empty = true;
|
_graph_empty = true;
|
||||||
|
|
||||||
|
|
||||||
|
ARDOUR::AudioEngine::instance()->Running.connect_same_thread (engine_connections, boost::bind (&Graph::reset_thread_list, this));
|
||||||
|
ARDOUR::AudioEngine::instance()->Stopped.connect_same_thread (engine_connections, boost::bind (&Graph::engine_stopped, this));
|
||||||
|
ARDOUR::AudioEngine::instance()->Halted.connect_same_thread (engine_connections, boost::bind (&Graph::engine_stopped, this));
|
||||||
|
|
||||||
reset_thread_list ();
|
reset_thread_list ();
|
||||||
|
|
||||||
#ifdef DEBUG_RT_ALLOC
|
#ifdef DEBUG_RT_ALLOC
|
||||||
@@ -82,6 +86,14 @@ Graph::Graph (Session & session)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Graph::engine_stopped ()
|
||||||
|
{
|
||||||
|
if (AudioEngine::instance()->process_thread_count() != 0) {
|
||||||
|
drop_threads ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Set up threads for running the graph */
|
/** Set up threads for running the graph */
|
||||||
void
|
void
|
||||||
Graph::reset_thread_list ()
|
Graph::reset_thread_list ()
|
||||||
@@ -114,6 +126,7 @@ Graph::reset_thread_list ()
|
|||||||
throw failed_constructor ();
|
throw failed_constructor ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_threads_active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -132,7 +145,7 @@ Graph::session_going_away()
|
|||||||
void
|
void
|
||||||
Graph::drop_threads ()
|
Graph::drop_threads ()
|
||||||
{
|
{
|
||||||
_quit_threads = true;
|
_threads_active = false;
|
||||||
|
|
||||||
uint32_t thread_count = AudioEngine::instance()->process_thread_count ();
|
uint32_t thread_count = AudioEngine::instance()->process_thread_count ();
|
||||||
|
|
||||||
@@ -145,8 +158,6 @@ Graph::drop_threads ()
|
|||||||
AudioEngine::instance()->join_process_threads ();
|
AudioEngine::instance()->join_process_threads ();
|
||||||
|
|
||||||
_execution_tokens = 0;
|
_execution_tokens = 0;
|
||||||
|
|
||||||
_quit_threads = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -243,7 +254,7 @@ Graph::restart_cycle()
|
|||||||
/* Block until the a process callback triggers us */
|
/* Block until the a process callback triggers us */
|
||||||
_callback_start_sem.wait();
|
_callback_start_sem.wait();
|
||||||
|
|
||||||
if (_quit_threads) {
|
if (!_threads_active) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,7 +379,7 @@ Graph::run_one()
|
|||||||
pthread_mutex_unlock (&_trigger_mutex);
|
pthread_mutex_unlock (&_trigger_mutex);
|
||||||
DEBUG_TRACE (DEBUG::ProcessThreads, string_compose ("%1 goes to sleep\n", pthread_name()));
|
DEBUG_TRACE (DEBUG::ProcessThreads, string_compose ("%1 goes to sleep\n", pthread_name()));
|
||||||
_execution_sem.wait ();
|
_execution_sem.wait ();
|
||||||
if (_quit_threads) {
|
if (!_threads_active) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
DEBUG_TRACE (DEBUG::ProcessThreads, string_compose ("%1 is awake\n", pthread_name()));
|
DEBUG_TRACE (DEBUG::ProcessThreads, string_compose ("%1 is awake\n", pthread_name()));
|
||||||
@@ -421,13 +432,13 @@ Graph::main_thread()
|
|||||||
|
|
||||||
DEBUG_TRACE(DEBUG::ProcessThreads, "main thread is awake\n");
|
DEBUG_TRACE(DEBUG::ProcessThreads, "main thread is awake\n");
|
||||||
|
|
||||||
if (_quit_threads) {
|
if (!_threads_active) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
prep ();
|
prep ();
|
||||||
|
|
||||||
if (_graph_empty && !_quit_threads) {
|
if (_graph_empty && _threads_active) {
|
||||||
_callback_done_sem.signal ();
|
_callback_done_sem.signal ();
|
||||||
DEBUG_TRACE(DEBUG::ProcessThreads, "main thread sees graph done, goes back to sleep\n");
|
DEBUG_TRACE(DEBUG::ProcessThreads, "main thread sees graph done, goes back to sleep\n");
|
||||||
goto again;
|
goto again;
|
||||||
@@ -526,6 +537,8 @@ Graph::routes_no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end
|
|||||||
{
|
{
|
||||||
DEBUG_TRACE (DEBUG::ProcessThreads, string_compose ("no-roll graph execution from %1 to %2 = %3\n", start_frame, end_frame, nframes));
|
DEBUG_TRACE (DEBUG::ProcessThreads, string_compose ("no-roll graph execution from %1 to %2 = %3\n", start_frame, end_frame, nframes));
|
||||||
|
|
||||||
|
if (!_threads_active) return 0;
|
||||||
|
|
||||||
_process_nframes = nframes;
|
_process_nframes = nframes;
|
||||||
_process_start_frame = start_frame;
|
_process_start_frame = start_frame;
|
||||||
_process_end_frame = end_frame;
|
_process_end_frame = end_frame;
|
||||||
|
|||||||
Reference in New Issue
Block a user