summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rondeau2012-03-27 14:14:03 -0400
committerTom Rondeau2012-03-27 22:02:47 -0400
commit170c4ba4b39889073b2a3f129e77ca9b2f91bbf2 (patch)
treee149b5fcef24d7abe3181109d9ca5bce7ab8f732
parentd346cb287299a04a71ea21007025edb694409043 (diff)
downloadgnuradio-170c4ba4b39889073b2a3f129e77ca9b2f91bbf2.tar.gz
gnuradio-170c4ba4b39889073b2a3f129e77ca9b2f91bbf2.tar.bz2
gnuradio-170c4ba4b39889073b2a3f129e77ca9b2f91bbf2.zip
core: when reseting buffers, make sure that the read/write pointers are always algined.
This fixes problems when disconnecting and reconnecting blocks to a flowgraph.
-rw-r--r--gnuradio-core/src/lib/runtime/gr_buffer.h3
-rw-r--r--gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc23
2 files changed, 26 insertions, 0 deletions
diff --git a/gnuradio-core/src/lib/runtime/gr_buffer.h b/gnuradio-core/src/lib/runtime/gr_buffer.h
index e8e393756..9478e1ce0 100644
--- a/gnuradio-core/src/lib/runtime/gr_buffer.h
+++ b/gnuradio-core/src/lib/runtime/gr_buffer.h
@@ -93,6 +93,7 @@ class GR_CORE_API gr_buffer {
uint64_t nitems_written() { return d_abs_write_offset; }
+ size_t get_sizeof_item() { return d_sizeof_item; }
/*!
* \brief Adds a new tag to the buffer.
@@ -249,6 +250,8 @@ class GR_CORE_API gr_buffer_reader {
uint64_t nitems_read() { return d_abs_read_offset; }
+ size_t get_sizeof_item() { return d_buffer->get_sizeof_item(); }
+
/*!
* \brief Return the block that reads via this reader.
*
diff --git a/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc b/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc
index 5d1057e0f..e97fa13a4 100644
--- a/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc
+++ b/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc
@@ -28,6 +28,7 @@
#include <gr_block_detail.h>
#include <gr_io_signature.h>
#include <gr_buffer.h>
+#include <volk/volk.h>
#include <iostream>
#include <map>
@@ -243,6 +244,28 @@ gr_flat_flowgraph::merge_connections(gr_flat_flowgraph_sptr old_ffg)
if (GR_FLAT_FLOWGRAPH_DEBUG)
std::cout << "new block" << std::endl;
connect_block_inputs(block);
+
+ const int alignment = volk_get_alignment();
+ for(int i = 0; i < block->detail()->ninputs(); i++) {
+ void *r = (void*)block->detail()->input(i)->read_pointer();
+ unsigned long int ri = (unsigned long int)r % alignment;
+ if(ri != 0) {
+ size_t itemsize = block->detail()->input(i)->get_sizeof_item();
+ block->detail()->input(i)->update_read_pointer(ri/itemsize);
+ block->set_unaligned(0);
+ block->set_is_unaligned(false);
+ }
+ }
+ for(int i = 0; i < block->detail()->noutputs(); i++) {
+ void *w = (void*)block->detail()->output(i)->write_pointer();
+ unsigned long int wi = (unsigned long int)w % alignment;
+ if(wi != 0) {
+ size_t itemsize = block->detail()->output(i)->get_sizeof_item();
+ block->detail()->output(i)->update_write_pointer(wi/itemsize);
+ block->set_unaligned(0);
+ block->set_is_unaligned(false);
+ }
+ }
}
// Now deal with the fact that the block details might have changed numbers of