Fix fade-out at quit.
authorRobin Gareus <robin@gareus.org>
Mon, 30 Oct 2017 16:27:13 +0000 (17:27 +0100)
committerRobin Gareus <robin@gareus.org>
Mon, 30 Oct 2017 16:27:13 +0000 (17:27 +0100)
libs/ardour/ardour/port_manager.h
libs/ardour/audioengine.cc
libs/ardour/port_manager.cc

index 743c006fbd2871d5ea705c94574e3d6e8c3631f9..e2a932e0d9b4b06c904522d9e7350b5b909013a8 100644 (file)
@@ -181,7 +181,6 @@ class LIBARDOUR_API PortManager
         */
        boost::shared_ptr<Ports> _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<std::string,MidiPortInformation> MidiPortInfo;
 
        mutable Glib::Threads::Mutex midi_port_info_mutex;
index 1c0fcbf1388d23398361bbbb643283b599fab6d5..23e525dd61ba4af9502b802ff17fdaaafa1e8c32 100644 (file)
@@ -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);
index eae165454323a4a39af5824beb0b0d73e6bba89a..2b038142f89d30db6f1f61f6750f3c00442866ea 100644 (file)
@@ -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<AudioPort> ap = boost::dynamic_pointer_cast<AudioPort> (i->second);
+                       boost::shared_ptr<AudioPort> ap = boost::dynamic_pointer_cast<AudioPort> (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&