centralize buffer silent-flag
authorRobin Gareus <robin@gareus.org>
Sat, 28 Dec 2013 12:43:44 +0000 (13:43 +0100)
committerRobin Gareus <robin@gareus.org>
Sat, 28 Dec 2013 12:43:44 +0000 (13:43 +0100)
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.

libs/ardour/ardour/audio_buffer.h
libs/ardour/audio_buffer.cc
libs/ardour/plugin_insert.cc
libs/ardour/port_insert.cc
libs/ardour/route.cc

index 054a1f7b453f7aed074c0ed38ee6a37494664033..c356ed82b9fd18490037efadf2fa0fdeb3a5210d 100644 (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; }
index a36ad81c2ae118d39195a9e874e92e6eb1b38f67..b4e2a55ac2e7d38452e4dda3a7517dbaf03880fa 100644 (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;
+}
index b191cf4890a8e2892d6ba29ee576e05693e90ba4..b3517531aa0a2ede287da6540e90bce32599571e 100644 (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
index 97fe082c815c0957ba1013591038ccda81f77643..c352e22e55a6c83ba98cd28c02bb0ff2713094bb 100644 (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);
                 }
 
index 92a6544151b1816f12e20d1b1a8a7d7ed7a2fcc9..c032b77efff7612d5e278866ce243dd834d9c773 100644 (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 ());