Consolidate delivery buffer flushing of all route types
authorJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>
Thu, 14 Jul 2016 23:43:14 +0000 (01:43 +0200)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 15 Jul 2016 01:55:49 +0000 (21:55 -0400)
Route::no_roll(), Route::roll(), Track::no_roll(), AudioTrack::roll()
and MidiTrack::roll() all had the exact same loop for flushing buffers
of their Delivery processors. That was a lot of replicated code that had
to be kept synchronised by hand. Put that code into a protected method
Route::flush_processor_buffers_locked() which is called instead.

libs/ardour/ardour/route.h
libs/ardour/audio_track.cc
libs/ardour/midi_track.cc
libs/ardour/route.cc
libs/ardour/track.cc

index bef1a54569ab18755e269ef8b275b8acc656288e..f415e9725c87b847ccca09f4adb569011d62c58b 100644 (file)
@@ -588,6 +588,8 @@ public:
                                             pframes_t nframes, int declick,
                                             bool gain_automation_ok);
 
+       void flush_processor_buffers_locked (framecnt_t nframes);
+
        virtual void bounce_process (BufferSet& bufs,
                                     framepos_t start_frame, framecnt_t nframes,
                                                                                                                         boost::shared_ptr<Processor> endpoint, bool include_endpoint,
index 8f83c19161ca6d843dcbb6b5cfa61872e532dceb..3a653a0efe675096b4d9d8e225c84451975f2061 100644 (file)
@@ -394,12 +394,7 @@ AudioTrack::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_fram
 
        process_output_buffers (bufs, start_frame, end_frame, nframes, declick, (!diskstream->record_enabled() && _session.transport_rolling()));
 
-       for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
-               boost::shared_ptr<Delivery> d = boost::dynamic_pointer_cast<Delivery> (*i);
-               if (d) {
-                       d->flush_buffers (nframes);
-               }
-       }
+       flush_processor_buffers_locked (nframes);
 
        need_butler = diskstream->commit (playback_distance);
 
index c96254eeb20bae7f90fb0987efbe904cf5da1939..b79a1cf52cd6b56f85e7d20650ae45b596dff29a 100644 (file)
@@ -444,12 +444,7 @@ MidiTrack::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame
        process_output_buffers (bufs, start_frame, end_frame, nframes,
                                declick, (!diskstream->record_enabled() && !_session.transport_stopped()));
 
-       for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
-               boost::shared_ptr<Delivery> d = boost::dynamic_pointer_cast<Delivery> (*i);
-               if (d) {
-                       d->flush_buffers (nframes);
-               }
-       }
+       flush_processor_buffers_locked (nframes);
 
        need_butler = diskstream->commit (playback_distance);
 
index 01580456e4ca0cdf92cbfb0f9dd90cdcc9493346..cd670df02e1a759dfb63c1ee6bbcace179cb4edd 100644 (file)
@@ -3391,6 +3391,17 @@ Route::pans_required () const
        return max (n_inputs ().n_audio(), processor_max_streams.n_audio());
 }
 
+void
+Route::flush_processor_buffers_locked (framecnt_t nframes)
+{
+       for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
+               boost::shared_ptr<Delivery> d = boost::dynamic_pointer_cast<Delivery> (*i);
+               if (d) {
+                       d->flush_buffers (nframes);
+               }
+       }
+}
+
 int
 Route::no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, bool session_state_changing)
 {
@@ -3436,12 +3447,8 @@ Route::no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
        _trim->apply_gain_automation (false);
        passthru (bufs, start_frame, end_frame, nframes, 0);
 
-       for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
-               boost::shared_ptr<Delivery> d = boost::dynamic_pointer_cast<Delivery> (*i);
-               if (d) {
-                       d->flush_buffers (nframes);
-               }
-       }
+       flush_processor_buffers_locked (nframes);
+
        return 0;
 }
 
@@ -3480,12 +3487,8 @@ Route::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, in
 
        passthru (bufs, start_frame, end_frame, nframes, declick);
 
-       for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
-               boost::shared_ptr<Delivery> d = boost::dynamic_pointer_cast<Delivery> (*i);
-               if (d) {
-                       d->flush_buffers (nframes);
-               }
-       }
+       flush_processor_buffers_locked (nframes);
+
        return 0;
 }
 
index 71eabc5b2845ac8ed20d4e1f726bde3dd4b50ede..7b81397e04fcb0f092c1c94e2e38a9221951ceaa 100644 (file)
@@ -466,12 +466,7 @@ Track::no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
                passthru (bufs, start_frame, end_frame, nframes, false);
        }
 
-       for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
-               boost::shared_ptr<Delivery> d = boost::dynamic_pointer_cast<Delivery> (*i);
-               if (d) {
-                       d->flush_buffers (nframes);
-               }
-       }
+       flush_processor_buffers_locked (nframes);
 
        return 0;
 }