diff --git a/Audio/soundin.cpp b/Audio/soundin.cpp index 53779b341..581f1a92f 100644 --- a/Audio/soundin.cpp +++ b/Audio/soundin.cpp @@ -2,12 +2,15 @@ #include #include +#include #include #include #include #include #include +#include "Logger.hpp" + #include "moc_soundin.cpp" bool SoundInput::checkStream () @@ -178,8 +181,18 @@ void SoundInput::reset (bool report_dropped_frames) if (cummulative_lost_usec_ != std::numeric_limits::min () && report_dropped_frames) { auto lost_usec = elapsed_usecs - m_stream->processedUSecs () - cummulative_lost_usec_; - Q_EMIT dropped_frames (m_stream->format ().framesForDuration (lost_usec), lost_usec); - //qDebug () << "SoundInput::reset: frames dropped:" << m_stream->format ().framesForDuration (lost_usec) << "sec:" << lost_usec / 1.e6; + if (std::abs (lost_usec) > 48000 / 5) + { + LOG_WARN ("Detected dropped audio source samples: " + << m_stream->format ().framesForDuration (lost_usec) + << " (" << std::setprecision (4) << lost_usec / 1.e6 << " S)") + } + else if (std::abs (lost_usec) > 5 * 48000) + { + LOG_ERROR ("Detected excessive dropped audio source samples: " + << m_stream->format ().framesForDuration (lost_usec) + << " (" << std::setprecision (4) << lost_usec / 1.e6 << " S)") + } } cummulative_lost_usec_ = elapsed_usecs - m_stream->processedUSecs (); } diff --git a/Audio/soundin.h b/Audio/soundin.h index c35b3d7d8..823993c69 100644 --- a/Audio/soundin.h +++ b/Audio/soundin.h @@ -40,7 +40,6 @@ public: Q_SIGNAL void error (QString message) const; Q_SIGNAL void status (QString message) const; - Q_SIGNAL void dropped_frames (qint32 dropped, qint64 usec); private: // used internally diff --git a/widgets/mainwindow.cpp b/widgets/mainwindow.cpp index f25f5460a..1feaa3243 100644 --- a/widgets/mainwindow.cpp +++ b/widgets/mainwindow.cpp @@ -480,23 +480,6 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, connect(m_soundInput, &SoundInput::error, this, &MainWindow::showSoundInError); connect(m_soundInput, &SoundInput::error, &m_config, &Configuration::invalidate_audio_input_device); // connect(m_soundInput, &SoundInput::status, this, &MainWindow::showStatusMessage); - connect (m_soundInput, &SoundInput::dropped_frames, this, [this] (qint32 dropped_frames, qint64 usec) { - if (dropped_frames > 48000 / 5) // 1/5 second - { - showStatusMessage (tr ("%1 (%2 sec) audio frames dropped").arg (dropped_frames).arg (usec / 1.e6, 5, 'f', 3)); - } - if (dropped_frames > 5 * 48000) // seconds - { - auto period = qt_truncate_date_time_to (QDateTime::currentDateTimeUtc ().addMSecs (-m_TRperiod / 2.), m_TRperiod * 1e3); - MessageBox::warning_message (this - , tr ("Audio Source") - , tr ("Reduce system load") - , tr ("Excessive dropped samples - %1 (%2 sec) audio frames dropped in period starting %3") - .arg (dropped_frames) - .arg (usec / 1.e6, 5, 'f', 3) - .arg (period.toString ("hh:mm:ss"))); - } - }); connect (&m_audioThread, &QThread::finished, m_soundInput, &QObject::deleteLater); connect (this, &MainWindow::finished, this, &MainWindow::close); @@ -1563,7 +1546,7 @@ void MainWindow::dataSink(qint64 frames) if(m_mode=="FT8" and !m_diskData and (m_ihsym==m_earlyDecode or m_ihsym==m_earlyDecode2)) return; if (!m_diskData) { - Q_EMIT reset_audio_input_stream (true); // signals dropped samples + Q_EMIT reset_audio_input_stream (true); // reports dropped samples } if(!m_diskData and (m_saveAll or m_saveDecoded or m_mode=="WSPR" or m_mode=="FST4W")) { //Always save unless "Save None"; may delete later