diff options
-rw-r--r-- | gr-blocks/include/gnuradio/blocks/delay.h | 14 | ||||
-rw-r--r-- | gr-blocks/lib/delay_impl.cc | 3 |
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; } |