13
0

centralize buffer silent-flag

fixes possible x-talk 1 in, >= 2 out tracks:

Previously, only the first route-buffer of the input buffers
were marked as non-silent in Route::process_output_buffers().
Other buffers in the set (e.g. post-panner) would
contain audio but not marked as non-silent.
This commit is contained in:
Robin Gareus 2013-12-28 13:43:44 +01:00
parent 8f69af4af3
commit 37264c85a5
5 changed files with 19 additions and 18 deletions

View File

@ -33,17 +33,7 @@ public:
AudioBuffer(size_t capacity);
~AudioBuffer();
void silence (framecnt_t len, framecnt_t offset = 0) {
if (!_silent) {
assert(_capacity > 0);
assert(offset + len <= _capacity);
memset(_data + offset, 0, sizeof (Sample) * len);
if (len == _capacity) {
_silent = true;
}
}
_written = true;
}
void silence (framecnt_t len, framecnt_t offset = 0);
/** Read @a len frames @a src starting at @a src_offset into self starting at @ dst_offset*/
void read_from (const Sample* src, framecnt_t len, framecnt_t dst_offset = 0, framecnt_t src_offset = 0) {
@ -204,10 +194,11 @@ public:
Sample* data (framecnt_t offset = 0) {
assert(offset <= _capacity);
_silent = false;
return _data + offset;
}
bool check_silence (pframes_t, pframes_t&) const;
bool check_silence (pframes_t, bool, pframes_t&) const;
void prepare () { _written = false; _silent = false; }
bool written() const { return _written; }

View File

@ -76,12 +76,26 @@ AudioBuffer::resize (size_t size)
}
bool
AudioBuffer::check_silence (pframes_t nframes, pframes_t& n) const
AudioBuffer::check_silence (pframes_t nframes, bool wholebuffer, pframes_t& n) const
{
for (n = 0; n < _size && n < nframes; ++n) {
for (n = 0; (wholebuffer || n < _size) && n < nframes; ++n) {
if (_data[n] != Sample (0)) {
return false;
}
}
return true;
}
void
AudioBuffer::silence (framecnt_t len, framecnt_t offset) {
pframes_t n = 0;
if (!_silent) {
assert(_capacity > 0);
assert(offset + len <= _capacity);
memset(_data + offset, 0, sizeof (Sample) * len);
if (len == _capacity) {
_silent = true;
}
}
_written = true;
}

View File

@ -505,7 +505,6 @@ PluginInsert::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end
* all buffers appropriately.
*/
bufs.set_is_silent (false);
}
void

View File

@ -116,7 +116,6 @@ PortInsert::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame,
_mtdm->process (nframes, in, out);
outbuf.set_is_silent (false);
outbuf.set_written (true);
}

View File

@ -419,8 +419,6 @@ Route::process_output_buffers (BufferSet& bufs,
framepos_t start_frame, framepos_t end_frame, pframes_t nframes,
int declick, bool gain_automation_ok)
{
bufs.set_is_silent (false);
/* figure out if we're going to use gain automation */
if (gain_automation_ok) {
_amp->set_gain_automation_buffer (_session.gain_automation_buffer ());