Add API method to enable audio loopback in IVoice and

audio context

refs #136
This commit is contained in:
Roland Winklmeier
2014-05-20 16:55:35 +02:00
parent 70c7aa4a94
commit 9c81322137
8 changed files with 52 additions and 0 deletions

View File

@@ -146,6 +146,9 @@ namespace BlackCore
//! Get the squelch value
virtual double getSquelchValue() const = 0;
//! Enable audio loopback
virtual void enableAudioLoopback(bool enable = true) = 0;
};
}

View File

@@ -307,6 +307,13 @@ namespace BlackCore
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
*/

View File

@@ -97,6 +97,9 @@ namespace BlackCore
//! \copydoc IContextAudio::getSquelchValue()
virtual double getSquelchValue() const override;
//! \copydoc IContextAudio::enableAudioLoopback()
virtual void enableAudioLoopback(bool enable = true) override;
protected:
//! \brief Constructor
CContextAudio(CRuntimeConfig::ContextMode mode, CRuntime *runtime);

View File

@@ -211,4 +211,9 @@ namespace BlackCore
return this->m_dBusInterface->callDBusRet<bool>(QLatin1Literal("isMuted"));
}
void CContextAudioProxy::enableAudioLoopback(bool enable)
{
return this->m_dBusInterface->callDBus(QLatin1Literal("enableAudioLoopback"), enable);
}
} // namespace

View File

@@ -110,6 +110,9 @@ namespace BlackCore
//! \copydoc IContextAudio::getSquelchValue()
virtual double getSquelchValue() const override;
//! \copydoc IContextAudio::enableAudioLoopback()
virtual void enableAudioLoopback(bool enable = true) override;
};
}

View File

@@ -213,6 +213,12 @@ namespace BlackCore
*/
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:
//! The status of a room has changed.

View File

@@ -21,6 +21,7 @@ namespace BlackCore
m_audioOutput(new QAudioOutput()),
m_inputSquelch(-1),
m_micTestResult(Cvatlib_Voice_Simple::agc_Ok),
m_isAudioLoopbackEnabled(false),
m_temporaryUserRoomIndex(CVoiceVatlib::InvalidRoomIndex),
m_lockVoiceRooms(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
*/

View File

@@ -128,6 +128,9 @@ namespace BlackCore
//! \copydoc IVoice::switchAudioOutput
virtual void switchAudioOutput(const ComUnit comUnit, bool enable) override;
//! \copydoc IVoice::enableAudioLoopback
virtual void enableAudioLoopback(bool enable = true) override;
//! \copydoc IVoice::isMuted
virtual bool isMuted() const override
{
@@ -235,6 +238,7 @@ namespace BlackCore
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, 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?
// KB: I would remove this approach, it is potentially unsafe