From b54db1cab79e25c39eccb4667bc7c44efb4ccb02 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 30 Oct 2017 17:27:13 +0100 Subject: [PATCH] Fix fade-out at quit. --- libs/ardour/ardour/port_manager.h | 3 ++- libs/ardour/audioengine.cc | 9 ++++----- libs/ardour/port_manager.cc | 23 +++++++++++++++++++---- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/libs/ardour/ardour/port_manager.h b/libs/ardour/ardour/port_manager.h index 743c006fbd..e2a932e0d9 100644 --- a/libs/ardour/ardour/port_manager.h +++ b/libs/ardour/ardour/port_manager.h @@ -181,7 +181,6 @@ class LIBARDOUR_API PortManager */ boost::shared_ptr _cycle_ports; - void fade_out (gain_t, gain_t, pframes_t); void silence (pframes_t nframes, Session *s = 0); void silence_outputs (pframes_t nframes); void check_monitoring (); @@ -198,6 +197,8 @@ class LIBARDOUR_API PortManager */ void cycle_end (pframes_t nframes, Session* s = 0); + void cycle_end_fade_out (gain_t, gain_t, pframes_t, Session* s = 0); + typedef std::map MidiPortInfo; mutable Glib::Threads::Mutex midi_port_info_mutex; diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc index 1c0fcbf138..23e525dd61 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -349,8 +349,7 @@ AudioEngine::process_callback (pframes_t nframes) if (_session == 0) { if (!_freewheeling) { - PortManager::cycle_start (nframes); - PortManager::cycle_end (nframes); + PortManager::silence_outputs (nframes); } _processed_samples = next_processed_samples; @@ -440,7 +439,7 @@ AudioEngine::process_callback (pframes_t nframes) if (session_remove_pending && session_removal_countdown) { - PortManager::fade_out (session_removal_gain, session_removal_gain_step, nframes); + PortManager::cycle_end_fade_out (session_removal_gain, session_removal_gain_step, nframes, _session); if (session_removal_countdown > nframes) { session_removal_countdown -= nframes; @@ -449,10 +448,10 @@ AudioEngine::process_callback (pframes_t nframes) } session_removal_gain -= (nframes * session_removal_gain_step); + } else { + PortManager::cycle_end (nframes, _session); } - PortManager::cycle_end (nframes, _session); - _processed_samples = next_processed_samples; PT_TIMING_CHECK (2); diff --git a/libs/ardour/port_manager.cc b/libs/ardour/port_manager.cc index eae1654543..2b038142f8 100644 --- a/libs/ardour/port_manager.cc +++ b/libs/ardour/port_manager.cc @@ -869,13 +869,26 @@ PortManager::check_monitoring () } void -PortManager::fade_out (gain_t base_gain, gain_t gain_step, pframes_t nframes) +PortManager::cycle_end_fade_out (gain_t base_gain, gain_t gain_step, pframes_t nframes, Session* s) { - for (Ports::iterator i = _cycle_ports->begin(); i != _cycle_ports->end(); ++i) { + if (s && s->rt_tasklist ()) { + RTTaskList::TaskList tl; + for (Ports::iterator p = _cycle_ports->begin(); p != _cycle_ports->end(); ++p) { + tl.push_back (boost::bind (&Port::cycle_end, p->second, nframes)); + } + s->rt_tasklist()->process (tl); + } else { + for (Ports::iterator p = _cycle_ports->begin(); p != _cycle_ports->end(); ++p) { + p->second->cycle_end (nframes); + } + } - if (i->second->sends_output()) { + for (Ports::iterator p = _cycle_ports->begin(); p != _cycle_ports->end(); ++p) { + p->second->flush_buffers (nframes); + + if (p->second->sends_output()) { - boost::shared_ptr ap = boost::dynamic_pointer_cast (i->second); + boost::shared_ptr ap = boost::dynamic_pointer_cast (p->second); if (ap) { Sample* s = ap->engine_get_whole_audio_buffer (); gain_t g = base_gain; @@ -887,6 +900,8 @@ PortManager::fade_out (gain_t base_gain, gain_t gain_step, pframes_t nframes) } } } + _cycle_ports.reset (); + /* we are done */ } PortEngine& -- 2.30.2