another notable cleanup/simplification of DiskReader's MIDI handling
authorPaul Davis <paul@linuxaudiosystems.com>
Sun, 3 Nov 2019 16:20:50 +0000 (09:20 -0700)
committerPaul Davis <paul@linuxaudiosystems.com>
Sun, 3 Nov 2019 16:20:50 +0000 (09:20 -0700)
Note that we resolve notes from the tracker directly into the output buffer. This happens
after an edit causes a buffer overwrite

libs/ardour/disk_reader.cc

index 3a051582d83d8df5bd1bb545efbec14d7afcc8cd..bb1717c8d7fe38ca53b5330cb321eb1e4dc58d2d 100644 (file)
@@ -251,14 +251,6 @@ DiskReader::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
        sampleoffset_t disk_samples_to_consume;
        MonitorState ms = _track->monitoring_state ();
 
-       if (run_must_resolve) {
-               boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> (_track);
-               if (mt) {
-                       resolve_tracker (mt->immediate_events(), 0);
-               }
-               run_must_resolve = false;
-       }
-
        if (_active) {
                if (!_pending_active) {
                        _active = false;
@@ -387,23 +379,25 @@ DiskReader::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
                }
        }
 
+  midi:
        /* MIDI data handling */
 
-  midi:
-       if (!declick_in_progress() && bufs.count().n_midi()) {
-               MidiBuffer* dst;
+       if (bufs.count().n_midi()) {
 
-               if (_no_disk_output) {
-                       dst = &scratch_bufs.get_midi(0);
-               } else {
-                       dst = &bufs.get_midi (0);
+               MidiBuffer& dst (bufs.get_midi (0));
+
+               if (run_must_resolve) {
+                       resolve_tracker (dst, 0);
+                       run_must_resolve = false;
                }
 
-               if ((ms & MonitoringDisk) && !still_locating && speed) {
-                       get_midi_playback (*dst, start_sample, end_sample, ms, scratch_bufs, speed, disk_samples_to_consume);
+               if (!_no_disk_output && !declick_in_progress() && (ms & MonitoringDisk) && !still_locating && speed) {
+                       get_midi_playback (dst, start_sample, end_sample, ms, scratch_bufs, speed, disk_samples_to_consume);
                }
        }
 
+       /* decide if we need the butler */
+
        if (!still_locating) {
 
                bool butler_required = false;