summaryrefslogtreecommitdiffstats
path: root/src/OutputUHD.cpp
diff options
context:
space:
mode:
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;
}
}