diff options
| author | Christoph Berg <myon@debian.org> | 2019-06-02 22:20:23 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2019-06-02 22:20:23 +0200 |
| commit | e6817de24bdd0a9f5677b07d6bff897a5db47794 (patch) | |
| tree | 1eba79fe1a06ab93d1025297cee39e95dfab98a4 /Detector.cpp | |
| parent | 58a14345036378f9040e269fa276ba0c97795037 (diff) | |
| parent | 851b658298afb9bafeda98ffbfa2ade612c656be (diff) | |
Update upstream source from tag 'upstream/2.1.0_rc6+repack'
Update to upstream version '2.1.0~rc6+repack'
with Debian dir 2aba196aec0548f1bb333214231be9cc9efe2d4c
Diffstat (limited to 'Detector.cpp')
| -rw-r--r-- | Detector.cpp | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/Detector.cpp b/Detector.cpp index 69a10f5e..05a631b1 100644 --- a/Detector.cpp +++ b/Detector.cpp @@ -2,6 +2,7 @@ #include <QDateTime> #include <QtAlgorithms> #include <QDebug> +#include <math.h> #include "commons.h" #include "moc_Detector.cpp" @@ -10,7 +11,7 @@ extern "C" { void fil4_(qint16*, qint32*, qint16*, qint32*); } -Detector::Detector (unsigned frameRate, unsigned periodLengthInSeconds, +Detector::Detector (unsigned frameRate, double periodLengthInSeconds, unsigned downSampleFactor, QObject * parent) : AudioDevice (parent) , m_frameRate (frameRate) @@ -54,12 +55,14 @@ void Detector::clear () qint64 Detector::writeData (char const * data, qint64 maxSize) { - int ns=secondInPeriod(); - if(ns < m_ns) { // When ns has wrapped around to zero, restart the buffers + static unsigned mstr0=999999; + qint64 ms0 = QDateTime::currentMSecsSinceEpoch() % 86400000; + unsigned mstr = ms0 % int(1000.0*m_period); // ms into the nominal Tx start time + if(mstr < mstr0) { //When mstr has wrapped around to 0, restart the buffer dec_data.params.kin = 0; m_bufferPos = 0; } - m_ns=ns; + mstr0=mstr; // no torn frames Q_ASSERT (!(maxSize % static_cast<qint64> (bytesPerFrame ()))); @@ -72,7 +75,7 @@ qint64 Detector::writeData (char const * data, qint64 maxSize) if (framesAccepted < static_cast<size_t> (maxSize / bytesPerFrame ())) { qDebug () << "dropped " << maxSize / bytesPerFrame () - framesAccepted << " frames of data on the floor!" - << dec_data.params.kin << ns; + << dec_data.params.kin << mstr; } for (unsigned remaining = framesAccepted; remaining; ) { @@ -120,13 +123,3 @@ qint64 Detector::writeData (char const * data, qint64 maxSize) return maxSize; // we drop any data past the end of the buffer on // the floor until the next period starts } - -unsigned Detector::secondInPeriod () const -{ - // we take the time of the data as the following assuming no latency - // delivering it to us (not true but close enough for us) - qint64 now (QDateTime::currentMSecsSinceEpoch ()); - - unsigned secondInToday ((now % 86400000LL) / 1000); - return secondInToday % m_period; -} |
