allow Lua session scripts to inject [immediate] RT-events
[ardour.git] / libs / ardour / track.cc
index 75cb689441efc2a8063bd5351ef87bf924f89f1b..7cdca70d3ba7941dd1a98920c12a0530f368132d 100644 (file)
@@ -27,6 +27,7 @@
 #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"
@@ -35,7 +36,7 @@
 #include "ardour/track.h"
 #include "ardour/utils.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace ARDOUR;
@@ -105,6 +106,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 +147,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 +366,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;
        }
 
@@ -444,10 +460,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);
                        }
                }
 
@@ -460,18 +476,13 @@ 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);
        }
 
-       for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
-               boost::shared_ptr<Delivery> d = boost::dynamic_pointer_cast<Delivery> (*i);
-               if (d) {
-                       d->flush_buffers (nframes);
-               }
-       }
+       flush_processor_buffers_locked (nframes);
 
        return 0;
 }
@@ -501,6 +512,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;