diff options
author | Tom Rondeau | 2011-01-02 11:31:56 -0500 |
---|---|---|
committer | Tom Rondeau | 2011-01-02 11:36:15 -0500 |
commit | c11a431055c1e84ed16a6567cc9b2f3b821ad5e7 (patch) | |
tree | 2d844b5956cee2d279253937c0152d39029524ca /gnuradio-core | |
parent | 9c07c99147955574354d9d2a36c18f7aa8988130 (diff) | |
download | gnuradio-c11a431055c1e84ed16a6567cc9b2f3b821ad5e7.tar.gz gnuradio-c11a431055c1e84ed16a6567cc9b2f3b821ad5e7.tar.bz2 gnuradio-c11a431055c1e84ed16a6567cc9b2f3b821ad5e7.zip |
Buffers now hold on to all tags from both this window and the last window of items instead of just this window.
This protects against the rare times when one block is called twice before another block is, thereby pruning the tags before they can be passed downstream. The same thing will happen if a block is called 3 times in a row, which is highly unlikely.
Diffstat (limited to 'gnuradio-core')
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_buffer.cc | 9 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_buffer.h | 2 |
2 files changed, 6 insertions, 5 deletions
diff --git a/gnuradio-core/src/lib/runtime/gr_buffer.cc b/gnuradio-core/src/lib/runtime/gr_buffer.cc index 0b2eb52a0..0bff0271a 100644 --- a/gnuradio-core/src/lib/runtime/gr_buffer.cc +++ b/gnuradio-core/src/lib/runtime/gr_buffer.cc @@ -80,7 +80,8 @@ minimum_buffer_items (long type_size, long page_size) gr_buffer::gr_buffer (int nitems, size_t sizeof_item, gr_block_sptr link) : d_base (0), d_bufsize (0), d_vmcircbuf (0), d_sizeof_item (sizeof_item), d_link(link), - d_write_index (0), d_abs_write_offset(0), d_done (false) + d_write_index (0), d_abs_write_offset(0), d_done (false), + d_last_min_items_read(0) { if (!allocate_buffer (nitems, sizeof_item)) throw std::bad_alloc (); @@ -162,7 +163,9 @@ gr_buffer::space_available () min_items_read = std::min(min_items_read, d_readers[i]->nitems_read()); } - prune_tags(min_items_read); + //prune_tags(min_items_read); + prune_tags(d_last_min_items_read); + d_last_min_items_read = min_items_read; // The -1 ensures that the case d_write_index == d_read_index is // unambiguous. It indicates that there is no data for the reader @@ -241,7 +244,6 @@ gr_buffer::prune_tags(uint64_t max_time) */ //gruel::scoped_lock guard(*mutex()); - int n = 0; uint64_t item_time; std::deque<pmt::pmt_t>::iterator itr = d_item_tags.begin(); @@ -249,7 +251,6 @@ gr_buffer::prune_tags(uint64_t max_time) item_time = pmt::pmt_to_uint64(pmt::pmt_tuple_ref(*itr, 0)); if(item_time < max_time) { d_item_tags.pop_front(); - n++; } itr++; } diff --git a/gnuradio-core/src/lib/runtime/gr_buffer.h b/gnuradio-core/src/lib/runtime/gr_buffer.h index fe0e7585d..aa26f1e09 100644 --- a/gnuradio-core/src/lib/runtime/gr_buffer.h +++ b/gnuradio-core/src/lib/runtime/gr_buffer.h @@ -135,7 +135,7 @@ class gr_buffer { uint64_t d_abs_write_offset; // num items written since the start bool d_done; std::deque<pmt::pmt_t> d_item_tags; - + uint64_t d_last_min_items_read; unsigned index_add (unsigned a, unsigned b) |