From 170c4ba4b39889073b2a3f129e77ca9b2f91bbf2 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Tue, 27 Mar 2012 14:14:03 -0400 Subject: 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. --- gnuradio-core/src/lib/runtime/gr_buffer.h | 3 +++ gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc | 23 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) (limited to 'gnuradio-core') 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 #include #include +#include #include #include @@ -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 -- cgit From c774e6efb5f715c5f8b5f20bd8dea0051da667fd Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Tue, 27 Mar 2012 22:04:44 -0400 Subject: doc: fix documentation for wavsink (thanks to John Coppens for point it out). --- gnuradio-core/src/lib/io/gr_wavfile_sink.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gnuradio-core') diff --git a/gnuradio-core/src/lib/io/gr_wavfile_sink.h b/gnuradio-core/src/lib/io/gr_wavfile_sink.h index 5fd3eaadc..348f789ae 100644 --- a/gnuradio-core/src/lib/io/gr_wavfile_sink.h +++ b/gnuradio-core/src/lib/io/gr_wavfile_sink.h @@ -44,10 +44,10 @@ gr_make_wavfile_sink (const char *filename, int bits_per_sample = 16); /*! - * \brief Read stream from a Microsoft PCM (.wav) file, output floats + * \brief Write stream to a Microsoft PCM (.wav) file. * - * Values are within [-1;1]. - * Check gr_make_wavfile_source() for extra info. + * Values must be floats within [-1;1]. + * Check gr_make_wavfile_sink() for extra info. * * \ingroup sink_blk */ -- cgit