Ref T730, added voice server setup (settings for server URLs) to context

This commit is contained in:
Klaus Basan
2019-10-08 03:05:45 +02:00
committed by Mat Sutcliffe
parent 2123529fd8
commit d3c0e75248
2 changed files with 23 additions and 3 deletions

View File

@@ -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});

View File

@@ -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<BlackMisc::Audio::TSettings> m_audioSettings { this, &IContextAudio::onChangedAudioSettings };
BlackMisc::CSetting<BlackMisc::Audio::TSettings> m_audioSettings { this, &IContextAudio::onChangedAudioSettings };
BlackMisc::CSetting<BlackMisc::Audio::Settings::TVoiceSetup> m_voiceSettings { this, &IContextAudio::onChangedVoiceSettings };
BlackMisc::CSetting<Audio::TInputDevice> m_inputDeviceSetting { this, &IContextAudio::changeDeviceSettings };
BlackMisc::CSetting<Audio::TOutputDevice> m_outputDeviceSetting { this, &IContextAudio::changeDeviceSettings };