Merge branch 'master' into windows+cc
[ardour.git] / libs / ardour / midi_track.cc
index 51edd06aee2cfc5755da16ffaa6cad2625751d19..6a998de90e42b1c1565a3fbf938b4dcd03836ab6 100644 (file)
@@ -318,6 +318,12 @@ MidiTrack::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame
 {
        Glib::Threads::RWLock::ReaderLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
        if (!lm.locked()) {
+               boost::shared_ptr<MidiDiskstream> diskstream = midi_diskstream();
+               framecnt_t playback_distance = diskstream->calculate_playback_distance(nframes);
+               if (can_internal_playback_seek(llabs(playback_distance))) {
+                       /* TODO should declick, and/or note-off */
+                       internal_playback_seek(playback_distance);
+               }
                return 0;
        }
 
@@ -329,6 +335,9 @@ MidiTrack::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame
 
        if (!_active) {
                silence (nframes);
+               if (_meter_point == MeterInput && (_monitoring & MonitorInput || _diskstream->record_enabled())) {
+                       _meter->reset();
+               }
                return 0;
        }
 
@@ -349,11 +358,11 @@ MidiTrack::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame
                return dret;
        }
 
-       BufferSet& bufs = _session.get_scratch_buffers (n_process_buffers());
+       BufferSet& bufs = _session.get_route_buffers (n_process_buffers());
 
        fill_buffers_with_input (bufs, _input, nframes);
 
-       if (_meter_point == MeterInput) {
+       if (_meter_point == MeterInput && (_monitoring & MonitorInput || _diskstream->record_enabled())) {
                _meter->run (bufs, start_frame, end_frame, nframes, true);
        }
 
@@ -623,9 +632,9 @@ void
 MidiTrack::MidiControl::set_value(double val)
 {
        bool valid = false;
-       if (std::isinf(val)) {
+       if (isinf(val)) {
                cerr << "MIDIControl value is infinity" << endl;
-       } else if (std::isnan(val)) {
+       } else if (isnan(val)) {
                cerr << "MIDIControl value is NaN" << endl;
        } else if (val < _list->parameter().min()) {
                cerr << "MIDIControl value is < " << _list->parameter().min() << endl;