From 8d6c7649e0ca0ffe30c0fc343fc54f501b0363ce Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Fri, 10 May 2019 20:31:16 +0100 Subject: [PATCH] Repaired a defect in the calculation of delay before starting audio streams --- Audio/tools/record_time_signal.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Audio/tools/record_time_signal.cpp b/Audio/tools/record_time_signal.cpp index f63f8dbdc..8cd4f8ee1 100644 --- a/Audio/tools/record_time_signal.cpp +++ b/Audio/tools/record_time_signal.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "revision_utils.hpp" #include "Audio/BWFFile.hpp" @@ -52,7 +53,12 @@ public: } else { - QTimer::singleShot (int ((((start - (QDateTime::currentMSecsSinceEpoch () / 1000) % 60) + 60) % 60) * 1000), Qt::PreciseTimer, this, &Record::start_recording); + auto now = QDateTime::currentDateTimeUtc (); + auto time = now.time (); + auto then = now; + then.setTime (QTime {time.hour (), time.minute (), start}); + auto delta_ms = (now.msecsTo (then) + (60 * 1000)) % (60 * 1000); + QTimer::singleShot (int (delta_ms), Qt::PreciseTimer, this, &Record::start_recording); } } @@ -113,7 +119,12 @@ public: } else { - QTimer::singleShot (int ((((start - (QDateTime::currentMSecsSinceEpoch () / 1000) % 60) + 60) % 60) * 1000), Qt::PreciseTimer, this, &Playback::start_playback); + auto now = QDateTime::currentDateTimeUtc (); + auto time = now.time (); + auto then = now; + then.setTime (QTime {time.hour (), time.minute (), start}); + auto delta_ms = (now.msecsTo (then) + (60 * 1000)) % (60 * 1000); + QTimer::singleShot (int (delta_ms), Qt::PreciseTimer, this, &Playback::start_playback); } }