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.
This commit is contained in:
@@ -123,6 +123,7 @@ protected:
|
|||||||
: DiskIOProcessor::ChannelInfo (buffer_size)
|
: DiskIOProcessor::ChannelInfo (buffer_size)
|
||||||
, pre_loop_buffer (0)
|
, pre_loop_buffer (0)
|
||||||
, pre_loop_buffer_size (0)
|
, pre_loop_buffer_size (0)
|
||||||
|
, initialized (false)
|
||||||
{
|
{
|
||||||
resize (buffer_size);
|
resize (buffer_size);
|
||||||
resize_preloop (preloop_size);
|
resize_preloop (preloop_size);
|
||||||
@@ -134,6 +135,7 @@ protected:
|
|||||||
|
|
||||||
Sample* pre_loop_buffer;
|
Sample* pre_loop_buffer;
|
||||||
samplecnt_t pre_loop_buffer_size;
|
samplecnt_t pre_loop_buffer_size;
|
||||||
|
bool initialized;
|
||||||
};
|
};
|
||||||
|
|
||||||
XMLNode& state ();
|
XMLNode& state ();
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ DiskReader::ReaderChannelInfo::resize (samplecnt_t bufsize)
|
|||||||
rbuf = new PlaybackBuffer<Sample> (bufsize);
|
rbuf = new PlaybackBuffer<Sample> (bufsize);
|
||||||
/* touch memory to lock it */
|
/* touch memory to lock it */
|
||||||
memset (rbuf->buffer (), 0, sizeof (Sample) * rbuf->bufsize ());
|
memset (rbuf->buffer (), 0, sizeof (Sample) * rbuf->bufsize ());
|
||||||
|
initialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -366,7 +367,7 @@ DiskReader::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
|
|||||||
const sampleoffset_t declick_offs = _declick_offs;
|
const sampleoffset_t declick_offs = _declick_offs;
|
||||||
|
|
||||||
for (n = 0, chan = c->begin (); chan != c->end (); ++chan, ++n) {
|
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& output (bufs.get_audio (n % n_buffers));
|
||||||
|
|
||||||
AudioBuffer& disk_buf ((ms & MonitoringInput) ? scratch_bufs.get_audio (n) : output);
|
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) {
|
if (!declick_out) {
|
||||||
const samplecnt_t available = chaninfo->rbuf->read (disk_buf.data (), disk_samples_to_consume);
|
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;
|
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));
|
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 ();
|
Underrun ();
|
||||||
@@ -673,6 +676,8 @@ DiskReader::overwrite_existing_audio ()
|
|||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rci->initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -1231,6 +1236,7 @@ DiskReader::refill_audio (Sample* sum_buffer, Sample* mixdown_buffer, float* gai
|
|||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
rci->initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zero_fill) {
|
if (zero_fill) {
|
||||||
|
|||||||
Reference in New Issue
Block a user