mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 19:05:31 +08:00
Add API method to enable audio loopback in IVoice and
audio context refs #136
This commit is contained in:
@@ -146,6 +146,9 @@ namespace BlackCore
|
|||||||
|
|
||||||
//! Get the squelch value
|
//! Get the squelch value
|
||||||
virtual double getSquelchValue() const = 0;
|
virtual double getSquelchValue() const = 0;
|
||||||
|
|
||||||
|
//! Enable audio loopback
|
||||||
|
virtual void enableAudioLoopback(bool enable = true) = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -307,6 +307,13 @@ namespace BlackCore
|
|||||||
return static_cast<double>(this->m_voice->inputSquelch());
|
return static_cast<double>(this->m_voice->inputSquelch());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CContextAudio::enableAudioLoopback(bool enable)
|
||||||
|
{
|
||||||
|
Q_ASSERT(this->m_voice);
|
||||||
|
if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
|
||||||
|
m_voice->enableAudioLoopback(enable);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Settings changed
|
* Settings changed
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -97,6 +97,9 @@ namespace BlackCore
|
|||||||
//! \copydoc IContextAudio::getSquelchValue()
|
//! \copydoc IContextAudio::getSquelchValue()
|
||||||
virtual double getSquelchValue() const override;
|
virtual double getSquelchValue() const override;
|
||||||
|
|
||||||
|
//! \copydoc IContextAudio::enableAudioLoopback()
|
||||||
|
virtual void enableAudioLoopback(bool enable = true) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! \brief Constructor
|
//! \brief Constructor
|
||||||
CContextAudio(CRuntimeConfig::ContextMode mode, CRuntime *runtime);
|
CContextAudio(CRuntimeConfig::ContextMode mode, CRuntime *runtime);
|
||||||
|
|||||||
@@ -211,4 +211,9 @@ namespace BlackCore
|
|||||||
return this->m_dBusInterface->callDBusRet<bool>(QLatin1Literal("isMuted"));
|
return this->m_dBusInterface->callDBusRet<bool>(QLatin1Literal("isMuted"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CContextAudioProxy::enableAudioLoopback(bool enable)
|
||||||
|
{
|
||||||
|
return this->m_dBusInterface->callDBus(QLatin1Literal("enableAudioLoopback"), enable);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -110,6 +110,9 @@ namespace BlackCore
|
|||||||
|
|
||||||
//! \copydoc IContextAudio::getSquelchValue()
|
//! \copydoc IContextAudio::getSquelchValue()
|
||||||
virtual double getSquelchValue() const override;
|
virtual double getSquelchValue() const override;
|
||||||
|
|
||||||
|
//! \copydoc IContextAudio::enableAudioLoopback()
|
||||||
|
virtual void enableAudioLoopback(bool enable = true) override;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -213,6 +213,12 @@ namespace BlackCore
|
|||||||
*/
|
*/
|
||||||
virtual void switchAudioOutput(const ComUnit comUnit, bool enable) = 0;
|
virtual void switchAudioOutput(const ComUnit comUnit, bool enable) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Enable audio loopback to route recorded voice from microphone to speakers
|
||||||
|
* \param enable (default true)
|
||||||
|
*/
|
||||||
|
virtual void enableAudioLoopback(bool enable = true) = 0;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
//! The status of a room has changed.
|
//! The status of a room has changed.
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ namespace BlackCore
|
|||||||
m_audioOutput(new QAudioOutput()),
|
m_audioOutput(new QAudioOutput()),
|
||||||
m_inputSquelch(-1),
|
m_inputSquelch(-1),
|
||||||
m_micTestResult(Cvatlib_Voice_Simple::agc_Ok),
|
m_micTestResult(Cvatlib_Voice_Simple::agc_Ok),
|
||||||
|
m_isAudioLoopbackEnabled(false),
|
||||||
m_temporaryUserRoomIndex(CVoiceVatlib::InvalidRoomIndex),
|
m_temporaryUserRoomIndex(CVoiceVatlib::InvalidRoomIndex),
|
||||||
m_lockVoiceRooms(QReadWriteLock::Recursive),
|
m_lockVoiceRooms(QReadWriteLock::Recursive),
|
||||||
m_lockCallsigns(QReadWriteLock::Recursive),
|
m_lockCallsigns(QReadWriteLock::Recursive),
|
||||||
@@ -239,6 +240,26 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CVoiceVatlib::enableAudioLoopback(bool enable)
|
||||||
|
{
|
||||||
|
if (enable == m_isAudioLoopbackEnabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QMutexLocker lockerVatlib(&m_mutexVatlib);
|
||||||
|
Q_ASSERT_X(m_voice->IsValid() && m_voice->IsSetup(), "CVoiceVatlib", "Cvatlib_Voice_Simple invalid or not setup!");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
m_voice->SetAudioLoopback(0, enable);
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
this->exceptionDispatcher(Q_FUNC_INFO);
|
||||||
|
}
|
||||||
|
|
||||||
|
// bools are atomic. No need to protect it with a mutex
|
||||||
|
m_isAudioLoopbackEnabled = enable;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Squelch test
|
* Squelch test
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -128,6 +128,9 @@ namespace BlackCore
|
|||||||
//! \copydoc IVoice::switchAudioOutput
|
//! \copydoc IVoice::switchAudioOutput
|
||||||
virtual void switchAudioOutput(const ComUnit comUnit, bool enable) override;
|
virtual void switchAudioOutput(const ComUnit comUnit, bool enable) override;
|
||||||
|
|
||||||
|
//! \copydoc IVoice::enableAudioLoopback
|
||||||
|
virtual void enableAudioLoopback(bool enable = true) override;
|
||||||
|
|
||||||
//! \copydoc IVoice::isMuted
|
//! \copydoc IVoice::isMuted
|
||||||
virtual bool isMuted() const override
|
virtual bool isMuted() const override
|
||||||
{
|
{
|
||||||
@@ -235,6 +238,7 @@ namespace BlackCore
|
|||||||
BlackMisc::Aviation::CCallsignList m_temporaryVoiceRoomCallsigns; /*!< temp. storage of voice rooms during update */
|
BlackMisc::Aviation::CCallsignList m_temporaryVoiceRoomCallsigns; /*!< temp. storage of voice rooms during update */
|
||||||
QMap<ComUnit, bool> m_outputEnabled; /*!< output enabled, basically a mute flag */
|
QMap<ComUnit, bool> m_outputEnabled; /*!< output enabled, basically a mute flag */
|
||||||
QMap<ComUnit, ConnectionStatus> m_connectionStatus; /*!< holds connection status for each com unit */
|
QMap<ComUnit, ConnectionStatus> m_connectionStatus; /*!< holds connection status for each com unit */
|
||||||
|
bool m_isAudioLoopbackEnabled; /*!< A flag whether audio loopback is enabled or not */
|
||||||
|
|
||||||
// Need to keep the roomIndex?
|
// Need to keep the roomIndex?
|
||||||
// KB: I would remove this approach, it is potentially unsafe
|
// KB: I would remove this approach, it is potentially unsafe
|
||||||
|
|||||||
Reference in New Issue
Block a user