From 3bd43db55ccdefa05e9dc197acb7bcdcc4658f0a Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sun, 11 Aug 2013 01:30:05 +0000 Subject: [PATCH] Bugfixes: Detector no longer collects samples when transmitting or not monitoring. This was causingissues with the waterfall after tx periods and was a waste of CPU cycles. Correct the missing window title on the waterfall window. Stop and restart the output audio stream if the configuration of device or channels changes in the setup dialog. This defect was causing spurious transmissions after changing configuration. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3543 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- Detector.cpp | 69 +++++++++++++++++++++++++++----------------------- devsetup.cpp | 3 ++- mainwindow.cpp | 3 ++- widegraph.cpp | 3 +-- 4 files changed, 43 insertions(+), 35 deletions(-) diff --git a/Detector.cpp b/Detector.cpp index 2fe0031a2..3685235c1 100644 --- a/Detector.cpp +++ b/Detector.cpp @@ -37,43 +37,50 @@ void Detector::clear () qint64 Detector::writeData (char const * data, qint64 maxSize) { - Q_ASSERT (!(maxSize % static_cast (bytesPerFrame ()))); // no torn frames + 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)); + 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 ())) - { - qDebug () << "dropped " << maxSize / sizeof (jt9com_.d2[0]) - framesAccepted << " frames of data on the floor!"; - } - - store (data, framesAccepted, &jt9com_.d2[jt9com_.kin]); - - unsigned lastSignalIndex (jt9com_.kin / m_framesPerSignal); - jt9com_.kin += framesAccepted; - unsigned currentSignalIndex (jt9com_.kin / m_framesPerSignal); - - if (currentSignalIndex != lastSignalIndex && m_monitoring) - { - Q_EMIT framesWritten (currentSignalIndex * m_framesPerSignal); - } - - if (!secondInPeriod ()) - { - if (!m_starting) + if (framesAccepted < static_cast (maxSize / bytesPerFrame ())) { - // next samples will be in new period so wrap around to - // start of buffer - // - // we don't bother calling reset () since we expect to fill - // the whole buffer and don't need to waste cycles zeroing - jt9com_.kin = 0; - m_starting = true; + qDebug () << "dropped " << maxSize / sizeof (jt9com_.d2[0]) - framesAccepted << " frames of data on the floor!"; + } + + store (data, framesAccepted, &jt9com_.d2[jt9com_.kin]); + + unsigned lastSignalIndex (jt9com_.kin / m_framesPerSignal); + jt9com_.kin += framesAccepted; + unsigned currentSignalIndex (jt9com_.kin / m_framesPerSignal); + + if (currentSignalIndex != lastSignalIndex && m_monitoring) + { + Q_EMIT framesWritten (currentSignalIndex * m_framesPerSignal); + } + + if (!secondInPeriod ()) + { + if (!m_starting) + { + // next samples will be in new period so wrap around to + // start of buffer + // + // we don't bother calling reset () since we expect to fill + // the whole buffer and don't need to waste cycles zeroing + jt9com_.kin = 0; + m_starting = true; + } + } + else if (m_starting) + { + m_starting = false; } } - else if (m_starting) + else { - m_starting = false; + jt9com_.kin = 0; } return maxSize; // we drop any data past the end of diff --git a/devsetup.cpp b/devsetup.cpp index 8d7d0dfc6..b0ed3ea48 100644 --- a/devsetup.cpp +++ b/devsetup.cpp @@ -216,7 +216,8 @@ void DevSetup::accept() // Check to see whether SoundInThread must be restarted, // and save user parameters. - m_restartSoundIn = m_restartSoundOut = false; + m_restartSoundIn = false; + m_restartSoundOut = false; if (m_audioInputDevice != m_audioInputDevices[ui->comboBoxSndIn->currentIndex ()]) { diff --git a/mainwindow.cpp b/mainwindow.cpp index 7fcfc914e..776cdb202 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -822,7 +822,8 @@ void MainWindow::on_actionDeviceSetup_triggered() //Setup Dialog } if(dlg.m_restartSoundOut) { - transmit (); + Q_EMIT stopAudioOutputStream (); + Q_EMIT startAudioOutputStream (m_audioOutputDevice, AudioDevice::Mono == m_audioOutputChannel ? 1 : 2); } } m_catEnabled=dlg.m_catEnabled; diff --git a/widegraph.cpp b/widegraph.cpp index 654280153..32533095c 100644 --- a/widegraph.cpp +++ b/widegraph.cpp @@ -9,14 +9,13 @@ WideGraph::WideGraph(QSettings * settings, QWidget *parent) : ui(new Ui::WideGraph), m_settings (settings) { - installEventFilter (parent); + ui->setupUi(this); setWindowTitle ("Wide Graph"); setWindowFlags (Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint); setMaximumWidth (MAX_SCREENSIZE); setMaximumHeight (880); - ui->setupUi(this); ui->widePlot->setCursor(Qt::CrossCursor); ui->widePlot->setMaximumHeight(800); ui->widePlot->m_bCurrent=false;