summaryrefslogtreecommitdiffstats
path: root/src/OutputUHD.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-05-01 06:22:25 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-05-01 06:22:25 +0200
commitaabba6c6b56edbd4f64913af33651a2f2a641976 (patch)
treeeb5e17f6e0f54eb482a1dcdc7a2d046704d77c1a /src/OutputUHD.cpp
parent1810a2c6a34207caedf5a88bc4e5d38080e764ed (diff)
downloaddabmod-aabba6c6b56edbd4f64913af33651a2f2a641976.tar.gz
dabmod-aabba6c6b56edbd4f64913af33651a2f2a641976.tar.bz2
dabmod-aabba6c6b56edbd4f64913af33651a2f2a641976.zip
Ensure buffer in OutputUHD is properly filled to reduce underruns
Diffstat (limited to 'src/OutputUHD.cpp')
-rw-r--r--src/OutputUHD.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/OutputUHD.cpp b/src/OutputUHD.cpp
index 6679e62..e835d6e 100644
--- a/src/OutputUHD.cpp
+++ b/src/OutputUHD.cpp
@@ -639,16 +639,29 @@ void UHDWorker::process()
num_underflows = 0;
num_late_packets = 0;
+ int last_num_underflows = 0;
+ size_t pop_prebuffering = FRAMES_MAX_SIZE;
+
while (uwd->running) {
md.has_time_spec = false;
md.time_spec = uhd::time_spec_t(0.0);
struct UHDWorkerFrameData frame;
etiLog.log(trace, "UHD,wait");
- uwd->frames.wait_and_pop(frame);
+ uwd->frames.wait_and_pop(frame, pop_prebuffering);
etiLog.log(trace, "UHD,pop");
handle_frame(&frame);
+
+ /* Ensure we fill uwd->frames after every underrun and
+ * at startup to reduce underrun likelihood. */
+ if (last_num_underflows < num_underflows) {
+ pop_prebuffering = FRAMES_MAX_SIZE;
+ }
+ else {
+ pop_prebuffering = 1;
+ }
+ last_num_underflows = num_underflows;
}
}