summaryrefslogtreecommitdiff
path: root/libs/ardour/disk_reader.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2020-04-08 01:08:57 +0200
committerRobin Gareus <robin@gareus.org>2020-04-08 01:09:40 +0200
commit648beb94a04b018411b6744859f17923fa65ec3d (patch)
treeb70db3d02fde40e74533ffbf6a5049ac5ecd56e4 /libs/ardour/disk_reader.cc
parente893c317010792c8e19220bc2b91adb68083ae5a (diff)
Fix false-positive under-run messages
Port (or Tracks) can be safely added during playback, however the disk-reader's playback buffer is initially empty. This lead to false-positive Underrun() signals when processing takes place before or concurrently with re-filling the disk-buffer for the new channels. Now new empty buffers are ignored, and produce silence until the initial refill is complete. There is however no per-channel de-click in, yet. This fixes: play some audio track, ctrl+drag a region to the drop-zone, creating a new track while playing.
Diffstat (limited to 'libs/ardour/disk_reader.cc')
-rw-r--r--libs/ardour/disk_reader.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/libs/ardour/disk_reader.cc b/libs/ardour/disk_reader.cc
index e08241fc9f..d47ccacc67 100644
--- a/libs/ardour/disk_reader.cc
+++ b/libs/ardour/disk_reader.cc
@@ -83,6 +83,7 @@ DiskReader::ReaderChannelInfo::resize (samplecnt_t bufsize)
rbuf = new PlaybackBuffer<Sample> (bufsize);
/* touch memory to lock it */
memset (rbuf->buffer (), 0, sizeof (Sample) * rbuf->bufsize ());
+ initialized = false;
}
void
@@ -366,7 +367,7 @@ DiskReader::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
const sampleoffset_t declick_offs = _declick_offs;
for (n = 0, chan = c->begin (); chan != c->end (); ++chan, ++n) {
- ChannelInfo* chaninfo (*chan);
+ ReaderChannelInfo* chaninfo = dynamic_cast<ReaderChannelInfo*> (*chan);
AudioBuffer& output (bufs.get_audio (n % n_buffers));
AudioBuffer& disk_buf ((ms & MonitoringInput) ? scratch_bufs.get_audio (n) : output);
@@ -391,7 +392,9 @@ DiskReader::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
if (!declick_out) {
const samplecnt_t available = chaninfo->rbuf->read (disk_buf.data (), disk_samples_to_consume);
- if (disk_samples_to_consume > available) {
+ if (available == 0 && !chaninfo->initialized) {
+ disk_buf.silence (disk_samples_to_consume);
+ } else if (disk_samples_to_consume > available) {
cerr << "underrun for " << _name << " Available samples: " << available << " required: " << disk_samples_to_consume << endl;
DEBUG_TRACE (DEBUG::Butler, string_compose ("%1 underrun in %2, total space = %3 vs %4\n", DEBUG_THREAD_SELF, name (), available, disk_samples_to_consume));
Underrun ();
@@ -673,6 +676,8 @@ DiskReader::overwrite_existing_audio ()
ret = false;
}
}
+
+ rci->initialized = true;
}
return ret;
@@ -1231,6 +1236,7 @@ DiskReader::refill_audio (Sample* sum_buffer, Sample* mixdown_buffer, float* gai
ret = -1;
}
}
+ rci->initialized = true;
}
if (zero_fill) {