mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25: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);
|
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)
|
void CThreadedTonePairPlayer::handleStateChanged(QAudio::State newState)
|
||||||
{
|
{
|
||||||
QMutexLocker ml(&m_mutex);
|
QMutexLocker ml(&m_mutex);
|
||||||
@@ -175,7 +189,7 @@ namespace BlackSound
|
|||||||
bufferPointer -= last0AmplitudeSample;
|
bufferPointer -= last0AmplitudeSample;
|
||||||
while (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
|
// generate this for all channels, usually 1 channel
|
||||||
for (int i = 0; i < this->m_audioFormat.channelCount(); ++i)
|
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.sampleType() == QAudioFormat::SignedInt);
|
||||||
Q_ASSERT(this->m_audioFormat.byteOrder() == QAudioFormat::LittleEndian);
|
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);
|
qToLittleEndian<qint16>(value, bufferPointer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,9 @@ namespace BlackSound
|
|||||||
//! \copydoc BlackMisc::CContinuousWorker::initialize
|
//! \copydoc BlackMisc::CContinuousWorker::initialize
|
||||||
virtual void initialize() override;
|
virtual void initialize() override;
|
||||||
|
|
||||||
|
//! \copydoc BlackMisc::CContinuousWorker::beforeQuit
|
||||||
|
virtual void beforeQuit() noexcept override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void handleStateChanged(QAudio::State newState);
|
void handleStateChanged(QAudio::State newState);
|
||||||
void playBuffer();
|
void playBuffer();
|
||||||
@@ -61,8 +64,8 @@ namespace BlackSound
|
|||||||
|
|
||||||
//! Write audio amplitude to data buffer
|
//! Write audio amplitude to data buffer
|
||||||
//! This method assumes that
|
//! This method assumes that
|
||||||
//! \li sampleSize == 16
|
//! \li sampleSize == 16
|
||||||
//! \li byte order == little endian
|
//! \li byte order == little endian
|
||||||
//! \li sample type == signed int
|
//! \li sample type == signed int
|
||||||
void writeAmplitudeToBuffer(double amplitude, unsigned char *bufferPointer);
|
void writeAmplitudeToBuffer(double amplitude, unsigned char *bufferPointer);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user