mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2025-03-23 20:48:33 -04:00
Simplify logging of missing/extra audio input samples
These warnings and errors now go to the the system log rather than a MessageBox.
This commit is contained in:
parent
9417dee4a8
commit
21e7560b89
@ -2,12 +2,15 @@
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
#include <iomanip>
|
||||
#include <QAudioDeviceInfo>
|
||||
#include <QAudioFormat>
|
||||
#include <QAudioInput>
|
||||
#include <QSysInfo>
|
||||
#include <QDebug>
|
||||
|
||||
#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<qint64>::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 ();
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user