fix bypassing plugins with sidechain i/o
[ardour.git] / libs / ardour / track.cc
index 80169bf5a173661133510af7511cdf31fd3fb573..0c586e4a0e0603c4c5a3000d586a5d36233dc808 100644 (file)
@@ -28,6 +28,7 @@
 #include "ardour/port.h"
 #include "ardour/processor.h"
 #include "ardour/record_enable_control.h"
+#include "ardour/record_safe_control.h"
 #include "ardour/route_group_specialized.h"
 #include "ardour/session.h"
 #include "ardour/session_playlists.h"
@@ -40,7 +41,7 @@ using namespace std;
 using namespace ARDOUR;
 using namespace PBD;
 
-Track::Track (Session& sess, string name, Route::Flag flag, TrackMode mode, DataType default_type)
+Track::Track (Session& sess, string name, PresentationInfo::Flag flag, TrackMode mode, DataType default_type)
        : Route (sess, name, flag, default_type)
         , _saved_meter_point (_meter_point)
         , _mode (mode)
@@ -67,15 +68,12 @@ Track::init ()
        _record_enable_control.reset (new RecordEnableControl (_session, X_("recenable"), *this));
        add_control (_record_enable_control);
 
-       _record_safe_control.reset (new AutomationControl (_session, RecSafeAutomation, ParameterDescriptor (RecSafeAutomation),
-                                                          boost::shared_ptr<AutomationList> (new AutomationList (Evoral::Parameter (RecSafeAutomation))),
-                                                          X_("recsafe")));
+       _record_safe_control.reset (new RecordSafeControl (_session, X_("recsafe"), *this));
        add_control (_record_safe_control);
 
        _monitoring_control.reset (new MonitorControl (_session, X_("monitoring"), *this));
        add_control (_monitoring_control);
 
-       track_number_changed.connect_same_thread (*this, boost::bind (&Track::resync_track_name, this));
        _session.config.ParameterChanged.connect_same_thread (*this, boost::bind (&Track::parameter_changed, this, _1));
 
         _monitoring_control->Changed.connect_same_thread (*this, boost::bind (&Track::monitoring_changed, this, _1, _2));
@@ -242,27 +240,15 @@ Track::record_safe_changed (bool, Controllable::GroupControlDisposition)
 }
 
 bool
-Track::record_safe () const
+Track::can_be_record_safe ()
 {
-       return _diskstream && _diskstream->record_safe ();
+       return !_record_enable_control->get_value() && _diskstream && _session.writable() && (_freeze_record.state != Frozen);
 }
 
-void
-Track::set_record_safe (bool yn, Controllable::GroupControlDisposition group_override)
+bool
+Track::can_be_record_enabled ()
 {
-       if (!_session.writable()) {
-               return;
-       }
-
-       if (_freeze_record.state == Frozen) {
-               return;
-       }
-
-       if (record_enabled ()) {
-               return;
-       }
-
-       _rec_safe_control->set_value (yn, group_override);
+       return !_record_safe_control->get_value() && _diskstream && !_diskstream->record_safe() && _session.writable() && (_freeze_record.state != Frozen);
 }
 
 void
@@ -458,10 +444,10 @@ Track::no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
 
                        if (no_meter) {
                                BufferSet& bufs (_session.get_silent_buffers (n_process_buffers()));
-                               _meter->run (bufs, 0, 0, nframes, true);
-                               _input->process_input (boost::shared_ptr<Processor>(), start_frame, end_frame, nframes);
+                               _meter->run (bufs, start_frame, end_frame, 1.0, nframes, true);
+                               _input->process_input (boost::shared_ptr<Processor>(), start_frame, end_frame, speed(), nframes);
                        } else {
-                               _input->process_input (_meter, start_frame, end_frame, nframes);
+                               _input->process_input (_meter, start_frame, end_frame, speed(), nframes);
                        }
                }
 
@@ -474,7 +460,7 @@ Track::no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
                fill_buffers_with_input (bufs, _input, nframes);
 
                if (_meter_point == MeterInput) {
-                       _meter->run (bufs, start_frame, end_frame, nframes, true);
+                       _meter->run (bufs, start_frame, end_frame, 1.0 /*speed()*/, nframes, true);
                }
 
                passthru (bufs, start_frame, end_frame, nframes, false);