save/restore VCA master state inside slaves, so that a reloaded session ends up back...
[ardour.git] / libs / ardour / track.cc
index 7b81397e04fcb0f092c1c94e2e38a9221951ceaa..c84d9a1868499a88c225f125743d6d74e71170a4 100644 (file)
 #include "ardour/debug.h"
 #include "ardour/delivery.h"
 #include "ardour/diskstream.h"
+#include "ardour/event_type_map.h"
 #include "ardour/io_processor.h"
 #include "ardour/meter.h"
 #include "ardour/monitor_control.h"
 #include "ardour/playlist.h"
 #include "ardour/port.h"
 #include "ardour/processor.h"
+#include "ardour/profile.h"
 #include "ardour/record_enable_control.h"
 #include "ardour/record_safe_control.h"
 #include "ardour/route_group_specialized.h"
@@ -65,13 +67,13 @@ Track::init ()
        boost::shared_ptr<Route> rp (shared_from_this());
        boost::shared_ptr<Track> rt = boost::dynamic_pointer_cast<Track> (rp);
 
-       _record_enable_control.reset (new RecordEnableControl (_session, X_("recenable"), *this));
+       _record_enable_control.reset (new RecordEnableControl (_session, EventTypeMap::instance().to_symbol (RecEnableAutomation), *this));
        add_control (_record_enable_control);
 
-       _record_safe_control.reset (new RecordSafeControl (_session, X_("recsafe"), *this));
+       _record_safe_control.reset (new RecordSafeControl (_session, EventTypeMap::instance().to_symbol (RecSafeAutomation), *this));
        add_control (_record_safe_control);
 
-       _monitoring_control.reset (new MonitorControl (_session, X_("monitoring"), *this));
+       _monitoring_control.reset (new MonitorControl (_session, EventTypeMap::instance().to_symbol (MonitoringAutomation), *this));
        add_control (_monitoring_control);
 
        _session.config.ParameterChanged.connect_same_thread (*this, boost::bind (&Track::parameter_changed, this, _1));
@@ -105,6 +107,11 @@ XMLNode&
 Track::state (bool full)
 {
        XMLNode& root (Route::state (full));
+
+       root.add_child_nocopy (_monitoring_control->get_state ());
+       root.add_child_nocopy (_record_safe_control->get_state ());
+       root.add_child_nocopy (_record_enable_control->get_state ());
+
        root.add_property (X_("saved-meter-point"), enum_2_string (_saved_meter_point));
        root.add_child_nocopy (_diskstream->get_state ());
 
@@ -141,9 +148,18 @@ Track::set_state (const XMLNode& node, int version)
                child = *niter;
 
                XMLProperty const * prop;
-               if (child->name() == Controllable::xml_node_name && (prop = child->property ("name")) != 0) {
-                       if (prop->value() == X_("recenable")) {
+
+               if (child->name() == Controllable::xml_node_name) {
+                       if ((prop = child->property ("name")) == 0) {
+                               continue;
+                       }
+
+                       if (prop->value() == _record_enable_control->name()) {
                                _record_enable_control->set_state (*child, version);
+                       } else if (prop->value() == _record_safe_control->name()) {
+                               _record_safe_control->set_state (*child, version);
+                       } else if (prop->value() == _monitoring_control->name()) {
+                               _monitoring_control->set_state (*child, version);
                        }
                }
        }
@@ -351,7 +367,8 @@ Track::no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
 
        /* no outputs? nothing to do ... what happens if we have sends etc. ? */
 
-       if (n_outputs().n_total() == 0) {
+       if (n_outputs().n_total() == 0 && !ARDOUR::Profile->get_mixbus()) {
+               //Note: Mixbus has its own output mechanism, so we should operate even if no explicit outputs are assigned
                return 0;
        }
 
@@ -496,6 +513,7 @@ Track::silent_roll (pframes_t nframes, framepos_t /*start_frame*/, framepos_t /*
        _amp->apply_gain_automation(false);
 
        silence (nframes);
+       flush_processor_buffers_locked (nframes);
 
        framecnt_t playback_distance;
 
@@ -912,6 +930,17 @@ Track::monitoring_state () const
                return MonitoringDisk;
        }
 
+       switch (_session.config.get_session_monitoring ()) {
+               case MonitorDisk:
+                       return MonitoringDisk;
+                       break;
+               case MonitorInput:
+                       return MonitoringInput;
+                       break;
+               default:
+                       break;
+       }
+
        /* This is an implementation of the truth table in doc/monitor_modes.pdf;
           I don't think it's ever going to be too pretty too look at.
        */
@@ -927,9 +956,11 @@ Track::monitoring_state () const
         * time, but just to keep the semantics the same as they were before
         * sept 26th 2012, we differentiate between the cases where punch is
         * enabled and those where it is not.
+        *
+        * rg: I suspect this is not the case: monitoring may differ
         */
 
-       if (_session.config.get_punch_in() || _session.config.get_punch_out()) {
+       if (_session.config.get_punch_in() || _session.config.get_punch_out() || _session.preroll_record_punch_enabled ()) {
                session_rec = _session.actively_recording ();
        } else {
                session_rec = _session.get_record_enabled();