From 413aeff4088a1d5adadf07cb1833091a197dc393 Mon Sep 17 00:00:00 2001 From: Jörgen Scott Date: Mon, 9 Feb 2015 12:42:00 +0100 Subject: added reset for static delay --- src/OutputUHD.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/OutputUHD.cpp b/src/OutputUHD.cpp index 3845439..bfd24a8 100644 --- a/src/OutputUHD.cpp +++ b/src/OutputUHD.cpp @@ -269,7 +269,6 @@ void OutputUHD::SetDelayBuffer(unsigned int dabMode) default: throw std::runtime_error("OutPutUHD: invalid DAB mode"); } - fprintf(stderr, "DelayBuf = %d\n", myTFDurationMs * myConf.sampleRate / 1000); // The buffer size equals the number of samples per transmission frame so // we calculate it by multiplying the duration of the transmission frame // with the samplerate. @@ -687,15 +686,23 @@ void OutputUHD::set_parameter(const string& parameter, const string& value) ss >> myMuting; } else if (parameter == "staticdelay") { - int adjust; + int64_t adjust; ss >> adjust; - int newStaticDelayUs = myStaticDelayUs + adjust; - if (newStaticDelayUs > (myTFDurationMs * 1000)) - myStaticDelayUs = newStaticDelayUs - (myTFDurationMs * 1000); - else if (newStaticDelayUs < 0) - myStaticDelayUs = newStaticDelayUs + (myTFDurationMs * 1000); - else - myStaticDelayUs = newStaticDelayUs; + if (adjust > (myTFDurationMs * 1000)) + { // reset static delay for values outside range + myStaticDelayUs = 0; + } + else + { // the new adjust value is added to the existing delay and the result + // is wrapped around at TF duration + int newStaticDelayUs = myStaticDelayUs + adjust; + if (newStaticDelayUs > (myTFDurationMs * 1000)) + myStaticDelayUs = newStaticDelayUs - (myTFDurationMs * 1000); + else if (newStaticDelayUs < 0) + myStaticDelayUs = newStaticDelayUs + (myTFDurationMs * 1000); + else + myStaticDelayUs = newStaticDelayUs; + } } else if (parameter == "iqbalance") { ss >> myConf.frequency; -- cgit v1.2.3