mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
Stop audio output for SELCAL player during shutdown
This commit is contained in:
committed by
Mat Sutcliffe
parent
6841297c6e
commit
651e6bdacf
@@ -77,6 +77,20 @@ namespace BlackSound
|
||||
connect(m_audioOutput, &QAudioOutput::stateChanged, this, &CThreadedTonePairPlayer::handleStateChanged);
|
||||
}
|
||||
|
||||
void CThreadedTonePairPlayer::beforeQuit() noexcept
|
||||
{
|
||||
QMutexLocker ml(&m_mutex);
|
||||
CLogMessage(this).info(u"CThreadedTonePairPlayer quit for '%1'") << m_deviceInfo.getName();
|
||||
|
||||
if (m_audioOutput)
|
||||
{
|
||||
m_audioOutput->stop();
|
||||
m_audioOutput->disconnect();
|
||||
}
|
||||
|
||||
m_buffer.close();
|
||||
}
|
||||
|
||||
void CThreadedTonePairPlayer::handleStateChanged(QAudio::State newState)
|
||||
{
|
||||
QMutexLocker ml(&m_mutex);
|
||||
@@ -175,7 +189,7 @@ namespace BlackSound
|
||||
bufferPointer -= last0AmplitudeSample;
|
||||
while (last0AmplitudeSample)
|
||||
{
|
||||
double amplitude = 0.0; // amplitude -1 -> +1 , 0 is silence
|
||||
const double amplitude = 0.0; // amplitude -1 -> +1 , 0 is silence
|
||||
|
||||
// generate this for all channels, usually 1 channel
|
||||
for (int i = 0; i < this->m_audioFormat.channelCount(); ++i)
|
||||
@@ -195,7 +209,7 @@ namespace BlackSound
|
||||
Q_ASSERT(this->m_audioFormat.sampleType() == QAudioFormat::SignedInt);
|
||||
Q_ASSERT(this->m_audioFormat.byteOrder() == QAudioFormat::LittleEndian);
|
||||
|
||||
qint16 value = static_cast<qint16>(amplitude * 32767);
|
||||
const qint16 value = static_cast<qint16>(amplitude * 32767);
|
||||
qToLittleEndian<qint16>(value, bufferPointer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,9 @@ namespace BlackSound
|
||||
//! \copydoc BlackMisc::CContinuousWorker::initialize
|
||||
virtual void initialize() override;
|
||||
|
||||
//! \copydoc BlackMisc::CContinuousWorker::beforeQuit
|
||||
virtual void beforeQuit() noexcept override;
|
||||
|
||||
private:
|
||||
void handleStateChanged(QAudio::State newState);
|
||||
void playBuffer();
|
||||
@@ -61,8 +64,8 @@ namespace BlackSound
|
||||
|
||||
//! Write audio amplitude to data buffer
|
||||
//! This method assumes that
|
||||
//! \li sampleSize == 16
|
||||
//! \li byte order == little endian
|
||||
//! \li sampleSize == 16
|
||||
//! \li byte order == little endian
|
||||
//! \li sample type == signed int
|
||||
void writeAmplitudeToBuffer(double amplitude, unsigned char *bufferPointer);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user