Fix MIDI selection/tool issues (issue #0002415 and other bugs).
[ardour.git] / libs / ardour / session_process.cc
index 44b63e08756bee087038e7777b382db7ddd2eb51..d6890b31ae3f34346b9ba8d2d58a6ffe72d34247 100644 (file)
@@ -52,6 +52,8 @@ Session::process (nframes_t nframes)
 {
        MIDI::Manager::instance()->cycle_start(nframes);
 
+       _silent = false;
+
        if (synced_to_jack() && waiting_to_start) {
                if ( _engine.transport_state() == AudioEngine::TransportRolling) {
                        actually_start_transport ();
@@ -266,10 +268,10 @@ Session::process_with_events (nframes_t nframes)
        nframes_t this_nframes;
        nframes_t end_frame;
        nframes_t offset;
+       bool session_needs_butler = false;
        nframes_t stop_limit;
        long           frames_moved;
-       bool           session_needs_butler = false;
-
+       
        /* make sure the auditioner is silent */
 
        if (auditioner) {
@@ -302,7 +304,7 @@ Session::process_with_events (nframes_t nframes)
        }
 
        if (!process_can_proceed()) {
-               no_roll (nframes, 0);
+               _silent = true;
                return;
        }
 
@@ -317,8 +319,8 @@ Session::process_with_events (nframes_t nframes)
                Event* this_event;
                Events::iterator the_next_one;
                
-               if (post_transport_work & (PostTransportLocate|PostTransportStop)) {
-                       no_roll (nframes, 0);
+               if (!process_can_proceed()) {
+                       _silent = true;
                        return;
                }
                
@@ -333,7 +335,9 @@ Session::process_with_events (nframes_t nframes)
                        return;
                }
        
-               send_midi_time_code_for_cycle(nframes);
+               if (!_exporting) {
+                       send_midi_time_code_for_cycle (nframes);
+               }
 
                if (actively_recording()) {
                        stop_limit = max_frames;
@@ -494,7 +498,7 @@ Session::follow_slave (nframes_t nframes, nframes_t offset)
             << endl;
 #endif 
 
-       if (Config->get_timecode_source_is_synced()) {
+       if (_slave->is_always_synced() || Config->get_timecode_source_is_synced()) {
 
                /* if the TC source is synced, then we assume that its 
                   speed is binary: 0.0 or 1.0
@@ -642,7 +646,7 @@ Session::follow_slave (nframes_t nframes, nframes_t offset)
                slave_state = Stopped;
        }
 
-       if (slave_state == Running && !Config->get_timecode_source_is_synced()) {
+       if (slave_state == Running && !_slave->is_always_synced() && !Config->get_timecode_source_is_synced()) {
 
 
                if (_transport_speed != 0.0f) {
@@ -743,67 +747,66 @@ Session::process_without_events (nframes_t nframes)
        long frames_moved;
        nframes_t offset = 0;
 
-       {
-               if (post_transport_work & (PostTransportLocate|PostTransportStop)) {
-                       no_roll (nframes, 0);
-                       return;
-               }
-
-               if (!_exporting && _slave) {
-                       if (!follow_slave (nframes, 0)) {
-                               return;
-                       }
-               } 
+       if (!process_can_proceed()) {
+               _silent = true;
+               return;
+       }
 
-               if (_transport_speed == 0) {
-                       no_roll (nframes, 0);
+       if (!_exporting && _slave) {
+               if (!follow_slave (nframes, 0)) {
                        return;
                }
-       
-               send_midi_time_code_for_cycle(nframes);
+       } 
+
+       if (_transport_speed == 0) {
+               no_roll (nframes, 0);
+               return;
+       }
                
-               if (actively_recording()) {
-                       stop_limit = max_frames;
+       if (!_exporting) {
+               send_midi_time_code_for_cycle (nframes);
+       }
+
+       if (actively_recording()) {
+               stop_limit = max_frames;
+       } else {
+               if (Config->get_stop_at_session_end()) {
+                       stop_limit = current_end_frame();
                } else {
-                       if (Config->get_stop_at_session_end()) {
-                               stop_limit = current_end_frame();
-                       } else {
-                               stop_limit = max_frames;
-                       }
+                       stop_limit = max_frames;
                }
+       }
                
-               if (maybe_stop (stop_limit)) {
-                       no_roll (nframes, 0);
-                       return;
-               
+       if (maybe_stop (stop_limit)) {
+               no_roll (nframes, 0);
+               return;
+       } 
 
-               if (maybe_sync_start (nframes, offset)) {
-                       return;
-               }
+       if (maybe_sync_start (nframes, offset)) {
+               return;
+       }
 
-               click (_transport_frame, nframes, offset);
+       click (_transport_frame, nframes, offset);
 
-               prepare_diskstreams ();
+       prepare_diskstreams ();
        
-               frames_moved = (long) floor (_transport_speed * nframes);
+       frames_moved = (long) floor (_transport_speed * nframes);
 
-               if (process_routes (nframes, offset)) {
-                       no_roll (nframes, offset);
-                       return;
-               }
-
-               commit_diskstreams (nframes, session_needs_butler);
+       if (process_routes (nframes, offset)) {
+               no_roll (nframes, offset);
+               return;
+       }
 
-               if (frames_moved < 0) {
-                       decrement_transport_position (-frames_moved);
-               } else {
-                       increment_transport_position (frames_moved);
-               }
+       commit_diskstreams (nframes, session_needs_butler);
 
-               maybe_stop (stop_limit);
-               check_declick_out ();
+       if (frames_moved < 0) {
+               decrement_transport_position (-frames_moved);
+       } else {
+               increment_transport_position (frames_moved);
+       }
 
-       } /* implicit release of route lock */
+       maybe_stop (stop_limit);
+       check_declick_out ();
 
        if (session_needs_butler)
                summon_butler ();