diff options
author | Tom Rondeau | 2012-02-17 11:39:59 -0500 |
---|---|---|
committer | Tom Rondeau | 2012-02-17 11:39:59 -0500 |
commit | 114cd4ae4b544cde983c7d7bd47cdd354877afde (patch) | |
tree | 5e93f26684810dc5496280babf8b60d71e56fead /gnuradio-core/src/lib/general/gr_delay.cc | |
parent | 2eee2b14349c1c36b79131fe327d9040eca6d140 (diff) | |
download | gnuradio-114cd4ae4b544cde983c7d7bd47cdd354877afde.tar.gz gnuradio-114cd4ae4b544cde983c7d7bd47cdd354877afde.tar.bz2 gnuradio-114cd4ae4b544cde983c7d7bd47cdd354877afde.zip |
core: in delay block, protect against repeated calls to set_delay with the same value.
Diffstat (limited to 'gnuradio-core/src/lib/general/gr_delay.cc')
-rw-r--r-- | gnuradio-core/src/lib/general/gr_delay.cc | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/gnuradio-core/src/lib/general/gr_delay.cc b/gnuradio-core/src/lib/general/gr_delay.cc index cf868b37b..30c9a235d 100644 --- a/gnuradio-core/src/lib/general/gr_delay.cc +++ b/gnuradio-core/src/lib/general/gr_delay.cc @@ -55,11 +55,16 @@ gr_delay::forecast (int noutput_items, gr_vector_int &ninput_items_required) void gr_delay::set_delay (int d) -{ - gruel::scoped_lock l(d_mutex_delay); - int old = delay(); - set_history(d+1); - d_delta = delay() - old; +{ + // only set a new delta if there is a change in the delay; this + // protects from quickly-repeated calls to this function that would + // end with d_delta=0. + if(d != delay()) { + gruel::scoped_lock l(d_mutex_delay); + int old = delay(); + set_history(d+1); + d_delta = delay() - old; + } } int |