use C++ for PortManager::make_port_name_relative()
[ardour.git] / libs / ardour / port_insert.cc
index 46c4d7e9d5e6a296c8fba44946a394d5e75ea3e9..46d54cd445aece3647e7c6fee65586575bf4dd1d 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;
 }
 
@@ -60,14 +60,18 @@ PortInsert::~PortInsert ()
 }
 
 void
-PortInsert::start_latency_detection ()
+PortInsert::set_pre_fader (bool p)
 {
-        if (_mtdm != 0) {
-                delete _mtdm;
-        }
+       Processor::set_pre_fader (p);
+       _out->set_pre_fader (p);
+}
 
-        _mtdm = new MTDM;
-        _latency_flush_frames = false;
+void
+PortInsert::start_latency_detection ()
+{
+       delete _mtdm;
+        _mtdm = new MTDM (_session.frame_rate());
+        _latency_flush_frames = 0;
         _latency_detect = true;
         _measured_latency = 0;
 }
@@ -75,7 +79,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 +100,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;
        }
@@ -119,7 +123,7 @@ PortInsert::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame,
 
                         _mtdm->process (nframes, in, out);
 
-                        outbuf.set_is_silent (false);
+                        outbuf.set_written (true);
                 }
 
                 return;
@@ -242,7 +246,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 +256,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 +274,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;