diff --git a/src/blackcore/context/contextaudio.cpp b/src/blackcore/context/contextaudio.cpp index b816e0fd5..e48852ef1 100644 --- a/src/blackcore/context/contextaudio.cpp +++ b/src/blackcore/context/contextaudio.cpp @@ -33,8 +33,11 @@ namespace BlackCore namespace Context { IContextAudio::IContextAudio(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) : - IContext(mode, runtime), m_voiceClient("https://voice1.vatsim.uk", this) + IContext(mode, runtime), m_voiceClient(CVoiceSetup().getAfvVoiceServerUrl(), this) { + const CVoiceSetup vs = m_voiceSettings.getThreadLocal(); + m_voiceClient.updateVoiceServerUrl(vs.getAfvVoiceServerUrl()); + Q_ASSERT_X(CThreadUtils::isApplicationThread(m_voiceClient.thread()), Q_FUNC_INFO, "Should be in main thread"); m_voiceClient.start(); Q_ASSERT_X(m_voiceClient.owner() == this, Q_FUNC_INFO, "Wrong owner"); @@ -178,6 +181,10 @@ namespace BlackCore if (!inputDevice.getName().isEmpty()) { m_inputDeviceSetting.setAndSave(inputDevice.getName()); } if (!outputDevice.getName().isEmpty()) { m_outputDeviceSetting.setAndSave(outputDevice.getName()); } const bool changed = m_voiceClient.restartWithNewDevices(inputDevice, outputDevice); + + const CVoiceSetup vs = m_voiceSettings.getThreadLocal(); + m_voiceClient.updateVoiceServerUrl(vs.getAfvVoiceServerUrl()); + if (changed) { emit this->changedSelectedAudioDevices(this->getCurrentAudioDevices()); @@ -345,6 +352,11 @@ namespace BlackCore this->setVoiceOutputVolume(s.getOutVolume()); } + void IContextAudio::onChangedVoiceSettings() + { + // void + } + void IContextAudio::audioIncreaseVolume(bool enabled) { if (!enabled) { return; } @@ -405,6 +417,9 @@ namespace BlackCore BLACK_VERIFY_X(this->getIContextNetwork(), Q_FUNC_INFO, "Missing network context"); if (to.isConnected() && this->getIContextNetwork()) { + const CVoiceSetup vs = m_voiceSettings.getThreadLocal(); + m_voiceClient.updateVoiceServerUrl(vs.getAfvVoiceServerUrl()); + const CUser connectedUser = this->getIContextNetwork()->getConnectedServer().getUser(); m_voiceClient.connectTo(connectedUser.getId(), connectedUser.getPassword(), connectedUser.getCallsign().asString()); m_voiceClient.startAudio(CAudioDeviceInfo::getDefaultInputDevice(), CAudioDeviceInfo::getDefaultOutputDevice(), {0, 1}); diff --git a/src/blackcore/context/contextaudio.h b/src/blackcore/context/contextaudio.h index 418966199..1a6c50181 100644 --- a/src/blackcore/context/contextaudio.h +++ b/src/blackcore/context/contextaudio.h @@ -24,7 +24,7 @@ #include "blackmisc/audio/audiodeviceinfolist.h" #include "blackmisc/audio/notificationsounds.h" #include "blackmisc/audio/audiosettings.h" -#include "blackmisc/audio/voicesetup.h" +#include "blackmisc/audio/settings/voicesettings.h" #include "blackmisc/audio/ptt.h" #include "blackmisc/aviation/callsignset.h" #include "blackmisc/aviation/comsystem.h" @@ -193,6 +193,9 @@ namespace BlackCore //! Changed audio settings void onChangedAudioSettings(); + //! Changed voice settings + void onChangedVoiceSettings(); + //! Audio increase/decrease volume //! @{ void audioIncreaseVolume(bool enabled); @@ -223,7 +226,9 @@ namespace BlackCore static constexpr int MinUnmuteVolume = 20; //!< minimum volume when unmuted // settings - BlackMisc::CSetting m_audioSettings { this, &IContextAudio::onChangedAudioSettings }; + BlackMisc::CSetting m_audioSettings { this, &IContextAudio::onChangedAudioSettings }; + BlackMisc::CSetting m_voiceSettings { this, &IContextAudio::onChangedVoiceSettings }; + BlackMisc::CSetting m_inputDeviceSetting { this, &IContextAudio::changeDeviceSettings }; BlackMisc::CSetting m_outputDeviceSetting { this, &IContextAudio::changeDeviceSettings };