set + store signal chain latency for all processors; DiskWriter sets its capture_offs...
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 23 Jun 2017 18:19:04 +0000 (14:19 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 18 Sep 2017 15:40:53 +0000 (11:40 -0400)
libs/ardour/ardour/disk_writer.h
libs/ardour/ardour/processor.h
libs/ardour/disk_writer.cc
libs/ardour/processor.cc
libs/ardour/route.cc

index 72882e86fb2a69bdf454eac4e6cbcfa3de292d2f..218d1fc1fab6311f130409291d40a1fef5f8f45d 100644 (file)
@@ -90,7 +90,6 @@ class LIBARDOUR_API DiskWriter : public DiskIOProcessor
        PBD::Signal0<void> AlignmentStyleChanged;
 
        void set_input_latency (framecnt_t);
-       framecnt_t input_latency () const { return _input_latency; }
 
        bool configure_io (ChanCount in, ChanCount out);
 
@@ -170,7 +169,6 @@ class LIBARDOUR_API DiskWriter : public DiskIOProcessor
        CaptureInfos capture_info;
 
   private:
-       framecnt_t   _input_latency;
        gint         _record_enabled;
        gint         _record_safe;
        framepos_t    capture_start_frame;
index 1898b6cb60e7430ecdf6fdd23a3ae8523d02e08a..095ab7fadf8c7321fa9276c6e38a1ad17f977a56 100644 (file)
@@ -70,6 +70,9 @@ class LIBARDOUR_API Processor : public SessionObject, public Automatable, public
 
        virtual framecnt_t signal_latency() const { return 0; }
 
+       virtual void set_input_latency (framecnt_t);
+       framecnt_t input_latency () const { return _input_latency; }
+
        virtual int set_block_size (pframes_t /*nframes*/) { return 0; }
        virtual bool requires_fixed_sized_buffers() const { return false; }
 
@@ -149,6 +152,7 @@ protected:
        ProcessorWindowProxy *_window_proxy;
        PluginPinWindowProxy *_pinmgr_proxy;
        SessionObject* _owner;
+       framecnt_t _input_latency;
 };
 
 } // namespace ARDOUR
index 4eb4393861ef8eb6f3dd4587ac5c5cf0b570dd89..82f9324d5b53f5e4d12d664a8290980d434a8596 100644 (file)
@@ -45,7 +45,6 @@ PBD::Signal0<void> DiskWriter::Overrun;
 
 DiskWriter::DiskWriter (Session& s, string const & str, DiskIOProcessor::Flag f)
        : DiskIOProcessor (s, str, f)
-       , _input_latency (0)
        , _record_enabled (0)
        , _record_safe (0)
        , capture_start_frame (0)
@@ -292,7 +291,8 @@ DiskWriter::get_captured_frames (uint32_t n) const
 void
 DiskWriter::set_input_latency (framecnt_t l)
 {
-       _input_latency = l;
+       Processor::set_input_latency (l);
+       set_capture_offset ();
 }
 
 void
@@ -309,7 +309,7 @@ DiskWriter::set_capture_offset ()
                break;
        }
 
-        DEBUG_TRACE (DEBUG::CaptureAlignment, string_compose ("%1: using IO latency, capture offset set to %2 with style = %3\n", name(), _capture_offset, enum_2_string (_alignment_style)));
+       DEBUG_TRACE (DEBUG::CaptureAlignment, string_compose ("%1: using input latency %4, capture offset set to %2 with style = %3\n", name(), _capture_offset, enum_2_string (_alignment_style), _input_latency));
 }
 
 
@@ -322,7 +322,6 @@ DiskWriter::set_align_style (AlignStyle a, bool force)
 
        if ((a != _alignment_style) || force) {
                _alignment_style = a;
-               cerr << name() << " using align style " << enum_2_string (_alignment_style) << endl;
                set_capture_offset ();
                AlignmentStyleChanged ();
        }
index 23e55f91ae431d5d41351f9d0e4e10d5a4bbd28c..335bb0f019c6a12a4822bcf5c64bc0ef18fe7041 100644 (file)
@@ -68,6 +68,7 @@ Processor::Processor(Session& session, const string& name)
        , _window_proxy (0)
        , _pinmgr_proxy (0)
        , _owner (0)
+       , _input_latency (0)
 {
 }
 
@@ -86,6 +87,7 @@ Processor::Processor (const Processor& other)
        , _window_proxy (0)
        , _pinmgr_proxy (0)
        , _owner (0)
+       , _input_latency (0)
 {
 }
 
@@ -288,3 +290,10 @@ Processor::owner() const
 {
        return _owner;
 }
+
+void
+Processor::set_input_latency (framecnt_t cnt)
+{
+       _input_latency = cnt;
+}
+
index 352d36a2c5b9c34acfffc2282c6caa4a9e43b582..b7a57fd3f1e7a2c6dd679b9100c6ba3f64988c8b 100644 (file)
@@ -1806,6 +1806,8 @@ Route::configure_processors_unlocked (ProcessorStreams* err, Glib::Threads::RWLo
        // TODO check for a potential ReaderLock after ReaderLock ??
        Glib::Threads::RWLock::ReaderLock lr (_processor_lock);
 
+       framecnt_t chain_latency = _input->latency ();
+
        list< pair<ChanCount,ChanCount> >::iterator c = configuration.begin();
        for (ProcessorList::iterator p = _processors.begin(); p != _processors.end(); ++p, ++c) {
 
@@ -1816,6 +1818,10 @@ Route::configure_processors_unlocked (ProcessorStreams* err, Glib::Threads::RWLo
                        lm->acquire ();
                        return -1;
                }
+
+               (*p)->set_input_latency (chain_latency);
+               chain_latency += (*p)->signal_latency ();
+
                processor_max_streams = ChanCount::max(processor_max_streams, c->first);
                processor_max_streams = ChanCount::max(processor_max_streams, c->second);