diff options
author | Josh Blum | 2011-09-26 12:04:27 -0700 |
---|---|---|
committer | Josh Blum | 2011-09-26 12:04:27 -0700 |
commit | 1ff42298b8c5216587ecddcd3a3571def2e5fa21 (patch) | |
tree | f06d584ae6196e39829c17b5a9f6d728a03adfd1 /gnuradio-core/src/lib/general | |
parent | 4aa4411f2a3f184760ff5f534eec015f557f80c9 (diff) | |
parent | 18201a678610a608a4c952122ce6dc9430e8e2d1 (diff) | |
download | gnuradio-1ff42298b8c5216587ecddcd3a3571def2e5fa21.tar.gz gnuradio-1ff42298b8c5216587ecddcd3a3571def2e5fa21.tar.bz2 gnuradio-1ff42298b8c5216587ecddcd3a3571def2e5fa21.zip |
Merge branch 'next' of http://gnuradio.org/git/gnuradio into next
Diffstat (limited to 'gnuradio-core/src/lib/general')
-rw-r--r-- | gnuradio-core/src/lib/general/gr_keep_one_in_n.cc | 24 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_keep_one_in_n.h | 1 |
2 files changed, 24 insertions, 1 deletions
diff --git a/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc b/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc index 85495e277..8bccefa95 100644 --- a/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc +++ b/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc @@ -40,6 +40,12 @@ gr_keep_one_in_n::gr_keep_one_in_n (size_t item_size, int n) gr_make_io_signature (1, 1, item_size)), d_count(n) { + // To avoid bad behavior with using set_relative_rate in this block with + // VERY large values of n, we will keep track of things ourselves. Using + // this to turn off automatic tag propagation, which will be handled + // locally in general_work(). + set_tag_propagation_policy(TPP_DONT); + set_n(n); } @@ -52,7 +58,10 @@ gr_keep_one_in_n::set_n(int n) d_n = n; d_count = n; - set_relative_rate(1.0 / (float)n); + // keep our internal understanding of the relative rate of this block + // don't set the relative rate, though, and we will handle our own + // tag propagation. + d_decim_rate = 1.0/(float)d_n; } int @@ -80,6 +89,19 @@ gr_keep_one_in_n::general_work (int noutput_items, ni++; } + // Because we have set TPP_DONT, we have to propagate the tags here manually. + // Adjustment of the tag sample value is done using the float d_decim_rate. + std::vector<pmt::pmt_t> tags; + std::vector<pmt::pmt_t>::iterator t; + get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0)+ni); + for(t = tags.begin(); t != tags.end(); t++) { + uint64_t newcount = pmt::pmt_to_uint64(pmt::pmt_tuple_ref(*t, 0)); + add_item_tag(0, newcount * d_decim_rate, + pmt::pmt_tuple_ref(*t, 1), + pmt::pmt_tuple_ref(*t, 2), + pmt::pmt_tuple_ref(*t, 3)); + } + consume_each (ni); return no; } diff --git a/gnuradio-core/src/lib/general/gr_keep_one_in_n.h b/gnuradio-core/src/lib/general/gr_keep_one_in_n.h index f12a7a0f1..c32ed2a26 100644 --- a/gnuradio-core/src/lib/general/gr_keep_one_in_n.h +++ b/gnuradio-core/src/lib/general/gr_keep_one_in_n.h @@ -44,6 +44,7 @@ class GR_CORE_API gr_keep_one_in_n : public gr_block int d_n; int d_count; + float d_decim_rate; protected: gr_keep_one_in_n (size_t item_size, int n); |