remove cruft - unused _size in audio-buffers
authorRobin Gareus <robin@gareus.org>
Mon, 3 Feb 2014 15:59:51 +0000 (16:59 +0100)
committerRobin Gareus <robin@gareus.org>
Mon, 3 Feb 2014 15:59:51 +0000 (16:59 +0100)
libs/ardour/ardour/audio_buffer.h
libs/ardour/ardour/buffer.h
libs/ardour/ardour/midi_buffer.h
libs/ardour/audio_buffer.cc

index c356ed82b9fd18490037efadf2fa0fdeb3a5210d..7752c614d5eee8807c8fdac7fe899794eb16dc51 100644 (file)
@@ -173,7 +173,6 @@ public:
        void set_data (Sample* data, size_t size) {
                assert(!_owns_data); // prevent leaks
                _capacity = size;
-               _size = size;
                _data = data;
                _silent = false;
                _written = false;
@@ -185,8 +184,6 @@ public:
         */
        void resize (size_t nframes);
 
-       bool empty() const { return _size == 0; }
-
        const Sample* data (framecnt_t offset = 0) const {
                assert(offset <= _capacity);
                return _data + offset;
@@ -198,7 +195,7 @@ public:
                return _data + offset;
        }
 
-       bool check_silence (pframes_t, bool, pframes_t&) const;
+       bool check_silence (pframes_t, pframes_t&) const;
 
        void prepare () { _written = false; _silent = false; }
        bool written() const { return _written; }
index 0d0f5d37584280544f39dc7cf0b32478668e5d31..87f7a90fc30a72ba6e3e55be93cf2bb14dabc70b 100644 (file)
@@ -46,16 +46,9 @@ public:
        /** Factory function */
        static Buffer* create(DataType type, size_t capacity);
 
-       /** Maximum capacity of buffer.
-        * Note in some cases the entire buffer may not contain valid data, use size. */
+       /** Maximum capacity of buffer. */
        size_t capacity() const { return _capacity; }
 
-       /** Amount of valid data in buffer.  Use this over capacity almost always. */
-       size_t size() const { return _size; }
-
-       /** Return true if the buffer contains no data, false otherwise */
-       virtual bool empty() const { return _size == 0; }
-
        /** Type of this buffer.
         * Based on this you can static cast a Buffer* to the desired type. */
        DataType type() const { return _type; }
@@ -80,12 +73,11 @@ public:
 
   protected:
        Buffer(DataType type)
-               : _type(type), _capacity(0), _size(0), _silent (true)
+               : _type(type), _capacity(0), _silent (true)
        {}
 
        DataType  _type;
        pframes_t _capacity;
-       pframes_t _size;
        bool      _silent;
 };
 
index 781396a598778fc6977e97c005e1840e4f2c17e5..c67eef178af850d2270e38652fcb832c4f9c7cc3 100644 (file)
@@ -48,6 +48,8 @@ public:
        uint8_t* reserve(TimeType time, size_t size);
 
        void resize(size_t);
+       size_t size() const { return _size; }
+       bool empty() const { return _size == 0; }
 
        bool merge_in_place(const MidiBuffer &other);
 
@@ -159,6 +161,7 @@ private:
        friend class iterator_base< const MidiBuffer, const Evoral::MIDIEvent<TimeType> >;
 
        uint8_t* _data; ///< timestamp, event, timestamp, event, ...
+       pframes_t _size;
 };
 
 
index aa4f64755aeb9399d31e402b8703eae2dd1a4d1d..de2c1ddf00b916701e889e9bae3f96ded2e9d807 100644 (file)
@@ -57,12 +57,6 @@ AudioBuffer::resize (size_t size)
 
        if (_data && size < _capacity) {
                /* buffer is already large enough */
-               
-               if (size < _size) {
-                       /* truncate */
-                       _size = size;
-               }
-
                return;
        }
 
@@ -71,14 +65,13 @@ AudioBuffer::resize (size_t size)
        cache_aligned_malloc ((void**) &_data, sizeof (Sample) * size);
 
        _capacity = size;
-       _size = 0;
        _silent = false;
 }
 
 bool
-AudioBuffer::check_silence (pframes_t nframes, bool wholebuffer, pframes_t& n) const
+AudioBuffer::check_silence (pframes_t nframes, pframes_t& n) const
 {
-       for (n = 0; (wholebuffer || n < _size) &&  n < nframes; ++n) {
+       for (n = 0; n < nframes; ++n) {
                if (_data[n] != Sample (0)) {
                        return false;
                }