diff --git a/src/blackcore/context/contextaudio.cpp b/src/blackcore/context/contextaudio.cpp index a027471e1..b37efa118 100644 --- a/src/blackcore/context/contextaudio.cpp +++ b/src/blackcore/context/contextaudio.cpp @@ -46,6 +46,11 @@ namespace BlackCore // void } + void IContextAudio::onChangedLocalDevices(const CAudioDeviceInfoList &devices) + { + this->registerDevices(devices); + } + const QString &IContextAudio::InterfaceName() { static const QString s(BLACKCORE_CONTEXTAUDIO_INTERFACENAME); @@ -131,6 +136,7 @@ namespace BlackCore { if (!myself || !sApp || sApp->isShuttingDown()) { return; } myself->onChangedAudioSettings(); + myself->onChangedLocalDevices(m_activeLocalDevices); }); } @@ -177,6 +183,13 @@ namespace BlackCore connect(m_voiceClient, &CAfvClient::startedAudio, this, &CContextAudioBase::startedAudio, Qt::QueuedConnection); connect(m_voiceClient, &CAfvClient::stoppedAudio, this, &CContextAudioBase::stoppedAudio, Qt::QueuedConnection); connect(m_voiceClient, &CAfvClient::ptt, this, &CContextAudioBase::ptt, Qt::QueuedConnection); + + const CAudioDeviceInfoList devices = CAudioDeviceInfoList::allDevices(); + if (devices != m_activeLocalDevices) + { + m_activeLocalDevices = devices; + emit this->changedLocalAudioDevices(devices); + } } void CContextAudioBase::terminateVoiceClient() diff --git a/src/blackcore/context/contextaudio.h b/src/blackcore/context/contextaudio.h index 17c28b5cd..c8092bd08 100644 --- a/src/blackcore/context/contextaudio.h +++ b/src/blackcore/context/contextaudio.h @@ -105,6 +105,9 @@ namespace BlackCore protected: //! Constructor IContextAudio(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime); + + //! Devices have been changed + void onChangedLocalDevices(const BlackMisc::Audio::CAudioDeviceInfoList &devices); }; //! Audio context interface @@ -240,7 +243,7 @@ namespace BlackCore void changedMute(bool muted); //! Changed audio devices (e.g. device enabled/disable) - void changedAudioDevices(const BlackMisc::Audio::CAudioDeviceInfoList &devices); + void changedLocalAudioDevices(const BlackMisc::Audio::CAudioDeviceInfoList &devices); //! Audio started with devices void startedAudio(const BlackMisc::Audio::CAudioDeviceInfo &input, const BlackMisc::Audio::CAudioDeviceInfo &output); @@ -320,6 +323,7 @@ namespace BlackCore // AFV Afv::Clients::CAfvClient *m_voiceClient = nullptr; bool m_winCoInitialized = false; + BlackMisc::Audio::CAudioDeviceInfoList m_activeLocalDevices; // Players BlackSound::CSelcalPlayer *m_selcalPlayer = nullptr; diff --git a/src/blackcore/context/contextaudioimpl.cpp b/src/blackcore/context/contextaudioimpl.cpp index 727a2b4d1..288f530cc 100644 --- a/src/blackcore/context/contextaudioimpl.cpp +++ b/src/blackcore/context/contextaudioimpl.cpp @@ -25,7 +25,7 @@ namespace BlackCore CContextAudio::CContextAudio(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) : CContextAudioBase(mode, runtime) { - // void + connect(this, &CContextAudio::changedLocalAudioDevices, this, &CContextAudio::onChangedLocalDevices, Qt::QueuedConnection); } CContextAudio *CContextAudio::registerWithDBus(CDBusServer *server) diff --git a/src/blackcore/context/contextaudioproxy.cpp b/src/blackcore/context/contextaudioproxy.cpp index 1748f6b82..ce6aba180 100644 --- a/src/blackcore/context/contextaudioproxy.cpp +++ b/src/blackcore/context/contextaudioproxy.cpp @@ -32,6 +32,8 @@ namespace BlackCore { m_dBusInterface = new CGenericDBusInterface(serviceName, IContextAudio::ObjectPath(), IContextAudio::InterfaceName(), connection, this); this->relaySignals(serviceName, connection); + + connect(this, &CContextAudioProxy::changedLocalAudioDevices, this, &CContextAudioProxy::onChangedLocalDevices, Qt::QueuedConnection); } void CContextAudioProxy::unitTestRelaySignals() @@ -74,7 +76,7 @@ namespace BlackCore "changedMute", this, SIGNAL(changedMute(bool))); Q_ASSERT(s); s = connection.connect(serviceName, IContextAudio::ObjectPath(), IContextAudio::InterfaceName(), - "changedAudioDevices", this, SIGNAL(changedAudioDevices(BlackMisc::Audio::CAudioDeviceInfoList))); + "changedLocalAudioDevices", this, SIGNAL(changedLocalAudioDevices(BlackMisc::Audio::CAudioDeviceInfoList))); **/ this->relayBaseClassSignals(serviceName, connection, IContextAudio::ObjectPath(), IContextAudio::InterfaceName());