Fix off-by-one in body_range().
[ardour.git] / libs / ardour / session_transport.cc
index 843ae17e5fc6d913fa66317523d780e8eee01e24..5fef402d9fc9597a50f0691d1a1a9e62652da98c 100644 (file)
 
 */
 
-#include <cmath>
-#include <cerrno>
-#include <unistd.h>
-
 #ifdef WAF_BUILD
 #include "libardour-config.h"
 #endif
 
+#include <cmath>
+#include <cerrno>
+#include <unistd.h>
 
 #include "pbd/undo.h"
 #include "pbd/error.h"
@@ -36,7 +35,6 @@
 #include "midi++/port.h"
 #include "midi++/manager.h"
 
-#include "ardour/ardour.h"
 #include "ardour/audioengine.h"
 #include "ardour/auditioner.h"
 #include "ardour/butler.h"
@@ -465,7 +463,6 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished)
                auditioner->cancel_audition ();
        }
 
-       clear_clicks();
        cumulative_rf_motion = 0;
        reset_rf_scale (0);
 
@@ -582,13 +579,14 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished)
                        _requested_return_frame = -1;
 
                        if (do_locate) {
-                               clear_clicks ();
                                _engine.transport_locate (_transport_frame);
                        }
                }
 
        }
 
+       clear_clicks();
+
        /* do this before seeking, because otherwise the tracks will do the wrong thing in seamless loop mode.
        */
 
@@ -616,11 +614,13 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished)
 
        have_looped = false;
 
-       send_full_time_code (_transport_frame);
-
-       if (!dynamic_cast<MTC_Slave*>(_slave)) {
-               MIDI::Manager::instance()->mmc()->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdStop));
-               send_mmc_locate (_transport_frame);
+       if (!_engine.freewheeling()) {
+               send_full_time_code (_transport_frame);
+               
+               if (!dynamic_cast<MTC_Slave*>(_slave)) {
+                       MIDI::Manager::instance()->mmc()->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdStop));
+                       send_mmc_locate (_transport_frame);
+               }
        }
 
        if ((ptw & PostTransportLocate) && get_record_enabled()) {
@@ -1187,10 +1187,12 @@ Session::start_transport ()
                (*i)->automation_snapshot (_transport_frame, true);
        }
 
-       Timecode::Time time;
-       timecode_time_subframes (_transport_frame, time);
-       if (!dynamic_cast<MTC_Slave*>(_slave)) {
-               MIDI::Manager::instance()->mmc()->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdDeferredPlay));
+       if (!_engine.freewheeling()) {
+               Timecode::Time time;
+               timecode_time_subframes (_transport_frame, time);
+               if (!dynamic_cast<MTC_Slave*>(_slave)) {
+                       MIDI::Manager::instance()->mmc()->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdDeferredPlay));
+               }
        }
 
        TransportStateChange (); /* EMIT SIGNAL */
@@ -1551,9 +1553,11 @@ Session::maybe_stop (framepos_t limit)
 void
 Session::send_mmc_locate (framepos_t t)
 {
-       Timecode::Time time;
-       timecode_time_subframes (t, time);
-       MIDI::Manager::instance()->mmc()->send (MIDI::MachineControlCommand (time));
+       if (!_engine.freewheeling()) {
+               Timecode::Time time;
+               timecode_time_subframes (t, time);
+               MIDI::Manager::instance()->mmc()->send (MIDI::MachineControlCommand (time));
+       }
 }
 
 /** Ask the transport to not send timecode until further notice.  The suspension