From bc30c39a032c617f0819e09c0d94d2d8b16a9ac5 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Thu, 15 Jun 2017 20:00:01 -0700 Subject: [PATCH] UI: Ignore first 2.5 seconds of bandwidth test System network buffers need to be given some time to fill before starting a bandwidth test. This prevents the buffers from skewing with the results. --- UI/window-basic-auto-config-test.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/UI/window-basic-auto-config-test.cpp b/UI/window-basic-auto-config-test.cpp index f7b1ffe08..04b44e1dc 100644 --- a/UI/window-basic-auto-config-test.cpp +++ b/UI/window-basic-auto-config-test.cpp @@ -356,6 +356,19 @@ void AutoConfigTestPage::TestBandwidthThread() Q_ARG(QString, QTStr(TEST_BW_SERVER) .arg(server.name.c_str()))); + /* ignore first 2.5 seconds due to possible buffering skewing + * the result */ + cv.wait_for(ul, chrono::milliseconds(2500)); + if (stopped) + continue; + if (cancel) { + ul.unlock(); + obs_output_force_stop(output); + return; + } + + /* continue test */ + int start_bytes = (int)obs_output_get_total_bytes(output); uint64_t t_start = os_gettime_ns(); cv.wait_for(ul, chrono::seconds(10)); @@ -372,7 +385,8 @@ void AutoConfigTestPage::TestBandwidthThread() uint64_t total_time = os_gettime_ns() - t_start; - int total_bytes = (int)obs_output_get_total_bytes(output); + int total_bytes = (int)obs_output_get_total_bytes(output) - + start_bytes; uint64_t bitrate = (uint64_t)total_bytes * 8 * 1000000000 / total_time / 1000;