diff options
author | Josh Blum | 2012-09-13 20:17:47 -0700 |
---|---|---|
committer | Josh Blum | 2012-09-13 20:17:47 -0700 |
commit | 714aca847ac7f2e66c79933a3b7cb26b081d304a (patch) | |
tree | f81bb9cb6c657471b7ac34481256bbb25e7a83e3 /lib | |
parent | 44991fcb2b1d3a24e1563382d722947cafe8471e (diff) | |
download | sandhi-714aca847ac7f2e66c79933a3b7cb26b081d304a.tar.gz sandhi-714aca847ac7f2e66c79933a3b7cb26b081d304a.tar.bz2 sandhi-714aca847ac7f2e66c79933a3b7cb26b081d304a.zip |
some more history tweaks and asserts
Diffstat (limited to 'lib')
-rw-r--r-- | lib/block.cpp | 6 | ||||
-rw-r--r-- | lib/gras_impl/input_buffer_queues.hpp | 10 |
2 files changed, 11 insertions, 5 deletions
diff --git a/lib/block.cpp b/lib/block.cpp index 7ffcbf3..bb55a3f 100644 --- a/lib/block.cpp +++ b/lib/block.cpp @@ -72,10 +72,8 @@ size_t Block::history(const size_t which_input) const return vector_get((*this)->input_history_items, which_input); } -void Block::set_history(const size_t history_, const size_t which_input) +void Block::set_history(const size_t history, const size_t which_input) { - //FIXME why is history - 1 (gnuradio loves this) - const size_t history = (history_ == 0)? 0 : history_-1; vector_set((*this)->input_history_items, history, which_input); } @@ -116,7 +114,7 @@ void Block::set_input_inline(const size_t which_input, const bool enb) bool Block::input_inline(const size_t which_input) const { - return (*this)->input_inline_enables[which_input]; + return vector_get((*this)->input_inline_enables, which_input); } void Block::set_fixed_rate(const bool fixed_rate) diff --git a/lib/gras_impl/input_buffer_queues.hpp b/lib/gras_impl/input_buffer_queues.hpp index 7c25e3b..8d00d85 100644 --- a/lib/gras_impl/input_buffer_queues.hpp +++ b/lib/gras_impl/input_buffer_queues.hpp @@ -159,8 +159,13 @@ inline void InputBufferQueues::init( //determine byte sizes for buffers and dealing with history _history_bytes[i] = input_item_sizes[i]*input_history_items[i]; + if (_history_bytes[i]) _history_bytes[i] -= input_item_sizes[i]; //crazy history-1 API + + //calculate the input multiple aka reserve size _reserve_bytes[i] = input_item_sizes[i]*input_multiple_items[i]; _multiple_bytes[i] = std::max(size_t(1), _reserve_bytes[i]); + + //post bytes are the desired buffer size to escape the edge case _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 @@ -195,6 +200,7 @@ inline SBuffer InputBufferQueues::front(const size_t i, bool &potential_inline) ASSERT(not _queues[i].empty()); ASSERT(this->ready(i)); __prepare(i); + ASSERT(_queues[i].front().offset >= _history_bytes[i]); SBuffer &front = _queues[i].front(); const bool unique = front.unique(); @@ -278,7 +284,8 @@ 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]) + //otherwise, see if this is a mini history buff we can pop + else 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(); @@ -287,6 +294,7 @@ inline bool InputBufferQueues::consume(const size_t i, const size_t bytes_consum ASSERT(_queues[i].front().offset > residual); _queues[i].front().offset -= residual; _queues[i].front().length += residual; + ASSERT(_queues[i].front().offset >= _history_bytes[i]); } //update the number of bytes in this queue |