Merge branch 'master' into windows+cc
[ardour.git] / libs / ardour / port_insert.cc
index 46c4d7e9d5e6a296c8fba44946a394d5e75ea3e9..2519451b8960f8cbda91d26c62ff8f3d8014d65d 100644 (file)
@@ -44,12 +44,12 @@ PortInsert::name_and_id_new_insert (Session& s, uint32_t& bitslot)
 }
 
 PortInsert::PortInsert (Session& s, boost::shared_ptr<Pannable> pannable, boost::shared_ptr<MuteMaster> mm)
-       : IOProcessor (s, true, true, name_and_id_new_insert (s, _bitslot), "")
+       : IOProcessor (s, true, true, name_and_id_new_insert (s, _bitslot), "", DataType::AUDIO, true)
        , _out (new Delivery (s, _output, pannable, mm, _name, Delivery::Insert))
 {
         _mtdm = 0;
         _latency_detect = false;
-        _latency_flush_frames = false;
+        _latency_flush_frames = 0;
         _measured_latency = 0;
 }
 
@@ -62,12 +62,9 @@ PortInsert::~PortInsert ()
 void
 PortInsert::start_latency_detection ()
 {
-        if (_mtdm != 0) {
-                delete _mtdm;
-        }
-
-        _mtdm = new MTDM;
-        _latency_flush_frames = false;
+       delete _mtdm;
+        _mtdm = new MTDM (_session.frame_rate());
+        _latency_flush_frames = 0;
         _latency_detect = true;
         _measured_latency = 0;
 }
@@ -75,7 +72,7 @@ PortInsert::start_latency_detection ()
 void
 PortInsert::stop_latency_detection ()
 {
-        _latency_flush_frames = signal_latency() + _session.engine().frames_per_cycle();
+        _latency_flush_frames = signal_latency() + _session.engine().samples_per_cycle();
         _latency_detect = false;
 }
 
@@ -96,7 +93,7 @@ PortInsert::latency() const
        */
 
        if (_measured_latency == 0) {
-               return _session.engine().frames_per_cycle() + _input->latency();
+               return _session.engine().samples_per_cycle() + _input->latency();
        } else {
                return _measured_latency;
        }
@@ -118,8 +115,9 @@ PortInsert::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame,
                         Sample* out = outbuf.data();
 
                         _mtdm->process (nframes, in, out);
-
+                       
                         outbuf.set_is_silent (false);
+                        outbuf.set_written (true);
                 }
 
                 return;
@@ -242,7 +240,7 @@ PortInsert::signal_latency() const
        */
 
         if (_measured_latency == 0) {
-                return _session.engine().frames_per_cycle() + _input->signal_latency();
+                return _session.engine().samples_per_cycle() + _input->signal_latency();
         } else {
                 return _measured_latency;
         }
@@ -252,7 +250,9 @@ PortInsert::signal_latency() const
 bool
 PortInsert::configure_io (ChanCount in, ChanCount out)
 {
+#ifndef PLATFORM_WINDOWS
        assert (!AudioEngine::instance()->process_lock().trylock());
+#endif
 
        /* for an insert, processor input corresponds to IO output, and vice versa */
 
@@ -268,7 +268,7 @@ PortInsert::configure_io (ChanCount in, ChanCount out)
 }
 
 bool
-PortInsert::can_support_io_configuration (const ChanCount& in, ChanCount& out) const
+PortInsert::can_support_io_configuration (const ChanCount& in, ChanCount& out)
 {
        out = in;
        return true;