From c11a431055c1e84ed16a6567cc9b2f3b821ad5e7 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 2 Jan 2011 11:31:56 -0500 Subject: 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. --- gnuradio-core/src/lib/runtime/gr_buffer.cc | 9 +++++---- gnuradio-core/src/lib/runtime/gr_buffer.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'gnuradio-core/src/lib') 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::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 d_item_tags; - + uint64_t d_last_min_items_read; unsigned index_add (unsigned a, unsigned b) -- cgit