summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rondeau <tom@trondeau.com>2014-08-14 11:21:32 -0400
committerTom Rondeau <tom@trondeau.com>2014-08-14 11:21:32 -0400
commit3897c850322eb51f72ec4e55e2c35c7429c90337 (patch)
tree4fc7d8606447ee8b135e044710ebe4a6cad86a96
parentd10b68fd7d7194732d9eccb5edcf0e68ebdb8d6b (diff)
blocks: delay block cannot be initialized with a negative number.
This commit puts in a check in the constructor and better documentation about the behavior.
-rw-r--r--gr-blocks/include/gnuradio/blocks/delay.h14
-rw-r--r--gr-blocks/lib/delay_impl.cc3
2 files changed, 15 insertions, 2 deletions
diff --git a/gr-blocks/include/gnuradio/blocks/delay.h b/gr-blocks/include/gnuradio/blocks/delay.h
index fc90e22493..381669b7ed 100644
--- a/gr-blocks/include/gnuradio/blocks/delay.h
+++ b/gr-blocks/include/gnuradio/blocks/delay.h
@@ -35,6 +35,11 @@ namespace gr {
*
* Positive delays insert zero items at the beginning of the stream.
* Negative delays discard items from the stream.
+ *
+ * You cannot initialize this block with a negative delay,
+ * however. That leads to a causality issue with the buffers when
+ * they are initialized. If you need to negetively delay one path,
+ * then put the positive delay on the other path instead.
*/
class BLOCKS_API delay : virtual public block
{
@@ -45,11 +50,17 @@ namespace gr {
/*!
* \brief Make a delay block.
* \param itemsize size of the data items.
- * \param delay number of samples to delay stream.
+ * \param delay number of samples to delay stream (>= 0).
*/
static sptr make(size_t itemsize, int delay);
virtual int dly() const = 0;
+
+ /*!
+ * \brief Reset the delay.
+ * \param d change the delay value. This can be a positive or
+ * negative value.
+ */
virtual void set_dly(int d) = 0;
};
@@ -57,4 +68,3 @@ namespace gr {
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_DELAY_H */
-
diff --git a/gr-blocks/lib/delay_impl.cc b/gr-blocks/lib/delay_impl.cc
index 7ae4037780..0ebe124b09 100644
--- a/gr-blocks/lib/delay_impl.cc
+++ b/gr-blocks/lib/delay_impl.cc
@@ -44,6 +44,9 @@ namespace gr {
io_signature::make(1, -1, itemsize)),
d_itemsize(itemsize)
{
+ if(delay < 0) {
+ throw std::runtime_error("delay: Cannot initialize block with a delay < 0.");
+ }
set_dly(delay);
d_delta = 0;
}