From 114cd4ae4b544cde983c7d7bd47cdd354877afde Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Fri, 17 Feb 2012 11:39:59 -0500 Subject: core: in delay block, protect against repeated calls to set_delay with the same value. --- gnuradio-core/src/lib/general/gr_delay.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'gnuradio-core') 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 -- cgit