diff options
author | Robin Gareus <robin@gareus.org> | 2020-04-08 01:08:57 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2020-04-08 01:09:40 +0200 |
commit | 648beb94a04b018411b6744859f17923fa65ec3d (patch) | |
tree | b70db3d02fde40e74533ffbf6a5049ac5ecd56e4 /libs/ardour | |
parent | e893c317010792c8e19220bc2b91adb68083ae5a (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')
-rw-r--r-- | libs/ardour/ardour/disk_reader.h | 2 | ||||
-rw-r--r-- | libs/ardour/disk_reader.cc | 10 |
2 files changed, 10 insertions, 2 deletions
diff --git a/libs/ardour/ardour/disk_reader.h b/libs/ardour/ardour/disk_reader.h index ffd4e2a875..2e1ab6aec6 100644 --- a/libs/ardour/ardour/disk_reader.h +++ b/libs/ardour/ardour/disk_reader.h @@ -123,6 +123,7 @@ protected: : DiskIOProcessor::ChannelInfo (buffer_size) , pre_loop_buffer (0) , pre_loop_buffer_size (0) + , initialized (false) { resize (buffer_size); resize_preloop (preloop_size); @@ -134,6 +135,7 @@ protected: Sample* pre_loop_buffer; samplecnt_t pre_loop_buffer_size; + bool initialized; }; XMLNode& state (); 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) { |