From db0ba3940d4fa71440dfb19b66244b26aa90f3d3 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Thu, 3 Apr 2014 20:06:30 +0000 Subject: [PATCH] Squashed yet more compiler warnings. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3979 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- astro.cpp | 14 +++-------- mainwindow.cpp | 1 - soundout.cpp | 68 ++++++++++++++++---------------------------------- soundout.h | 10 -------- 4 files changed, 26 insertions(+), 67 deletions(-) diff --git a/astro.cpp b/astro.cpp index 86416a777..4542a0673 100644 --- a/astro.cpp +++ b/astro.cpp @@ -90,7 +90,6 @@ void Astro::astroUpdate(QDateTime t, QString mygrid, QString hisgrid, int fQSO, int nsetftx, int ntxFreq) { static int ntxFreq0=-99; - static bool astroBusy=false; double azsun,elsun,azmoon,elmoon,azmoondx,elmoondx; double ramoon,decmoon,dgrd,poloffset,xnr,techo; int ntsky,ndop,ndop00; @@ -108,15 +107,10 @@ void Astro::astroUpdate(QDateTime t, QString mygrid, QString hisgrid, int nfreq=10368; if(nfreq<10 or nfreq > 50000) nfreq=144; - if(!astroBusy) { - astroBusy=true; - - astrosub_(&nyear, &month, &nday, &uth, &nfreq, mygrid.toLatin1(), - hisgrid.toLatin1(), &azsun, &elsun, &azmoon, &elmoon, - &azmoondx, &elmoondx, &ntsky, &ndop, &ndop00,&ramoon, &decmoon, - &dgrd, &poloffset, &xnr, &techo, 6, 6); - astroBusy=false; - } + astrosub_(&nyear, &month, &nday, &uth, &nfreq, mygrid.toLatin1(), + hisgrid.toLatin1(), &azsun, &elsun, &azmoon, &elmoon, + &azmoondx, &elmoondx, &ntsky, &ndop, &ndop00,&ramoon, &decmoon, + &dgrd, &poloffset, &xnr, &techo, 6, 6); QString message; { diff --git a/mainwindow.cpp b/mainwindow.cpp index 9e65c3c08..d530ff1be 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -92,7 +92,6 @@ MainWindow::MainWindow(bool multiple, QSettings * settings, QSharedMemory *shdme m_dialFreq {0}, m_detector (RX_SAMPLE_RATE, NTMAX / 2, 6912 / 2, downSampleFactor), m_modulator (TX_SAMPLE_RATE, NTMAX / 2), - m_soundOutput (&m_modulator), m_audioThread {new QThread}, m_appDir {QApplication::applicationDirPath ()}, mem_jt9 {shdmem}, diff --git a/soundout.cpp b/soundout.cpp index 09a04689c..672bb9699 100644 --- a/soundout.cpp +++ b/soundout.cpp @@ -46,46 +46,34 @@ bool SoundOutput::audioError () const return result; } -SoundOutput::SoundOutput (QIODevice * source) - : m_active (false) - , m_currentDevice (QAudioDeviceInfo::defaultOutputDevice ()) -{ - Q_ASSERT (source); -} - void SoundOutput::setFormat (QAudioDeviceInfo const& device, unsigned channels, unsigned msBuffered) { Q_ASSERT (0 < channels && channels < 3); - if (!m_stream || device != m_currentDevice || - channels != static_cast (m_stream->format ().channelCount ())) + QAudioFormat format (device.preferredFormat ()); + + format.setChannelCount (channels); + format.setCodec ("audio/pcm"); + format.setSampleRate (48000); + format.setSampleType (QAudioFormat::SignedInt); + format.setSampleSize (16); + if (!format.isValid ()) { - QAudioFormat format (device.preferredFormat ()); - - format.setChannelCount (channels); - format.setCodec ("audio/pcm"); - format.setSampleRate (48000); - format.setSampleType (QAudioFormat::SignedInt); - format.setSampleSize (16); - if (!format.isValid ()) - { - Q_EMIT error (tr ("Requested output audio format is not valid.")); - } - if (!device.isFormatSupported (format)) - { - Q_EMIT error (tr ("Requested output audio format is not supported on device.")); - } - - m_stream.reset (new QAudioOutput (device, format)); - audioError (); - m_stream->setVolume (m_volume); - m_stream->setNotifyInterval(100); - - connect (m_stream.data(), &QAudioOutput::stateChanged, this, &SoundOutput::handleStateChanged); - - m_currentDevice = device; - // qDebug() << "A" << m_volume << m_stream->notifyInterval(); + Q_EMIT error (tr ("Requested output audio format is not valid.")); } + if (!device.isFormatSupported (format)) + { + Q_EMIT error (tr ("Requested output audio format is not supported on device.")); + } + + m_stream.reset (new QAudioOutput (device, format)); + audioError (); + m_stream->setVolume (m_volume); + m_stream->setNotifyInterval(100); + + connect (m_stream.data(), &QAudioOutput::stateChanged, this, &SoundOutput::handleStateChanged); + + // qDebug() << "A" << m_volume << m_stream->notifyInterval(); // // This buffer size is critical since for proper sound streaming. If @@ -153,21 +141,17 @@ void SoundOutput::handleStateChanged (QAudio::State newState) { case QAudio::IdleState: Q_EMIT status (tr ("Idle")); - m_active = false; break; case QAudio::ActiveState: - m_active = true; Q_EMIT status (tr ("Sending")); break; case QAudio::SuspendedState: - m_active = true; Q_EMIT status (tr ("Suspended")); break; case QAudio::StoppedState: - m_active = false; if (audioError ()) { Q_EMIT status (tr ("Error")); @@ -179,11 +163,3 @@ void SoundOutput::handleStateChanged (QAudio::State newState) break; } } - -SoundOutput::~SoundOutput () -{ - if (m_stream) - { - m_stream->stop (); - } -} diff --git a/soundout.h b/soundout.h index 9fd7157fe..11f9df884 100644 --- a/soundout.h +++ b/soundout.h @@ -16,14 +16,7 @@ class SoundOutput { Q_OBJECT; - Q_PROPERTY(bool running READ isRunning); - Q_PROPERTY(unsigned attenuation READ attenuation WRITE setAttenuation RESET resetAttenuation); - public: - SoundOutput (QIODevice * source); - ~SoundOutput (); - - bool isRunning() const {return m_active;} qreal attenuation () const; QAudioOutput * stream () {return m_stream.data ();} @@ -46,9 +39,6 @@ private Q_SLOTS: private: QScopedPointer m_stream; - - bool volatile m_active; - QAudioDeviceInfo m_currentDevice; qreal m_volume; };