X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fardour%2Faudio_buffer.h;h=829288a7afd0a1096c6fc1a613e212952c81eef3;hb=70b939da4f9d4097160e32f2373a7a5ff8f4957f;hp=9a41e8e093f82ceb6de9dab2cd9aab6e05727421;hpb=ee62ee07d39f51ba1b70f390dc2158c57f54a572;p=ardour.git diff --git a/libs/ardour/ardour/audio_buffer.h b/libs/ardour/ardour/audio_buffer.h index 9a41e8e093..829288a7af 100644 --- a/libs/ardour/ardour/audio_buffer.h +++ b/libs/ardour/ardour/audio_buffer.h @@ -68,9 +68,14 @@ public: /** Accumulate (add) @a len frames FROM THE START OF @a src into self at @a offset * scaling by @a gain_coeff */ void accumulate_with_gain_from(const AudioBuffer& src, nframes_t len, nframes_t offset, gain_t gain_coeff) { + assert(_capacity > 0); assert(offset + len <= _capacity); + if (src.silent()) { + return; + } + Sample* const dst_raw = _data + offset; const Sample* const src_raw = src.data(); @@ -82,6 +87,7 @@ public: /** Accumulate (add) @a len frames FROM THE START OF @a src into self at @a offset * scaling by @a gain_coeff */ void accumulate_with_gain_from(const Sample* src_raw, nframes_t len, nframes_t offset, gain_t gain_coeff) { + assert(_capacity > 0); assert(offset + len <= _capacity); @@ -123,7 +129,22 @@ public: Sample* data (nframes_t nframes, nframes_t offset) { assert(offset + nframes <= _capacity); return _data + offset; } -private: + void replace_data (size_t nframes); + + void drop_data () { + assert (_owns_data); + assert (_data); + + free (_data); + _data = 0; + _size = 0; + _capacity = 0; + _silent = false; + } + + void copy_to_internal (Sample* p, nframes_t cnt, nframes_t offset); + + private: bool _owns_data; Sample* _data; ///< Actual buffer contents };