mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +08:00
Ref T565, "canTalk" function in audio context
This commit is contained in:
committed by
Mat Sutcliffe
parent
d8d4fdf766
commit
ee4d498733
@@ -112,6 +112,9 @@ namespace BlackCore
|
||||
//! Get voice rooms for COM1, COM2:
|
||||
virtual BlackMisc::Audio::CVoiceRoomList getComVoiceRoomsWithAudioStatus() const = 0;
|
||||
|
||||
//! Can talk in any voice room
|
||||
virtual bool canTalk() const = 0;
|
||||
|
||||
//! Get voice rooms for COM1, COM2, but without latest audio status
|
||||
virtual BlackMisc::Audio::CVoiceRoomList getComVoiceRooms() const = 0;
|
||||
|
||||
|
||||
@@ -32,20 +32,27 @@ namespace BlackCore
|
||||
CContextAudioEmpty(CCoreFacade *runtime) : IContextAudio(CCoreFacadeConfig::NotUsed, runtime) {}
|
||||
|
||||
public slots:
|
||||
//! \copydoc IContextAudio::getComVoiceRooms()
|
||||
//! \copydoc IContextAudio::getComVoiceRooms
|
||||
virtual BlackMisc::Audio::CVoiceRoomList getComVoiceRooms() const override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::Audio::CVoiceRoomList();
|
||||
}
|
||||
|
||||
//! \copydoc IContextAudio::getComVoiceRoomsWithAudioStatus()
|
||||
//! \copydoc IContextAudio::getComVoiceRoomsWithAudioStatus
|
||||
virtual BlackMisc::Audio::CVoiceRoomList getComVoiceRoomsWithAudioStatus() const override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::Audio::CVoiceRoomList();
|
||||
}
|
||||
|
||||
//! \copydoc IContextAudio::canTalk
|
||||
virtual bool canTalk() const override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
|
||||
//! \copydoc IContextAudio::getVoiceRoom
|
||||
virtual BlackMisc::Audio::CVoiceRoom getVoiceRoom(BlackMisc::Aviation::CComSystem::ComUnit comUnitValue, bool withAudioStatus) const override
|
||||
{
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace BlackCore
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
CVoiceRoomList voiceRoomList;
|
||||
|
||||
QSharedPointer<IVoiceChannel> voiceChannelCom1 = m_voiceChannelMapping.value(BlackMisc::Aviation::CComSystem::Com1);
|
||||
QSharedPointer<IVoiceChannel> voiceChannelCom1 = m_voiceChannelMapping.value(CComSystem::Com1);
|
||||
if (voiceChannelCom1)
|
||||
{
|
||||
CVoiceRoom room = voiceChannelCom1->getVoiceRoom();
|
||||
@@ -138,7 +138,7 @@ namespace BlackCore
|
||||
voiceRoomList.push_back(CVoiceRoom());
|
||||
}
|
||||
|
||||
QSharedPointer<IVoiceChannel> voiceChannelCom2 = m_voiceChannelMapping.value(BlackMisc::Aviation::CComSystem::Com2);
|
||||
QSharedPointer<IVoiceChannel> voiceChannelCom2 = m_voiceChannelMapping.value(CComSystem::Com2);
|
||||
if (voiceChannelCom2)
|
||||
{
|
||||
CVoiceRoom room = voiceChannelCom2->getVoiceRoom();
|
||||
@@ -152,6 +152,12 @@ namespace BlackCore
|
||||
return voiceRoomList;
|
||||
}
|
||||
|
||||
bool CContextAudio::canTalk() const
|
||||
{
|
||||
const CVoiceRoomList rooms = this->getComVoiceRoomsWithAudioStatus();
|
||||
return rooms.countCanTalkTo() > 0;
|
||||
}
|
||||
|
||||
void CContextAudio::leaveAllVoiceRooms()
|
||||
{
|
||||
Q_ASSERT(m_voice);
|
||||
@@ -295,9 +301,9 @@ namespace BlackCore
|
||||
Q_ASSERT(getIContextOwnAircraft());
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << newRooms; }
|
||||
|
||||
CVoiceRoomList currentRooms = this->getComVoiceRooms();
|
||||
CVoiceRoom currentRoomCom1 = currentRooms[0];
|
||||
CVoiceRoom currentRoomCom2 = currentRooms[1];
|
||||
const CVoiceRoomList currentRooms = this->getComVoiceRooms();
|
||||
const CVoiceRoom currentRoomCom1 = currentRooms[0];
|
||||
const CVoiceRoom currentRoomCom2 = currentRooms[1];
|
||||
CVoiceRoom newRoomCom1 = newRooms[0];
|
||||
CVoiceRoom newRoomCom2 = newRooms[1];
|
||||
const CCallsign ownCallsign(this->getIContextOwnAircraft()->getOwnAircraft().getCallsign());
|
||||
@@ -372,7 +378,7 @@ namespace BlackCore
|
||||
newVoiceChannel->setOwnAircraftCallsign(ownCallsign);
|
||||
newVoiceChannel->setUserId(id);
|
||||
bool inUse = m_voiceChannelMapping.values().contains(newVoiceChannel);
|
||||
m_voiceChannelMapping.insert(BlackMisc::Aviation::CComSystem::Com2, newVoiceChannel);
|
||||
m_voiceChannelMapping.insert(CComSystem::Com2, newVoiceChannel);
|
||||
|
||||
// If the voice channel is not used by anybody else
|
||||
if (!inUse)
|
||||
@@ -392,7 +398,7 @@ namespace BlackCore
|
||||
Q_UNUSED(changed);
|
||||
}
|
||||
|
||||
CCallsignSet CContextAudio::getRoomCallsigns(BlackMisc::Aviation::CComSystem::ComUnit comUnitValue) const
|
||||
CCallsignSet CContextAudio::getRoomCallsigns(CComSystem::ComUnit comUnitValue) const
|
||||
{
|
||||
Q_ASSERT(m_voice);
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
@@ -401,7 +407,7 @@ namespace BlackCore
|
||||
return voiceChannel ? voiceChannel->getVoiceRoomCallsigns() : CCallsignSet();
|
||||
}
|
||||
|
||||
Network::CUserList CContextAudio::getRoomUsers(BlackMisc::Aviation::CComSystem::ComUnit comUnit) const
|
||||
Network::CUserList CContextAudio::getRoomUsers(CComSystem::ComUnit comUnit) const
|
||||
{
|
||||
Q_ASSERT(m_voice);
|
||||
Q_ASSERT(this->getRuntime());
|
||||
@@ -434,8 +440,18 @@ namespace BlackCore
|
||||
Q_ASSERT(m_voice);
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << notification; }
|
||||
|
||||
const bool play = !considerSettings || m_audioSettings.getThreadLocal().isNotificationFlagSet(notification);
|
||||
if (play) { CSoundGenerator::playNotificationSound(90, notification); }
|
||||
const CSettings settings = m_audioSettings.getThreadLocal();
|
||||
const bool play = !considerSettings || settings.isNotificationFlagSet(notification);
|
||||
if (!play) { return; }
|
||||
if (notification == CNotificationSounds::PTTClick && (considerSettings && settings.noAudioTransmission()))
|
||||
{
|
||||
if (!this->canTalk())
|
||||
{
|
||||
// warning sound
|
||||
notification = CNotificationSounds::NotificationNoAudioTransmission;
|
||||
}
|
||||
}
|
||||
CSoundGenerator::playNotificationSound(90, notification);
|
||||
}
|
||||
|
||||
void CContextAudio::initNotificationSounds()
|
||||
|
||||
@@ -77,6 +77,7 @@ namespace BlackCore
|
||||
//! @{
|
||||
virtual BlackMisc::Audio::CVoiceRoomList getComVoiceRooms() const override;
|
||||
virtual BlackMisc::Audio::CVoiceRoomList getComVoiceRoomsWithAudioStatus() const override;
|
||||
virtual bool canTalk() const override;
|
||||
virtual BlackMisc::Audio::CVoiceRoom getVoiceRoom(BlackMisc::Aviation::CComSystem::ComUnit comUnitValue, bool withAudioStatus) const override;
|
||||
virtual void setComVoiceRooms(const BlackMisc::Audio::CVoiceRoomList &newRooms) override;
|
||||
virtual BlackMisc::Aviation::CCallsignSet getRoomCallsigns(BlackMisc::Aviation::CComSystem::ComUnit comUnitValue) const override;
|
||||
|
||||
@@ -105,6 +105,11 @@ namespace BlackCore
|
||||
return this->m_dBusInterface->callDBusRet<CVoiceRoomList>(QLatin1String("getComVoiceRoomsWithAudioStatus"));
|
||||
}
|
||||
|
||||
bool CContextAudioProxy::canTalk() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<bool>(QLatin1String("canTalk"));
|
||||
}
|
||||
|
||||
CVoiceRoomList CContextAudioProxy::getComVoiceRooms() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<CVoiceRoomList>(QLatin1String("getComVoiceRooms"));
|
||||
|
||||
@@ -65,6 +65,7 @@ namespace BlackCore
|
||||
//! @{
|
||||
virtual BlackMisc::Audio::CVoiceRoomList getComVoiceRooms() const override;
|
||||
virtual BlackMisc::Audio::CVoiceRoomList getComVoiceRoomsWithAudioStatus() const override;
|
||||
virtual bool canTalk() const override;
|
||||
virtual BlackMisc::Audio::CVoiceRoom getVoiceRoom(BlackMisc::Aviation::CComSystem::ComUnit comUnitValue, bool withAudioStatus) const override;
|
||||
virtual void setComVoiceRooms(const BlackMisc::Audio::CVoiceRoomList &voiceRooms) override;
|
||||
virtual BlackMisc::Aviation::CCallsignSet getRoomCallsigns(BlackMisc::Aviation::CComSystem::ComUnit comUnitValue) const override;
|
||||
|
||||
Reference in New Issue
Block a user