From 7660ea29d277212633c86e43a105355a04a4dc09 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 13 May 2020 18:52:07 -0600 Subject: avoid off-by-one error when overwriting w/loop --- libs/ardour/disk_reader.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'libs/ardour') 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; -- cgit v1.2.3