summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnuradio-core/src/lib/runtime/gr_buffer.cc7
-rw-r--r--gnuradio-core/src/lib/runtime/gr_buffer.h11
-rw-r--r--gnuradio-core/src/lib/runtime/gr_buffer.i2
-rw-r--r--gnuradio-core/src/lib/runtime/qa_gr_buffer.cc6
-rw-r--r--gnuradio-core/src/python/gnuradio/gr/flow_graph.py2
5 files changed, 17 insertions, 11 deletions
diff --git a/gnuradio-core/src/lib/runtime/gr_buffer.cc b/gnuradio-core/src/lib/runtime/gr_buffer.cc
index d3d123096..e06786880 100644
--- a/gnuradio-core/src/lib/runtime/gr_buffer.cc
+++ b/gnuradio-core/src/lib/runtime/gr_buffer.cc
@@ -179,11 +179,14 @@ gr_buffer::update_write_pointer (int nitems)
}
gr_buffer_reader_sptr
-gr_buffer_add_reader (gr_buffer_sptr buf, int history)
+gr_buffer_add_reader (gr_buffer_sptr buf, int nzero_preload)
{
+ if (nzero_preload < 0)
+ throw std::invalid_argument("gr_buffer_add_reader: nzero_preload must be >= 0");
+
gr_buffer_reader_sptr r (new gr_buffer_reader (buf,
buf->index_sub(buf->d_write_index,
- history-1)));
+ nzero_preload)));
buf->d_readers.push_back (r.get ());
return r;
diff --git a/gnuradio-core/src/lib/runtime/gr_buffer.h b/gnuradio-core/src/lib/runtime/gr_buffer.h
index 6f85f275e..e468f4358 100644
--- a/gnuradio-core/src/lib/runtime/gr_buffer.h
+++ b/gnuradio-core/src/lib/runtime/gr_buffer.h
@@ -73,7 +73,7 @@ class gr_buffer {
friend class gr_buffer_reader;
friend gr_buffer_sptr gr_make_buffer (int nitems, size_t sizeof_item);
- friend gr_buffer_reader_sptr gr_buffer_add_reader (gr_buffer_sptr buf, int history);
+ friend gr_buffer_reader_sptr gr_buffer_add_reader (gr_buffer_sptr buf, int nzero_preload);
protected:
char *d_base; // base address of buffer
@@ -129,8 +129,11 @@ class gr_buffer {
};
-//! create a new gr_buffer_reader and attach it to buffer \p buf
-gr_buffer_reader_sptr gr_buffer_add_reader (gr_buffer_sptr buf, int history);
+/*!
+ * \brief create a new gr_buffer_reader and attach it to buffer \p buf
+ * \param nzero_preload -- number of zero items to "preload" into buffer.
+ */
+gr_buffer_reader_sptr gr_buffer_add_reader (gr_buffer_sptr buf, int nzero_preload);
//! returns # of gr_buffers currently allocated
long gr_buffer_ncurrently_allocated ();
@@ -179,7 +182,7 @@ class gr_buffer_reader {
private:
friend class gr_buffer;
- friend gr_buffer_reader_sptr gr_buffer_add_reader (gr_buffer_sptr buf, int history);
+ friend gr_buffer_reader_sptr gr_buffer_add_reader (gr_buffer_sptr buf, int nzero_preload);
gr_buffer_sptr d_buffer;
diff --git a/gnuradio-core/src/lib/runtime/gr_buffer.i b/gnuradio-core/src/lib/runtime/gr_buffer.i
index 80f92ece1..2cb6deb95 100644
--- a/gnuradio-core/src/lib/runtime/gr_buffer.i
+++ b/gnuradio-core/src/lib/runtime/gr_buffer.i
@@ -43,7 +43,7 @@ typedef boost::shared_ptr<gr_buffer_reader> gr_buffer_reader_sptr;
%ignore gr_buffer_reader;
%rename(buffer_add_reader) gr_buffer_add_reader;
-gr_buffer_reader_sptr gr_buffer_add_reader (gr_buffer_sptr buf, int history);
+gr_buffer_reader_sptr gr_buffer_add_reader (gr_buffer_sptr buf, int nzero_preload);
class gr_buffer_reader {
public:
diff --git a/gnuradio-core/src/lib/runtime/qa_gr_buffer.cc b/gnuradio-core/src/lib/runtime/qa_gr_buffer.cc
index 5c549d0b9..5a3d4d3d7 100644
--- a/gnuradio-core/src/lib/runtime/qa_gr_buffer.cc
+++ b/gnuradio-core/src/lib/runtime/qa_gr_buffer.cc
@@ -88,7 +88,7 @@ t1_body ()
int read_counter = 0;
gr_buffer_sptr buf (gr_make_buffer (nitems, sizeof (int)));
- gr_buffer_reader_sptr r1 (gr_buffer_add_reader (buf, 1));
+ gr_buffer_reader_sptr r1 (gr_buffer_add_reader (buf, 0));
int sa;
@@ -163,7 +163,7 @@ t2_body ()
int nitems = (64 * (1L << 10)) / sizeof (int); // 64K worth of ints
gr_buffer_sptr buf (gr_make_buffer (nitems, sizeof (int)));
- gr_buffer_reader_sptr r1 (gr_buffer_add_reader (buf, 1));
+ gr_buffer_reader_sptr r1 (gr_buffer_add_reader (buf, 0));
int read_counter = 0;
int write_counter = 0;
@@ -237,7 +237,7 @@ t3_body ()
for (int i = 0; i < N; i++){
read_counter[i] = 0;
- reader[i] = gr_buffer_add_reader (buf, 1);
+ reader[i] = gr_buffer_add_reader (buf, 0);
}
for (int lc = 0; lc < 1000; lc++){
diff --git a/gnuradio-core/src/python/gnuradio/gr/flow_graph.py b/gnuradio-core/src/python/gnuradio/gr/flow_graph.py
index db9c58768..d309f60eb 100644
--- a/gnuradio-core/src/python/gnuradio/gr/flow_graph.py
+++ b/gnuradio-core/src/python/gnuradio/gr/flow_graph.py
@@ -151,7 +151,7 @@ class flow_graph (basic_flow_graph):
upstream_block = e.src.block
upstream_port = e.src.port
upstream_buffer = upstream_block.detail().output(upstream_port)
- d.set_input(our_port, buffer_add_reader(upstream_buffer, m.history()))
+ d.set_input(our_port, buffer_add_reader(upstream_buffer, m.history()-1))
def topological_sort (self, all_v):