aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJörgen Scott <jorgen.scott@gmail.com>2015-02-09 12:42:00 +0100
committerJörgen Scott <jorgen.scott@gmail.com>2015-02-09 12:42:00 +0100
commit413aeff4088a1d5adadf07cb1833091a197dc393 (patch)
tree879b0df9a8f32a52d0f78a9ca05a1bb935f124f6 /src
parente8e7350db3bbf1d408ca4b305329c17d545c91eb (diff)
downloaddabmod-413aeff4088a1d5adadf07cb1833091a197dc393.tar.gz
dabmod-413aeff4088a1d5adadf07cb1833091a197dc393.tar.bz2
dabmod-413aeff4088a1d5adadf07cb1833091a197dc393.zip
added reset for static delay
Diffstat (limited to 'src')
-rw-r--r--src/OutputUHD.cpp25
1 files changed, 16 insertions, 9 deletions
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;