debug output of context fixed

This commit is contained in:
Klaus Basan
2015-12-16 02:49:50 +01:00
parent cbf54d0416
commit 41ae580ab4

View File

@@ -80,27 +80,30 @@ namespace BlackCore
CVoiceRoomList CContextAudio::getComVoiceRoomsWithAudioStatus() const CVoiceRoomList CContextAudio::getComVoiceRoomsWithAudioStatus() const
{ {
Q_ASSERT(this->m_voice); Q_ASSERT(this->m_voice);
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
return getComVoiceRooms(); return getComVoiceRooms();
} }
CVoiceRoom CContextAudio::getVoiceRoom(BlackMisc::Aviation::CComSystem::ComUnit comUnitValue, bool withAudioStatus) const CVoiceRoom CContextAudio::getVoiceRoom(BlackMisc::Aviation::CComSystem::ComUnit comUnitValue, bool withAudioStatus) const
{ {
Q_ASSERT(this->m_voice); Q_ASSERT(this->m_voice);
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << withAudioStatus; if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << withAudioStatus; }
auto voiceChannel = m_voiceChannelMapping.value(comUnitValue); auto voiceChannel = m_voiceChannelMapping.value(comUnitValue);
if (voiceChannel) if (voiceChannel)
{
return voiceChannel->getVoiceRoom(); return voiceChannel->getVoiceRoom();
}
else else
{
return CVoiceRoom(); return CVoiceRoom();
}
} }
CVoiceRoomList CContextAudio::getComVoiceRooms() const CVoiceRoomList CContextAudio::getComVoiceRooms() const
{ {
Q_ASSERT(this->m_voice); Q_ASSERT(this->m_voice);
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); auto voiceChannelCom1 = m_voiceChannelMapping.value(BlackMisc::Aviation::CComSystem::Com1);
@@ -131,7 +134,7 @@ namespace BlackCore
void CContextAudio::leaveAllVoiceRooms() void CContextAudio::leaveAllVoiceRooms()
{ {
Q_ASSERT(this->m_voice); Q_ASSERT(this->m_voice);
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;}
m_voiceChannelMapping.clear(); m_voiceChannelMapping.clear();
m_channel1->leaveVoiceRoom(); m_channel1->leaveVoiceRoom();
m_channel2->leaveVoiceRoom(); m_channel2->leaveVoiceRoom();
@@ -142,7 +145,7 @@ namespace BlackCore
CAudioDeviceInfoList CContextAudio::getAudioDevices() const CAudioDeviceInfoList CContextAudio::getAudioDevices() const
{ {
Q_ASSERT(this->m_voice); Q_ASSERT(this->m_voice);
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
CAudioDeviceInfoList devices = this->m_voiceOutputDevice->getOutputDevices(); CAudioDeviceInfoList devices = this->m_voiceOutputDevice->getOutputDevices();
devices = devices.join(this->m_voiceInputDevice->getInputDevices()); devices = devices.join(this->m_voiceInputDevice->getInputDevices());
return devices; return devices;
@@ -151,7 +154,7 @@ namespace BlackCore
CAudioDeviceInfoList CContextAudio::getCurrentAudioDevices() const CAudioDeviceInfoList CContextAudio::getCurrentAudioDevices() const
{ {
Q_ASSERT(this->m_voice); Q_ASSERT(this->m_voice);
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
CAudioDeviceInfoList devices; CAudioDeviceInfoList devices;
devices.push_back(this->m_voiceInputDevice->getCurrentInputDevice()); devices.push_back(this->m_voiceInputDevice->getCurrentInputDevice());
devices.push_back(this->m_voiceOutputDevice->getCurrentOutputDevice()); devices.push_back(this->m_voiceOutputDevice->getCurrentOutputDevice());
@@ -162,7 +165,7 @@ namespace BlackCore
{ {
Q_ASSERT(this->m_voice); Q_ASSERT(this->m_voice);
Q_ASSERT(audioDevice.getType() != CAudioDeviceInfo::Unknown); Q_ASSERT(audioDevice.getType() != CAudioDeviceInfo::Unknown);
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << audioDevice; if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << audioDevice; }
bool changed = false; bool changed = false;
if (audioDevice.getType() == CAudioDeviceInfo::InputDevice) if (audioDevice.getType() == CAudioDeviceInfo::InputDevice)
{ {
@@ -190,6 +193,8 @@ namespace BlackCore
void CContextAudio::setVoiceOutputVolume(int volume) void CContextAudio::setVoiceOutputVolume(int volume)
{ {
Q_ASSERT(m_voiceOutputDevice); Q_ASSERT(m_voiceOutputDevice);
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << volume; }
bool wasMuted = isMuted(); bool wasMuted = isMuted();
bool changed = m_voiceOutputDevice->getOutputVolume() != volume; bool changed = m_voiceOutputDevice->getOutputVolume() != volume;
if (!changed) { return; } if (!changed) { return; }
@@ -207,12 +212,14 @@ namespace BlackCore
int CContextAudio::getVoiceOutputVolume() const int CContextAudio::getVoiceOutputVolume() const
{ {
Q_ASSERT(m_voiceOutputDevice); Q_ASSERT(m_voiceOutputDevice);
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
return m_voiceOutputDevice->getOutputVolume(); return m_voiceOutputDevice->getOutputVolume();
} }
void CContextAudio::setMute(bool muted) void CContextAudio::setMute(bool muted)
{ {
if (this->isMuted() == muted) { return; } // avoid roundtrips / unnecessary signals if (this->isMuted() == muted) { return; } // avoid roundtrips / unnecessary signals
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << muted; }
int newVolume; int newVolume;
if (muted) if (muted)
@@ -240,7 +247,7 @@ namespace BlackCore
bool CContextAudio::isMuted() const bool CContextAudio::isMuted() const
{ {
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
return m_voiceOutputDevice->getOutputVolume() < 1; return m_voiceOutputDevice->getOutputVolume() < 1;
} }
@@ -249,7 +256,7 @@ namespace BlackCore
Q_ASSERT(this->m_voice); Q_ASSERT(this->m_voice);
Q_ASSERT(newRooms.size() == 2); Q_ASSERT(newRooms.size() == 2);
Q_ASSERT(getIContextOwnAircraft()); Q_ASSERT(getIContextOwnAircraft());
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << newRooms; if (m_debugEnabled) {CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << newRooms; }
CVoiceRoomList currentRooms = getComVoiceRooms(); CVoiceRoomList currentRooms = getComVoiceRooms();
CVoiceRoom currentRoomCom1 = currentRooms[0]; CVoiceRoom currentRoomCom1 = currentRooms[0];
@@ -347,6 +354,8 @@ namespace BlackCore
void CContextAudio::setOwnCallsignForRooms(const CCallsign &callsign) void CContextAudio::setOwnCallsignForRooms(const CCallsign &callsign)
{ {
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign; }
if (m_channel1) { m_channel1->setOwnAircraftCallsign(callsign); } if (m_channel1) { m_channel1->setOwnAircraftCallsign(callsign); }
if (m_channel2) { m_channel2->setOwnAircraftCallsign(callsign); } if (m_channel2) { m_channel2->setOwnAircraftCallsign(callsign); }
} }
@@ -354,13 +363,17 @@ namespace BlackCore
CCallsignSet CContextAudio::getRoomCallsigns(BlackMisc::Aviation::CComSystem::ComUnit comUnitValue) const CCallsignSet CContextAudio::getRoomCallsigns(BlackMisc::Aviation::CComSystem::ComUnit comUnitValue) const
{ {
Q_ASSERT(this->m_voice); Q_ASSERT(this->m_voice);
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
auto voiceChannel = m_voiceChannelMapping.value(comUnitValue); auto voiceChannel = m_voiceChannelMapping.value(comUnitValue);
if (voiceChannel) if (voiceChannel)
{
return voiceChannel->getVoiceRoomCallsigns(); return voiceChannel->getVoiceRoomCallsigns();
}
else else
{
return CCallsignSet(); return CCallsignSet();
}
} }
Network::CUserList CContextAudio::getRoomUsers(BlackMisc::Aviation::CComSystem::ComUnit comUnit) const Network::CUserList CContextAudio::getRoomUsers(BlackMisc::Aviation::CComSystem::ComUnit comUnit) const
@@ -368,29 +381,23 @@ namespace BlackCore
Q_ASSERT(this->m_voice); Q_ASSERT(this->m_voice);
Q_ASSERT(this->getRuntime()); Q_ASSERT(this->getRuntime());
if (!this->getRuntime()->getIContextNetwork()) return Network::CUserList(); if (!this->getRuntime()->getIContextNetwork()) return Network::CUserList();
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
return this->getIContextNetwork()->getUsersForCallsigns(this->getRoomCallsigns(comUnit)); return this->getIContextNetwork()->getUsersForCallsigns(this->getRoomCallsigns(comUnit));
} }
/*
* SELCAL tone
*/
void CContextAudio::playSelcalTone(const CSelcal &selcal) const void CContextAudio::playSelcalTone(const CSelcal &selcal) const
{ {
Q_ASSERT(this->m_voice); Q_ASSERT(this->m_voice);
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << selcal; if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << selcal; }
CAudioDeviceInfo outputDevice = m_voiceOutputDevice->getCurrentOutputDevice(); CAudioDeviceInfo outputDevice = m_voiceOutputDevice->getCurrentOutputDevice();
CSoundGenerator::playSelcal(90, selcal, outputDevice); CSoundGenerator::playSelcal(90, selcal, outputDevice);
} }
/*
* Notification
*/
void CContextAudio::playNotification(CNotificationSounds::Notification notification, bool considerSettings) const void CContextAudio::playNotification(CNotificationSounds::Notification notification, bool considerSettings) const
{ {
Q_ASSERT(this->m_voice); Q_ASSERT(this->m_voice);
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << notification; if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << notification; }
bool play = !considerSettings || m_audioSettings.get().getNotificationFlag(notification); bool play = !considerSettings || m_audioSettings.get().getNotificationFlag(notification);
if (play) if (play)
@@ -399,22 +406,16 @@ namespace BlackCore
} }
} }
/*
* Notification
*/
void CContextAudio::ps_initNotificationSounds() void CContextAudio::ps_initNotificationSounds()
{ {
// not possible in own thread // not possible in own thread
CSoundGenerator::playNotificationSound(0, CNotificationSounds::NotificationsLoadSounds); CSoundGenerator::playNotificationSound(0, CNotificationSounds::NotificationsLoadSounds);
} }
/*
* Audio loopback
*/
void CContextAudio::enableAudioLoopback(bool enable) void CContextAudio::enableAudioLoopback(bool enable)
{ {
Q_ASSERT(this->m_audioMixer); Q_ASSERT(this->m_audioMixer);
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::OutputOutputDevice1);
@@ -474,9 +475,6 @@ namespace BlackCore
else m_audioMixer->removeMixerConnection(IAudioMixer::InputMicrophone, IAudioMixer::OutputVoiceChannel1); else m_audioMixer->removeMixerConnection(IAudioMixer::InputMicrophone, IAudioMixer::OutputVoiceChannel1);
} }
/*
* Connection status changed
*/
void CContextAudio::ps_connectionStatusChanged(BlackCore::IVoiceChannel::ConnectionStatus oldStatus, void CContextAudio::ps_connectionStatusChanged(BlackCore::IVoiceChannel::ConnectionStatus oldStatus,
BlackCore::IVoiceChannel::ConnectionStatus newStatus) BlackCore::IVoiceChannel::ConnectionStatus newStatus)
{ {