mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-27 06:38:44 -05:00
Added tuning parameters for audio subsystem.
By adding the following section to the initialisation file the audio buffer sizes and audio thread priority may be adjusted. [Tune] Audio\InputBufferFrames=1200 Audio\OutputBufferMs=1000 Audio\ThreadPriority=4 The values above are the program defaults that will be used if the initialisation parameters are omitted. Thread prioritis are the QThread::Priority enumumeration values. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3576 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
982721c503
commit
d88ea99582
@ -54,7 +54,10 @@ MainWindow::MainWindow(QSettings * settings, QSharedMemory *shdmem, QString *the
|
||||
m_modulator (TX_SAMPLE_RATE, NTMAX / 2),
|
||||
m_audioOutputDevice (QAudioDeviceInfo::defaultOutputDevice ()), // start with default
|
||||
m_soundOutput (&m_modulator),
|
||||
psk_Reporter (new PSK_Reporter (this))
|
||||
psk_Reporter (new PSK_Reporter (this)),
|
||||
m_msAudioOutputBuffered (0u),
|
||||
m_framesAudioInputBuffered (RX_SAMPLE_RATE / 10),
|
||||
m_audioThreadPriority (QThread::HighPriority)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@ -73,7 +76,7 @@ MainWindow::MainWindow(QSettings * settings, QSharedMemory *shdmem, QString *the
|
||||
connect (&m_audioThread, &QThread::finished, &m_audioThread, &QThread::deleteLater); // disposal
|
||||
|
||||
// hook up sound output stream slots & signals
|
||||
connect (this, SIGNAL (startAudioOutputStream (QAudioDeviceInfo const&, unsigned)), &m_soundOutput, SLOT (startStream (QAudioDeviceInfo const&, unsigned)));
|
||||
connect (this, SIGNAL (startAudioOutputStream (QAudioDeviceInfo const&, unsigned, unsigned)), &m_soundOutput, SLOT (startStream (QAudioDeviceInfo const&, unsigned, unsigned)));
|
||||
connect (this, SIGNAL (stopAudioOutputStream ()), &m_soundOutput, SLOT (stopStream ()));
|
||||
connect (&m_soundOutput, &SoundOutput::error, this, &MainWindow::showSoundOutError);
|
||||
// connect (&m_soundOutput, &SoundOutput::status, this, &MainWindow::showStatusMessage);
|
||||
@ -102,10 +105,6 @@ MainWindow::MainWindow(QSettings * settings, QSharedMemory *shdmem, QString *the
|
||||
|
||||
connect(&m_detector, SIGNAL (framesWritten (qint64)), this, SLOT (dataSink (qint64)));
|
||||
|
||||
// start the audio thread
|
||||
m_audioThread.start (QThread::HighPriority);
|
||||
|
||||
|
||||
// setup the waterfall
|
||||
connect(m_wideGraph.data (), SIGNAL(freezeDecode2(int)),this,
|
||||
SLOT(freezeDecode(int)));
|
||||
@ -287,6 +286,9 @@ MainWindow::MainWindow(QSettings * settings, QSharedMemory *shdmem, QString *the
|
||||
//Band Settings
|
||||
readSettings(); //Restore user's setup params
|
||||
|
||||
// start the audio thread
|
||||
m_audioThread.start (m_audioThreadPriority);
|
||||
|
||||
#ifdef WIN32
|
||||
if(!m_bMultipleOK) {
|
||||
while(true) {
|
||||
@ -379,7 +381,7 @@ MainWindow::MainWindow(QSettings * settings, QSharedMemory *shdmem, QString *the
|
||||
connect(watcher2, SIGNAL(finished()),this,SLOT(diskWriteFinished()));
|
||||
|
||||
Q_EMIT startDetector (m_audioInputChannel);
|
||||
Q_EMIT startAudioInputStream (m_audioInputDevice, AudioDevice::Mono == m_audioInputChannel ? 1 : 2, RX_SAMPLE_RATE / 10, &m_detector);
|
||||
Q_EMIT startAudioInputStream (m_audioInputDevice, AudioDevice::Mono == m_audioInputChannel ? 1 : 2, m_framesAudioInputBuffered, &m_detector);
|
||||
|
||||
Q_EMIT transmitFrequency (m_txFreq - (m_bSplit || m_bXIT ? m_XIT : 0));
|
||||
Q_EMIT muteAudioOutput (false);
|
||||
@ -662,6 +664,14 @@ void MainWindow::readSettings()
|
||||
ui->cbPlus2kHz->setChecked(m_plus2kHz);
|
||||
m_settings->endGroup();
|
||||
|
||||
// use these initialisation settings to tune the audio o/p bufefr
|
||||
// size and audio thread priority
|
||||
m_settings->beginGroup ("Tune");
|
||||
m_msAudioOutputBuffered = m_settings->value ("Audio/OutputBufferMs").toInt ();
|
||||
m_framesAudioInputBuffered = m_settings->value ("Audio/InputBufferFrames", RX_SAMPLE_RATE / 10).toInt ();
|
||||
m_audioThreadPriority = static_cast<QThread::Priority> (m_settings->value ("Audio/ThreadPriority", QThread::HighPriority).toInt () % 8);
|
||||
m_settings->endGroup ();
|
||||
|
||||
if(m_ndepth==1) ui->actionQuickDecode->setChecked(true);
|
||||
if(m_ndepth==2) ui->actionMediumDecode->setChecked(true);
|
||||
if(m_ndepth==3) ui->actionDeepestDecode->setChecked(true);
|
||||
@ -832,12 +842,12 @@ void MainWindow::on_actionDeviceSetup_triggered() //Setup Dialog
|
||||
Q_EMIT stopAudioInputStream ();
|
||||
Q_EMIT detectorClose ();
|
||||
Q_EMIT startDetector (m_audioInputChannel);
|
||||
Q_EMIT startAudioInputStream (m_audioInputDevice, AudioDevice::Mono == m_audioInputChannel ? 1 : 2, RX_SAMPLE_RATE / 10, &m_detector);
|
||||
Q_EMIT startAudioInputStream (m_audioInputDevice, AudioDevice::Mono == m_audioInputChannel ? 1 : 2, m_framesAudioInputBuffered, &m_detector);
|
||||
}
|
||||
|
||||
if(dlg.m_restartSoundOut) {
|
||||
Q_EMIT stopAudioOutputStream ();
|
||||
Q_EMIT startAudioOutputStream (m_audioOutputDevice, AudioDevice::Mono == m_audioOutputChannel ? 1 : 2);
|
||||
Q_EMIT startAudioOutputStream (m_audioOutputDevice, AudioDevice::Mono == m_audioOutputChannel ? 1 : 2, m_msAudioOutputBuffered);
|
||||
}
|
||||
}
|
||||
m_catEnabled=dlg.m_catEnabled;
|
||||
@ -869,7 +879,7 @@ void MainWindow::on_monitorButton_clicked() //Monitor
|
||||
{
|
||||
m_monitoring=true;
|
||||
Q_EMIT detectorSetMonitoring (true);
|
||||
// Q_EMIT startAudioInputStream (m_audioInputDevice, AudioDevice::Mono == m_audioInputChannel ? 1 : 2, RX_SAMPLE_RATE / 10, &m_detector);
|
||||
// Q_EMIT startAudioInputStream (m_audioInputDevice, AudioDevice::Mono == m_audioInputChannel ? 1 : 2, m_framesAudioInputBuffered, &m_detector);
|
||||
m_diskData=false;
|
||||
}
|
||||
|
||||
@ -3067,7 +3077,7 @@ void MainWindow::transmit (double snr)
|
||||
{
|
||||
Q_EMIT sendMessage (NUM_JT9_SYMBOLS, m_nsps, m_txFreq - (m_bSplit || m_bXIT ? m_XIT : 0), m_audioOutputChannel, true, snr);
|
||||
}
|
||||
Q_EMIT startAudioOutputStream (m_audioOutputDevice, AudioDevice::Mono == m_audioOutputChannel ? 1 : 2);
|
||||
Q_EMIT startAudioOutputStream (m_audioOutputDevice, AudioDevice::Mono == m_audioOutputChannel ? 1 : 2, m_msAudioOutputBuffered);
|
||||
}
|
||||
|
||||
void MainWindow::on_outAttenuation_valueChanged (int a)
|
||||
|
@ -181,7 +181,7 @@ private slots:
|
||||
void on_outAttenuation_valueChanged (int);
|
||||
|
||||
private:
|
||||
Q_SIGNAL void startAudioOutputStream (QAudioDeviceInfo, unsigned channels);
|
||||
Q_SIGNAL void startAudioOutputStream (QAudioDeviceInfo, unsigned channels, unsigned msBuffered);
|
||||
Q_SIGNAL void stopAudioOutputStream ();
|
||||
|
||||
Q_SIGNAL void startAudioInputStream (QAudioDeviceInfo const&, unsigned channels, int framesPerBuffer, QIODevice * sink);
|
||||
@ -389,6 +389,9 @@ private:
|
||||
SignalMeter *signalMeter;
|
||||
LogBook m_logBook;
|
||||
DecodedText m_QSOText;
|
||||
unsigned m_msAudioOutputBuffered;
|
||||
unsigned m_framesAudioInputBuffered;
|
||||
QThread::Priority m_audioThreadPriority;
|
||||
|
||||
|
||||
//---------------------------------------------------- private functions
|
||||
|
11
rigclass.cpp
11
rigclass.cpp
@ -68,13 +68,16 @@ int Rig::init(rig_model_t rig_model)
|
||||
|
||||
theRig = rig_init(rig_model);
|
||||
if (!theRig)
|
||||
{
|
||||
initOk = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
initOk = true;
|
||||
|
||||
caps = theRig->caps;
|
||||
theRig->callbacks.freq_event = &hamlibpp_freq_event;
|
||||
theRig->state.obj = (rig_ptr_t)this;
|
||||
caps = theRig->caps;
|
||||
theRig->callbacks.freq_event = &hamlibpp_freq_event;
|
||||
theRig->state.obj = (rig_ptr_t)this;
|
||||
}
|
||||
|
||||
return initOk;
|
||||
}
|
||||
|
@ -7,9 +7,9 @@
|
||||
#include <QDebug>
|
||||
|
||||
#if defined (WIN32)
|
||||
# define MS_BUFFERED 1000
|
||||
# define MS_BUFFERED 1000u
|
||||
#else
|
||||
# define MS_BUFFERED 2000
|
||||
# define MS_BUFFERED 2000u
|
||||
#endif
|
||||
|
||||
bool SoundOutput::audioError () const
|
||||
@ -53,7 +53,7 @@ SoundOutput::SoundOutput (QIODevice * source)
|
||||
Q_ASSERT (source);
|
||||
}
|
||||
|
||||
void SoundOutput::startStream (QAudioDeviceInfo const& device, unsigned channels)
|
||||
void SoundOutput::startStream (QAudioDeviceInfo const& device, unsigned channels, unsigned msBuffered)
|
||||
{
|
||||
Q_ASSERT (0 < channels && channels < 3);
|
||||
|
||||
@ -97,7 +97,7 @@ void SoundOutput::startStream (QAudioDeviceInfo const& device, unsigned channels
|
||||
// we have to set this before every start on the stream because the
|
||||
// Windows implementation seems to forget the buffer size after a
|
||||
// stop.
|
||||
m_stream->setBufferSize (m_stream->format ().bytesForDuration (MS_BUFFERED * 1000));
|
||||
m_stream->setBufferSize (m_stream->format ().bytesForDuration ((msBuffered ? msBuffered : MS_BUFFERED) * 1000));
|
||||
m_stream->start (m_source);
|
||||
audioError ();
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ class SoundOutput : public QObject
|
||||
/* private because we expect to run in a thread and don't want direct
|
||||
C++ calls made, instead they must be invoked via the Qt
|
||||
signal/slot mechanism which is thread safe */
|
||||
void startStream (QAudioDeviceInfo const& device, unsigned channels);
|
||||
void startStream (QAudioDeviceInfo const& device, unsigned channels, unsigned msBuffered = 0u);
|
||||
void suspend ();
|
||||
void resume ();
|
||||
void stopStream ();
|
||||
|
Loading…
Reference in New Issue
Block a user