diff options
author | Josh Blum | 2012-09-13 19:03:59 -0700 |
---|---|---|
committer | Josh Blum | 2012-09-13 19:03:59 -0700 |
commit | 1ec3451161fbbd772490b8b1c7dd3d3c7aad9503 (patch) | |
tree | 385dbecf7c228f9420e2dbb374772720546182f2 /lib/gras_impl/input_buffer_queues.hpp | |
parent | 87cd4fe7179a55f1ea34ea90744017c403838542 (diff) | |
download | sandhi-1ec3451161fbbd772490b8b1c7dd3d3c7aad9503.tar.gz sandhi-1ec3451161fbbd772490b8b1c7dd3d3c7aad9503.tar.bz2 sandhi-1ec3451161fbbd772490b8b1c7dd3d3c7aad9503.zip |
input buffer history work and fixes
added consume flag to know if user called consume
fixes for mini history buff and flag when in use
Diffstat (limited to 'lib/gras_impl/input_buffer_queues.hpp')
-rw-r--r-- | lib/gras_impl/input_buffer_queues.hpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/gras_impl/input_buffer_queues.hpp b/lib/gras_impl/input_buffer_queues.hpp index 2188509..7c25e3b 100644 --- a/lib/gras_impl/input_buffer_queues.hpp +++ b/lib/gras_impl/input_buffer_queues.hpp @@ -124,6 +124,7 @@ struct InputBufferQueues std::vector<size_t> _multiple_bytes; std::vector<size_t> _post_bytes; std::vector<boost::shared_ptr<BufferQueue> > _aux_queues; + std::vector<bool> _in_hist_buff; }; @@ -137,6 +138,7 @@ inline void InputBufferQueues::resize(const size_t size) _multiple_bytes.resize(size, 0); _post_bytes.resize(size, 0); _aux_queues.resize(size); + _in_hist_buff.resize(size, false); } @@ -161,6 +163,7 @@ inline void InputBufferQueues::init( _multiple_bytes[i] = std::max(size_t(1), _reserve_bytes[i]); _post_bytes[i] = input_item_sizes[i]*max_history_items; _post_bytes[i] = std::max(_post_bytes[i], _reserve_bytes[i]); + _post_bytes[i] += input_item_sizes[i]; //pad for round down issues //allocate mini buffers for history edge conditions size_t num_bytes = _history_bytes[i] + _post_bytes[i]; @@ -179,6 +182,7 @@ inline void InputBufferQueues::init( buff.length = 0; _queues[i].push_front(buff); + _in_hist_buff[i] = true; } } } @@ -233,6 +237,7 @@ inline void InputBufferQueues::__prepare(const size_t i) hist_bytes = _history_bytes[i]; dst.offset = hist_bytes; dst.length = 0; + _in_hist_buff[i] = true; } SBuffer src = _queues[i].front(); @@ -263,9 +268,6 @@ inline bool InputBufferQueues::consume(const size_t i, const size_t bytes_consum //assert that we dont consume past the bounds of the buffer ASSERT(_queues[i].front().length >= bytes_consumed); - //this is an optimization - const bool minibuff = (_history_bytes[i] != 0) and (_queues[i].front().offset == _history_bytes[i]) and (bytes_consumed == _post_bytes[i]); - //update bounds on the current buffer _queues[i].front().offset += bytes_consumed; _queues[i].front().length -= bytes_consumed; @@ -276,12 +278,23 @@ inline bool InputBufferQueues::consume(const size_t i, const size_t bytes_consum _queues[i].pop_front(); } + if (_in_hist_buff[i] and _queues[i].front().offset >= 2*_history_bytes[i]) + { + const size_t residual = _queues[i].front().length; + _queues[i].pop_front(); + _in_hist_buff[i] = false; + ASSERT(not _queues[i].empty()); + ASSERT(_queues[i].front().offset > residual); + _queues[i].front().offset -= residual; + _queues[i].front().length += residual; + } + //update the number of bytes in this queue ASSERT(_enqueued_bytes[i] >= bytes_consumed); _enqueued_bytes[i] -= bytes_consumed; __update(i); - return not minibuff; //not true on minibuff + return not _in_hist_buff[i]; } } //namespace gnuradio |