From d98153f558e634298fa5f9e14c00c3a18d6c142b Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sat, 28 Sep 2013 00:58:36 +0000 Subject: [PATCH] Changed Detector to only pass multiples of 4 frames to 48kHz to 12kHz down sampler routine. Added assert to disallow stereo processing of i/p samples until fil4.f90 can deal with interleaved stereo streams. Added QProcess error to jt9 error handler, not that anything is done with the error code yet but at least it can be examined in the debugger if required. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3583 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- Detector.cpp | 19 ++++++++++++------- mainwindow.cpp | 4 ++-- mainwindow.h | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Detector.cpp b/Detector.cpp index 78500ebee..20d4e6dfa 100644 --- a/Detector.cpp +++ b/Detector.cpp @@ -35,26 +35,31 @@ void Detector::clear () // jt9com_.kin = qMin ((msInPeriod * m_frameRate) / 1000, static_cast (sizeof (jt9com_.d2) / sizeof (jt9com_.d2[0]))); jt9com_.kin = 0; - // fill buffer with zeros (G4WJS commented out becuase it might cause decoder hangs) + // fill buffer with zeros (G4WJS commented out because it might cause decoder hangs) // qFill (jt9com_.d2, jt9com_.d2 + sizeof (jt9com_.d2) / sizeof (jt9com_.d2[0]), 0); } qint64 Detector::writeData (char const * data, qint64 maxSize) { + bool overrun (false); + int excess (0); if (m_monitoring) { Q_ASSERT (!(maxSize % static_cast (bytesPerFrame ()))); // no torn frames qint64 framesAcceptable (sizeof (jt9com_.d2) / sizeof (jt9com_.d2[0]) - jt9com_.kin); qint64 framesAccepted (qMin (static_cast (maxSize / bytesPerFrame ()), framesAcceptable)); - - if (framesAccepted < static_cast (maxSize / bytesPerFrame ())) + + overrun = framesAccepted < static_cast (maxSize / bytesPerFrame ()); + if (overrun) { qDebug () << "dropped " << maxSize / sizeof (jt9com_.d2[0]) - framesAccepted << " frames of data on the floor!"; } + Q_ASSERT (2 == bytesPerFrame ()); // only mono until fil4 can do stereo + excess = framesAccepted % 4; qint32 m_n1,m_n2; - m_n1 = framesAccepted; + m_n1 = framesAccepted - excess; fil4_((qint16 *)data, &m_n1, m_translate, &m_n2); store ((char const *) m_translate, m_n2, &jt9com_.d2[jt9com_.kin]); @@ -90,9 +95,9 @@ qint64 Detector::writeData (char const * data, qint64 maxSize) jt9com_.kin = 0; } - return maxSize; // we drop any data past the end of - // the buffer on the floor until the - // next period starts + return maxSize - (overrun ? 0 : excess * bytesPerFrame ()); + // we drop any data past the end of the buffer on + // the floor until the next period starts } unsigned Detector::secondInPeriod () const diff --git a/mainwindow.cpp b/mainwindow.cpp index a8ce5c2dc..eec8b0efe 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -160,7 +160,7 @@ MainWindow::MainWindow(QSettings * settings, QSharedMemory *shdmem, QString *the this, SLOT(readFromStdout())); connect(&proc_jt9, SIGNAL(error(QProcess::ProcessError)), - this, SLOT(jt9_error())); + this, SLOT(jt9_error(QProcess::ProcessError))); connect(&proc_jt9, SIGNAL(readyReadStandardError()), this, SLOT(readFromStderr())); @@ -1386,7 +1386,7 @@ void MainWindow::decode() //decode() decodeBusy(true); } -void MainWindow::jt9_error() //jt9_error +void MainWindow::jt9_error(QProcess::ProcessError e) //jt9_error { if(!m_killAll) { msgBox("Error starting or running\n" + m_appDir + "/jt9 -s"); diff --git a/mainwindow.h b/mainwindow.h index f041564e0..270ddacba 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -66,7 +66,7 @@ public slots: void doubleClickOnCall2(bool shift, bool ctrl); void readFromStdout(); void readFromStderr(); - void jt9_error(); + void jt9_error(QProcess::ProcessError); void setXIT(int n); void setFreq4(int rxFreq, int txFreq);