From: Robin Gareus Date: Sat, 28 Dec 2013 12:43:44 +0000 (+0100) Subject: centralize buffer silent-flag X-Git-Tag: 3.5.308~158 X-Git-Url: https://main.carlh.net/gitweb/?p=ardour.git;a=commitdiff_plain;h=37264c85a509aca4a4ea71e8e2c5d32c81956879 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. --- diff --git a/libs/ardour/ardour/audio_buffer.h b/libs/ardour/ardour/audio_buffer.h index 054a1f7b45..c356ed82b9 100644 --- a/libs/ardour/ardour/audio_buffer.h +++ b/libs/ardour/ardour/audio_buffer.h @@ -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; } diff --git a/libs/ardour/audio_buffer.cc b/libs/ardour/audio_buffer.cc index a36ad81c2a..b4e2a55ac2 100644 --- a/libs/ardour/audio_buffer.cc +++ b/libs/ardour/audio_buffer.cc @@ -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; +} diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc index b191cf4890..b3517531aa 100644 --- a/libs/ardour/plugin_insert.cc +++ b/libs/ardour/plugin_insert.cc @@ -505,7 +505,6 @@ PluginInsert::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end * all buffers appropriately. */ - bufs.set_is_silent (false); } void diff --git a/libs/ardour/port_insert.cc b/libs/ardour/port_insert.cc index 97fe082c81..c352e22e55 100644 --- a/libs/ardour/port_insert.cc +++ b/libs/ardour/port_insert.cc @@ -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); } diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 92a6544151..c032b77eff 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -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 ());