Check which voice channel is allocated to COM1

ref T328
This commit is contained in:
Roland Winklmeier
2018-09-06 11:20:18 +02:00
committed by Klaus Basan
parent dbbc459dbc
commit 1e16203d04
2 changed files with 22 additions and 7 deletions

View File

@@ -9,7 +9,6 @@
#include "blackcore/audiodevice.h" #include "blackcore/audiodevice.h"
#include "blackcore/audiomixer.h"
#include "blackcore/context/contextaudioimpl.h" #include "blackcore/context/contextaudioimpl.h"
#include "blackcore/context/contextnetwork.h" #include "blackcore/context/contextnetwork.h"
#include "blackcore/context/contextownaircraft.h" #include "blackcore/context/contextownaircraft.h"
@@ -88,6 +87,9 @@ namespace BlackCore
m_unusedVoiceChannels.push_back(m_channel1); m_unusedVoiceChannels.push_back(m_channel1);
m_unusedVoiceChannels.push_back(m_channel2); m_unusedVoiceChannels.push_back(m_channel2);
m_voiceChannelOutputPortMapping[m_channel1] = IAudioMixer::OutputVoiceChannel1;
m_voiceChannelOutputPortMapping[m_channel2] = IAudioMixer::OutputVoiceChannel2;
m_selcalPlayer = new CSelcalPlayer(QAudioDeviceInfo::defaultOutputDevice(), this); m_selcalPlayer = new CSelcalPlayer(QAudioDeviceInfo::defaultOutputDevice(), this);
changeDeviceSettings(); changeDeviceSettings();
@@ -134,7 +136,7 @@ namespace BlackCore
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
CVoiceRoomList voiceRoomList; CVoiceRoomList voiceRoomList;
auto voiceChannelCom1 = m_voiceChannelMapping.value(BlackMisc::Aviation::CComSystem::Com1); QSharedPointer<IVoiceChannel> voiceChannelCom1 = m_voiceChannelMapping.value(BlackMisc::Aviation::CComSystem::Com1);
if (voiceChannelCom1) if (voiceChannelCom1)
{ {
CVoiceRoom room = voiceChannelCom1->getVoiceRoom(); CVoiceRoom room = voiceChannelCom1->getVoiceRoom();
@@ -145,7 +147,7 @@ namespace BlackCore
voiceRoomList.push_back(CVoiceRoom()); voiceRoomList.push_back(CVoiceRoom());
} }
auto voiceChannelCom2 = m_voiceChannelMapping.value(BlackMisc::Aviation::CComSystem::Com2); QSharedPointer<IVoiceChannel> voiceChannelCom2 = m_voiceChannelMapping.value(BlackMisc::Aviation::CComSystem::Com2);
if (voiceChannelCom2) if (voiceChannelCom2)
{ {
CVoiceRoom room = voiceChannelCom2->getVoiceRoom(); CVoiceRoom room = voiceChannelCom2->getVoiceRoom();
@@ -314,7 +316,7 @@ namespace BlackCore
// changed rooms? But only compare on "URL", not status as connected etc. // changed rooms? But only compare on "URL", not status as connected etc.
if (currentRoomCom1.getVoiceRoomUrl() != newRoomCom1.getVoiceRoomUrl()) if (currentRoomCom1.getVoiceRoomUrl() != newRoomCom1.getVoiceRoomUrl())
{ {
auto oldVoiceChannel = m_voiceChannelMapping.value(BlackMisc::Aviation::CComSystem::Com1); QSharedPointer<IVoiceChannel> oldVoiceChannel = m_voiceChannelMapping.value(BlackMisc::Aviation::CComSystem::Com1);
if (oldVoiceChannel) if (oldVoiceChannel)
{ {
m_voiceChannelMapping.remove(BlackMisc::Aviation::CComSystem::Com1); m_voiceChannelMapping.remove(BlackMisc::Aviation::CComSystem::Com1);
@@ -333,7 +335,7 @@ namespace BlackCore
if (newRoomCom1.isValid()) if (newRoomCom1.isValid())
{ {
auto newVoiceChannel = getVoiceChannelBy(newRoomCom1); QSharedPointer<IVoiceChannel> newVoiceChannel = getVoiceChannelBy(newRoomCom1);
newVoiceChannel->setOwnAircraftCallsign(ownCallsign); newVoiceChannel->setOwnAircraftCallsign(ownCallsign);
bool inUse = m_voiceChannelMapping.key(newVoiceChannel); bool inUse = m_voiceChannelMapping.key(newVoiceChannel);
m_voiceChannelMapping.insert(BlackMisc::Aviation::CComSystem::Com1, newVoiceChannel); m_voiceChannelMapping.insert(BlackMisc::Aviation::CComSystem::Com1, newVoiceChannel);
@@ -514,8 +516,19 @@ namespace BlackCore
void CContextAudio::ps_setVoiceTransmission(bool enable) void CContextAudio::ps_setVoiceTransmission(bool enable)
{ {
// FIXME: Use the 'active' channel instead of hardcoded COM1 // FIXME: Use the 'active' channel instead of hardcoded COM1
if (enable) m_audioMixer->makeMixerConnection(IAudioMixer::InputMicrophone, IAudioMixer::OutputVoiceChannel1); if (!m_voiceChannelMapping.contains(BlackMisc::Aviation::CComSystem::Com1)) { return; }
else m_audioMixer->removeMixerConnection(IAudioMixer::InputMicrophone, IAudioMixer::OutputVoiceChannel1); QSharedPointer<IVoiceChannel> voiceChannelCom1 = m_voiceChannelMapping.value(BlackMisc::Aviation::CComSystem::Com1);
IAudioMixer::OutputPort mixerOutputPort = m_voiceChannelOutputPortMapping.value(voiceChannelCom1);
if (enable)
{
m_audioMixer->makeMixerConnection(IAudioMixer::InputMicrophone, mixerOutputPort);
}
else
{
// Remove for both output ports, just in case.
m_audioMixer->removeMixerConnection(IAudioMixer::InputMicrophone, IAudioMixer::OutputVoiceChannel1);
m_audioMixer->removeMixerConnection(IAudioMixer::InputMicrophone, IAudioMixer::OutputVoiceChannel2);
}
} }
void CContextAudio::ps_connectionStatusChanged(BlackCore::IVoiceChannel::ConnectionStatus oldStatus, void CContextAudio::ps_connectionStatusChanged(BlackCore::IVoiceChannel::ConnectionStatus oldStatus,

View File

@@ -18,6 +18,7 @@
#include "blackcore/corefacadeconfig.h" #include "blackcore/corefacadeconfig.h"
#include "blackcore/audio/audiosettings.h" #include "blackcore/audio/audiosettings.h"
#include "blackcore/voicechannel.h" #include "blackcore/voicechannel.h"
#include "blackcore/audiomixer.h"
#include "blackmisc/audio/audiodeviceinfolist.h" #include "blackmisc/audio/audiodeviceinfolist.h"
#include "blackmisc/audio/notificationsounds.h" #include "blackmisc/audio/notificationsounds.h"
#include "blackmisc/audio/voiceroom.h" #include "blackmisc/audio/voiceroom.h"
@@ -154,6 +155,7 @@ namespace BlackCore
QList<QSharedPointer<IVoiceChannel>> m_unusedVoiceChannels; QList<QSharedPointer<IVoiceChannel>> m_unusedVoiceChannels;
QHash<BlackMisc::Aviation::CComSystem::ComUnit, QSharedPointer<IVoiceChannel>> m_voiceChannelMapping; QHash<BlackMisc::Aviation::CComSystem::ComUnit, QSharedPointer<IVoiceChannel>> m_voiceChannelMapping;
QHash<QSharedPointer<IVoiceChannel>, IAudioMixer::OutputPort> m_voiceChannelOutputPortMapping;
BlackSound::CSelcalPlayer *m_selcalPlayer = nullptr; BlackSound::CSelcalPlayer *m_selcalPlayer = nullptr;
// settings // settings