summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2020-05-13 18:52:07 -0600
committerPaul Davis <paul@linuxaudiosystems.com>2020-05-13 18:52:29 -0600
commit7660ea29d277212633c86e43a105355a04a4dc09 (patch)
tree14ca3ae923e97e021798eef966174a9efb304e7a /libs/ardour
parent7232ac2f671220f7f6a971727b02635b4b387582 (diff)
avoid off-by-one error when overwriting w/loop
Diffstat (limited to 'libs/ardour')
-rw-r--r--libs/ardour/disk_reader.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/libs/ardour/disk_reader.cc b/libs/ardour/disk_reader.cc
index 028fb24716..4ed24bcf4b 100644
--- a/libs/ardour/disk_reader.cc
+++ b/libs/ardour/disk_reader.cc
@@ -692,8 +692,16 @@ DiskReader::overwrite_existing_audio ()
chunk1_offset = overwrite_offset;
chunk1_cnt = min (c->front()->rbuf->bufsize() - overwrite_offset, to_overwrite);
+ /* note: because we are overwriting buffer contents but not moving the
+ * write/read pointers, we do actually want to fill all the way to the
+ * write pointer (the value given by PlaybackBuffer::overwritable_at().
+ *
+ * This differs from what happens during ::refill_audio() where we are
+ * careful not to allow the read pointer to catch the write pointer
+ * (that indicates an empty buffer)
+ */
+
if (chunk1_cnt == to_overwrite) {
- chunk1_cnt--;
chunk2_cnt = 0;
} else {
chunk2_cnt = to_overwrite - chunk1_cnt;