mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 10:55:32 +08:00
Ref T609, adjusted audio context to support changed COM units and muted transmission if muted in COM unit
This commit is contained in:
committed by
Mat Sutcliffe
parent
90deceae6b
commit
03096f8f7e
@@ -44,6 +44,7 @@ using namespace BlackMisc::Audio;
|
|||||||
using namespace BlackMisc::Input;
|
using namespace BlackMisc::Input;
|
||||||
using namespace BlackMisc::Audio;
|
using namespace BlackMisc::Audio;
|
||||||
using namespace BlackMisc::PhysicalQuantities;
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
|
using namespace BlackMisc::Simulation;
|
||||||
using namespace BlackSound;
|
using namespace BlackSound;
|
||||||
using namespace BlackCore::Vatsim;
|
using namespace BlackCore::Vatsim;
|
||||||
|
|
||||||
@@ -53,6 +54,7 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
CContextAudio::CContextAudio(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) :
|
CContextAudio::CContextAudio(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) :
|
||||||
IContextAudio(mode, runtime),
|
IContextAudio(mode, runtime),
|
||||||
|
CIdentifiable(this),
|
||||||
m_voice(new CVoiceVatlib())
|
m_voice(new CVoiceVatlib())
|
||||||
{
|
{
|
||||||
initVoiceChannels();
|
initVoiceChannels();
|
||||||
@@ -140,12 +142,12 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
m_voice->connectVoice(m_channel1.data(), m_audioMixer.get(), IAudioMixer::InputVoiceChannel1);
|
m_voice->connectVoice(m_channel1.data(), m_audioMixer.get(), IAudioMixer::InputVoiceChannel1);
|
||||||
m_voice->connectVoice(m_channel2.data(), m_audioMixer.get(), IAudioMixer::InputVoiceChannel2);
|
m_voice->connectVoice(m_channel2.data(), m_audioMixer.get(), IAudioMixer::InputVoiceChannel2);
|
||||||
m_voice->connectVoice(m_audioMixer.get(), IAudioMixer::OutputOutputDevice1, m_voiceOutputDevice.get());
|
m_voice->connectVoice(m_audioMixer.get(), IAudioMixer::OutputDevice1, m_voiceOutputDevice.get());
|
||||||
m_voice->connectVoice(m_audioMixer.get(), IAudioMixer::OutputVoiceChannel1, m_channel1.data());
|
m_voice->connectVoice(m_audioMixer.get(), IAudioMixer::OutputVoiceChannel1, m_channel1.data());
|
||||||
m_voice->connectVoice(m_audioMixer.get(), IAudioMixer::OutputVoiceChannel2, m_channel2.data());
|
m_voice->connectVoice(m_audioMixer.get(), IAudioMixer::OutputVoiceChannel2, m_channel2.data());
|
||||||
|
|
||||||
m_audioMixer->makeMixerConnection(IAudioMixer::InputVoiceChannel1, IAudioMixer::OutputOutputDevice1);
|
m_audioMixer->makeMixerConnection(IAudioMixer::InputVoiceChannel1, IAudioMixer::OutputDevice1);
|
||||||
m_audioMixer->makeMixerConnection(IAudioMixer::InputVoiceChannel2, IAudioMixer::OutputOutputDevice2);
|
m_audioMixer->makeMixerConnection(IAudioMixer::InputVoiceChannel2, IAudioMixer::OutputDevice1);
|
||||||
}
|
}
|
||||||
|
|
||||||
CContextAudio::~CContextAudio()
|
CContextAudio::~CContextAudio()
|
||||||
@@ -531,11 +533,11 @@ namespace BlackCore
|
|||||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||||
if (enable)
|
if (enable)
|
||||||
{
|
{
|
||||||
m_audioMixer->makeMixerConnection(IAudioMixer::InputMicrophone, IAudioMixer::OutputOutputDevice1);
|
m_audioMixer->makeMixerConnection(IAudioMixer::InputMicrophone, IAudioMixer::OutputDevice1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_audioMixer->removeMixerConnection(IAudioMixer::InputMicrophone, IAudioMixer::OutputOutputDevice1);
|
m_audioMixer->removeMixerConnection(IAudioMixer::InputMicrophone, IAudioMixer::OutputDevice1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -543,7 +545,7 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
Q_ASSERT(m_audioMixer);
|
Q_ASSERT(m_audioMixer);
|
||||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||||
return m_audioMixer->hasMixerConnection(IAudioMixer::InputMicrophone, IAudioMixer::OutputOutputDevice1);
|
return m_audioMixer->hasMixerConnection(IAudioMixer::InputMicrophone, IAudioMixer::OutputDevice1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CContextAudio::setVoiceSetup(const CVoiceSetup &setup)
|
void CContextAudio::setVoiceSetup(const CVoiceSetup &setup)
|
||||||
@@ -595,9 +597,34 @@ namespace BlackCore
|
|||||||
|
|
||||||
void CContextAudio::setVoiceTransmission(bool enable, COM com)
|
void CContextAudio::setVoiceTransmission(bool enable, COM com)
|
||||||
{
|
{
|
||||||
// FIXME: Use the 'active' channel instead of hardcoded COM1
|
// first apporach of T609 multiple COM
|
||||||
// FIXME: Use com
|
QSharedPointer<IVoiceChannel> voiceChannelCom = nullptr;
|
||||||
Q_UNUSED(com);
|
CComSystem::ComUnit usedUnit = CComSystem::Com1;
|
||||||
|
|
||||||
|
if (com == COM1 && m_voiceChannelMapping.contains(CComSystem::Com1)) { usedUnit = CComSystem::Com1; voiceChannelCom = m_voiceChannelMapping.value(usedUnit); }
|
||||||
|
else if (com == COM2 && m_voiceChannelMapping.contains(CComSystem::Com2)) { usedUnit = CComSystem::Com2; voiceChannelCom = m_voiceChannelMapping.value(usedUnit); }
|
||||||
|
else if (com == COMActive && m_voiceChannelMapping.contains(CComSystem::Com1)) { usedUnit = CComSystem::Com1; voiceChannelCom = m_voiceChannelMapping.value(usedUnit); }
|
||||||
|
else if (com == COMActive && m_voiceChannelMapping.contains(CComSystem::Com2)) { usedUnit = CComSystem::Com2; voiceChannelCom = m_voiceChannelMapping.value(usedUnit); }
|
||||||
|
if (!voiceChannelCom) { return; }
|
||||||
|
IAudioMixer::OutputPort mixerOutputPort = m_voiceChannelOutputPortMapping.value(voiceChannelCom);
|
||||||
|
|
||||||
|
// use values from simulator?
|
||||||
|
if (enable && this->isComIntegratedWithSimulator())
|
||||||
|
{
|
||||||
|
const CComSystem comSystem = this->getOwnComSystem(usedUnit);
|
||||||
|
enable = comSystem.isTransmitEnabled(); // consider muted
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enable)
|
||||||
|
{
|
||||||
|
m_audioMixer->makeMixerConnection(IAudioMixer::InputMicrophone, mixerOutputPort);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_audioMixer->removeMixerConnection(IAudioMixer::InputMicrophone, mixerOutputPort);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** fixme KB 201908 to be removed if the above works
|
||||||
if (!m_voiceChannelMapping.contains(CComSystem::Com1)) { return; }
|
if (!m_voiceChannelMapping.contains(CComSystem::Com1)) { return; }
|
||||||
QSharedPointer<IVoiceChannel> voiceChannelCom1 = m_voiceChannelMapping.value(CComSystem::Com1);
|
QSharedPointer<IVoiceChannel> voiceChannelCom1 = m_voiceChannelMapping.value(CComSystem::Com1);
|
||||||
IAudioMixer::OutputPort mixerOutputPort = m_voiceChannelOutputPortMapping.value(voiceChannelCom1);
|
IAudioMixer::OutputPort mixerOutputPort = m_voiceChannelOutputPortMapping.value(voiceChannelCom1);
|
||||||
@@ -611,6 +638,7 @@ namespace BlackCore
|
|||||||
m_audioMixer->removeMixerConnection(IAudioMixer::InputMicrophone, IAudioMixer::OutputVoiceChannel1);
|
m_audioMixer->removeMixerConnection(IAudioMixer::InputMicrophone, IAudioMixer::OutputVoiceChannel1);
|
||||||
m_audioMixer->removeMixerConnection(IAudioMixer::InputMicrophone, IAudioMixer::OutputVoiceChannel2);
|
m_audioMixer->removeMixerConnection(IAudioMixer::InputMicrophone, IAudioMixer::OutputVoiceChannel2);
|
||||||
}
|
}
|
||||||
|
**/
|
||||||
}
|
}
|
||||||
|
|
||||||
void CContextAudio::setVoiceTransmissionCom1(bool enabled)
|
void CContextAudio::setVoiceTransmissionCom1(bool enabled)
|
||||||
@@ -689,7 +717,7 @@ namespace BlackCore
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} // device name
|
||||||
}
|
}
|
||||||
|
|
||||||
void CContextAudio::onChangedAudioSettings()
|
void CContextAudio::onChangedAudioSettings()
|
||||||
@@ -719,13 +747,14 @@ namespace BlackCore
|
|||||||
if (!this->getIContextOwnAircraft())
|
if (!this->getIContextOwnAircraft())
|
||||||
{
|
{
|
||||||
// context not available
|
// context not available
|
||||||
|
const double defFreq = 122.8;
|
||||||
switch (unit)
|
switch (unit)
|
||||||
{
|
{
|
||||||
case CComSystem::Com1: return CComSystem::getCom1System(122.800, 122.800);
|
case CComSystem::Com1: return CComSystem::getCom1System(defFreq, defFreq);
|
||||||
case CComSystem::Com2: return CComSystem::getCom2System(122.800, 122.800);
|
case CComSystem::Com2: return CComSystem::getCom2System(defFreq, defFreq);
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
return CComSystem::getCom1System(122.800, 122.800);
|
return CComSystem::getCom1System(defFreq, defFreq);
|
||||||
}
|
}
|
||||||
return this->getIContextOwnAircraft()->getOwnComSystem(unit);
|
return this->getIContextOwnAircraft()->getOwnComSystem(unit);
|
||||||
}
|
}
|
||||||
@@ -736,6 +765,27 @@ namespace BlackCore
|
|||||||
return this->getIContextSimulator()->getSimulatorSettings().isComIntegrated();
|
return this->getIContextSimulator()->getSimulatorSettings().isComIntegrated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CContextAudio::xCtxChangedAircraftCockpit(const CSimulatedAircraft &aircraft, const CIdentifier &originator)
|
||||||
|
{
|
||||||
|
if (CIdentifiable::isMyIdentifier(originator)) { return; }
|
||||||
|
const bool integrated = this->isComIntegratedWithSimulator();
|
||||||
|
|
||||||
|
if (integrated)
|
||||||
|
{
|
||||||
|
// set as in cockpit
|
||||||
|
const bool com1Rec = aircraft.getCom1System().isReceiveEnabled();
|
||||||
|
const bool com2Rec = aircraft.getCom2System().isReceiveEnabled();
|
||||||
|
m_audioMixer->makeOrRemoveConnection(IAudioMixer::InputVoiceChannel1, IAudioMixer::OutputDevice1, com1Rec);
|
||||||
|
m_audioMixer->makeOrRemoveConnection(IAudioMixer::InputVoiceChannel2, IAudioMixer::OutputDevice1, com2Rec);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// reset
|
||||||
|
m_audioMixer->makeMixerConnectionIfNotExisting(IAudioMixer::InputVoiceChannel1, IAudioMixer::OutputDevice1);
|
||||||
|
m_audioMixer->makeMixerConnectionIfNotExisting(IAudioMixer::InputVoiceChannel2, IAudioMixer::OutputDevice1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QSharedPointer<IVoiceChannel> CContextAudio::getVoiceChannelBy(const CVoiceRoom &voiceRoom)
|
QSharedPointer<IVoiceChannel> CContextAudio::getVoiceChannelBy(const CVoiceRoom &voiceRoom)
|
||||||
{
|
{
|
||||||
QSharedPointer<IVoiceChannel> voiceChannel;
|
QSharedPointer<IVoiceChannel> voiceChannel;
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include "blackmisc/aviation/comsystem.h"
|
#include "blackmisc/aviation/comsystem.h"
|
||||||
#include "blackmisc/aviation/selcal.h"
|
#include "blackmisc/aviation/selcal.h"
|
||||||
#include "blackmisc/macos/microphoneaccess.h"
|
#include "blackmisc/macos/microphoneaccess.h"
|
||||||
|
#include "blackmisc/identifiable.h"
|
||||||
#include "blackmisc/identifier.h"
|
#include "blackmisc/identifier.h"
|
||||||
#include "blackmisc/network/userlist.h"
|
#include "blackmisc/network/userlist.h"
|
||||||
#include "blackmisc/settingscache.h"
|
#include "blackmisc/settingscache.h"
|
||||||
@@ -62,7 +63,9 @@ namespace BlackCore
|
|||||||
namespace Context
|
namespace Context
|
||||||
{
|
{
|
||||||
//! Audio context implementation
|
//! Audio context implementation
|
||||||
class BLACKCORE_EXPORT CContextAudio : public IContextAudio
|
class BLACKCORE_EXPORT CContextAudio :
|
||||||
|
public IContextAudio,
|
||||||
|
public BlackMisc::CIdentifiable
|
||||||
{
|
{
|
||||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTAUDIO_INTERFACENAME)
|
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTAUDIO_INTERFACENAME)
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -174,6 +177,10 @@ namespace BlackCore
|
|||||||
bool isComIntegratedWithSimulator() const;
|
bool isComIntegratedWithSimulator() const;
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
|
//! Changed cockpit
|
||||||
|
//! \remark cross context
|
||||||
|
void xCtxChangedAircraftCockpit(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const BlackMisc::CIdentifier &originator);
|
||||||
|
|
||||||
//! Voice channel by room
|
//! Voice channel by room
|
||||||
QSharedPointer<IVoiceChannel> getVoiceChannelBy(const BlackMisc::Audio::CVoiceRoom &voiceRoom);
|
QSharedPointer<IVoiceChannel> getVoiceChannelBy(const BlackMisc::Audio::CVoiceRoom &voiceRoom);
|
||||||
|
|
||||||
|
|||||||
@@ -259,6 +259,14 @@ namespace BlackCore
|
|||||||
c = connect(this->getCContextOwnAircraft(), &CContextOwnAircraft::ps_changedModel,
|
c = connect(this->getCContextOwnAircraft(), &CContextOwnAircraft::ps_changedModel,
|
||||||
this->getCContextSimulator(), &CContextSimulator::xCtxChangedOwnAircraftModel);
|
this->getCContextSimulator(), &CContextSimulator::xCtxChangedOwnAircraftModel);
|
||||||
Q_ASSERT(c);
|
Q_ASSERT(c);
|
||||||
|
|
||||||
|
|
||||||
|
// hook up with audio
|
||||||
|
if (this->getIContextAudio())
|
||||||
|
{
|
||||||
|
c = connect(m_contextOwnAircraft, &IContextOwnAircraft::changedAircraftCockpit, this->getCContextAudio(), &CContextAudio::xCtxChangedAircraftCockpit, Qt::QueuedConnection);
|
||||||
|
Q_ASSERT(c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// times
|
// times
|
||||||
@@ -279,8 +287,7 @@ namespace BlackCore
|
|||||||
if (m_contextAudio && m_contextAudio->isUsingImplementingObject())
|
if (m_contextAudio && m_contextAudio->isUsingImplementingObject())
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_contextApplication);
|
Q_ASSERT(m_contextApplication);
|
||||||
Q_ASSERT(m_contextOwnAircraft);
|
c = connect(m_contextApplication, &IContextApplication::fakedSetComVoiceRoom, this->getCContextAudio(), &CContextAudio::setComVoiceRooms, Qt::QueuedConnection);
|
||||||
c = connect(m_contextApplication, &IContextApplication::fakedSetComVoiceRoom, this->getCContextAudio(), &CContextAudio::setComVoiceRooms);
|
|
||||||
Q_ASSERT(c);
|
Q_ASSERT(c);
|
||||||
times.insert("Post setup, connects audio", time.restart());
|
times.insert("Post setup, connects audio", time.restart());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user