diff --git a/libs/ardour/ardour/graph.h b/libs/ardour/ardour/graph.h index 7517f898ee..2725c5372b 100644 --- a/libs/ardour/ardour/graph.h +++ b/libs/ardour/ardour/graph.h @@ -75,6 +75,7 @@ public: /* public API for use by session-process */ int process_routes (boost::shared_ptr chain, pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample, bool& need_butler); int routes_no_roll (boost::shared_ptr chain, pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample, bool non_rt_pending); + int silence_routes (boost::shared_ptr chain, pframes_t nframes); int process_io_plugs (boost::shared_ptr chain, pframes_t nframes, samplepos_t start_sample); bool in_process_thread () const; @@ -134,6 +135,10 @@ private: bool _process_can_record; bool _process_non_rt_pending; + enum ProcessMode { + Roll, NoRoll, Silence + } _process_mode; + bool _process_noroll; int _process_retval; bool _process_need_butler; diff --git a/libs/ardour/graph.cc b/libs/ardour/graph.cc index be02cb7c31..5e6ca79c71 100644 --- a/libs/ardour/graph.cc +++ b/libs/ardour/graph.cc @@ -441,7 +441,7 @@ Graph::process_routes (boost::shared_ptr chain, pframes_t nframes, s _process_start_sample = start_sample; _process_end_sample = end_sample; - _process_noroll = false; + _process_mode = Roll; _process_retval = 0; _process_need_butler = false; @@ -468,9 +468,8 @@ Graph::routes_no_roll (boost::shared_ptr chain, pframes_t nframes, s _process_nframes = nframes; _process_start_sample = start_sample; _process_end_sample = end_sample; - _process_non_rt_pending = non_rt_pending; - _process_noroll = true; + _process_mode = NoRoll; _process_retval = 0; _process_need_butler = false; @@ -482,6 +481,29 @@ Graph::routes_no_roll (boost::shared_ptr chain, pframes_t nframes, s return _process_retval; } +int +Graph::silence_routes (boost::shared_ptr chain, pframes_t nframes) +{ + DEBUG_TRACE (DEBUG::ProcessThreads, string_compose ("silence graph execution from %1 for = %2\n", nframes)); + + if (g_atomic_int_get (&_terminate)) { + return 0; + } + + _graph_chain = chain.get (); + _process_nframes = nframes; + _process_mode = Silence; + _process_retval = 0; + _process_need_butler = false; + + DEBUG_TRACE (DEBUG::ProcessThreads, "wake graph for silence process\n"); + _callback_start_sem.signal (); + _callback_done_sem.wait (); + DEBUG_TRACE (DEBUG::ProcessThreads, "graph execution complete\n"); + + return _process_retval; +} + int Graph::process_io_plugs (boost::shared_ptr chain, pframes_t nframes, samplepos_t start_sample) { @@ -513,10 +535,17 @@ Graph::process_one_route (Route* route) DEBUG_TRACE (DEBUG::ProcessThreads, string_compose ("%1 runs route %2\n", pthread_name (), route->name ())); - if (_process_noroll) { - retval = route->no_roll (_process_nframes, _process_start_sample, _process_end_sample, _process_non_rt_pending); - } else { - retval = route->roll (_process_nframes, _process_start_sample, _process_end_sample, need_butler); + switch (_process_mode) { + case Roll: + retval = route->roll (_process_nframes, _process_start_sample, _process_end_sample, need_butler); + break; + case NoRoll: + retval = route->no_roll (_process_nframes, _process_start_sample, _process_end_sample, _process_non_rt_pending); + break; + case Silence: + retval = 0; + route->silence (_process_nframes); + break; } if (retval) {