[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 04/04: blocks: delay block cannot be initia
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 04/04: blocks: delay block cannot be initialized with a negative number. |
Date: |
Thu, 14 Aug 2014 15:23:24 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
trondeau pushed a commit to branch maint
in repository gnuradio.
commit 3897c850322eb51f72ec4e55e2c35c7429c90337
Author: Tom Rondeau <address@hidden>
Date: Thu Aug 14 11:21:32 2014 -0400
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.
---
gr-blocks/include/gnuradio/blocks/delay.h | 14 ++++++++++++--
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 fc90e22..381669b 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 7ae4037..0ebe124 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;
}