be sure to move effective_start while loop-reading MIDI
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 6 Nov 2019 16:03:55 +0000 (09:03 -0700)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 6 Nov 2019 16:03:55 +0000 (09:03 -0700)
libs/ardour/disk_reader.cc

index ae7bd59082cf2c168af0aea6a70b177a4b82d117..4bc931698b853e1aadc1c210f482863c7e884bab 100644 (file)
@@ -1112,11 +1112,15 @@ DiskReader::get_midi_playback (MidiBuffer& dst, samplepos_t start_sample, sample
 
                                        effective_start = loop_range.squish (effective_start);
                                        effective_end = min (effective_start + cnt, loc->end());
+                                       assert (effective_end > effective_start);
 
-                                       DEBUG_TRACE (DEBUG::MidiDiskIO, string_compose ("playback buffer LOOP read, from %1 to %2 (%3)\n", effective_start, effective_end, (effective_end - effective_start)));
+                                       const samplecnt_t this_read = effective_end - effective_start;
+
+                                       DEBUG_TRACE (DEBUG::MidiDiskIO, string_compose ("playback buffer LOOP read, from %1 to %2 (%3)\n", effective_start, effective_end, this_read));
 
                                        size_t events_read = rtmb->read (*target, effective_start, effective_end, _tracker);
-                                       cnt -= (effective_end - effective_start);
+                                       cnt -= this_read;
+                                       effective_start += this_read;
 
                                        DEBUG_TRACE (DEBUG::MidiDiskIO, string_compose ("%1 MDS events LOOP read %2 range %3 .. %4 cnt now %5\n", _name, events_read, effective_start, effective_end, cnt));