Refactored inheritance hierarchy of ContextAudio (former ContextVoice)

refs #85
This commit is contained in:
Roland Winklmeier
2014-03-08 16:57:33 +01:00
parent 1e8a2a5b01
commit 33aee8cb12
15 changed files with 461 additions and 359 deletions

View File

@@ -1,7 +1,7 @@
#include "tool.h"
#include "blackcore/coreruntime.h"
#include "blackcore/context_network.h"
#include "blackcore/context_voice.h"
#include "blackcore/context_audio.h"
#include "blackmisc/valuemap.h"
#include "blackmisc/avallclasses.h"
#include "blackmisc/pqallquantities.h"
@@ -43,7 +43,7 @@ namespace BlackMiscTest
while (line != "x")
{
const BlackCore::IContextNetwork *networkContext = core->getIContextNetwork();
const BlackCore::IContextVoice *voiceContext = core->getIContextVoice();
const BlackCore::IContextAudio *audioContext = core->getIContextAudio();
// display current status
qDebug() << "-------------";
@@ -95,7 +95,7 @@ namespace BlackMiscTest
{
qDebug() << "-------------";
qDebug() << "voice rooms";
qDebug() << voiceContext->getComVoiceRooms();
qDebug() << audioContext->getComVoiceRooms();
}
}

View File

@@ -35,8 +35,8 @@ MainWindow::MainWindow(GuiModes::WindowMode windowMode, QWidget *parent) :
m_modelAllUsers(nullptr), m_modelUsersVoiceCom1(nullptr), m_modelUsersVoiceCom2(nullptr), m_modelSettingsHotKeys(nullptr),
// contexts and runtime
m_coreMode(GuiModes::CoreExternal),
m_coreAvailable(false), m_contextNetworkAvailable(false), m_contextVoiceAvailable(false),
m_contextApplication(nullptr), m_contextNetwork(nullptr), m_contextVoice(nullptr), m_contextSettings(nullptr),
m_coreAvailable(false), m_contextNetworkAvailable(false), m_contextAudioAvailable(false),
m_contextApplication(nullptr), m_contextNetwork(nullptr), m_contextAudio(nullptr), m_contextSettings(nullptr),
m_contextSimulator(nullptr),
// timers
m_timerUpdateAtcStationsOnline(nullptr), m_timerUpdateAircraftsInRange(nullptr), m_timerUpdateUsers(nullptr),
@@ -97,10 +97,10 @@ void MainWindow::gracefulShutdown()
{
if (this->m_contextNetwork->isConnected())
{
if (this->m_contextVoiceAvailable)
if (this->m_contextAudioAvailable)
{
this->m_contextVoice->leaveAllVoiceRooms();
this->m_contextVoice->disconnect(this); // break down signal / slots
this->m_contextAudio->leaveAllVoiceRooms();
this->m_contextAudio->disconnect(this); // break down signal / slots
}
this->m_contextNetwork->disconnectFromNetwork();
this->m_contextNetwork->disconnect(this); // avoid any status update signals, etc.
@@ -209,7 +209,7 @@ void MainWindow::toggleNetworkConnection()
// send latest aircraft to network/voice
this->m_contextNetwork->setOwnAircraft(this->m_ownAircraft);
if (this->m_contextVoiceAvailable) this->m_contextVoice->setOwnAircraft(this->m_ownAircraft);
if (this->m_contextAudioAvailable) this->m_contextAudio->setOwnAircraft(this->m_ownAircraft);
// Login is based on setting current server
INetwork::LoginMode mode = INetwork::LoginNormal;
@@ -229,7 +229,7 @@ void MainWindow::toggleNetworkConnection()
{
// disconnect from network
this->stopUpdateTimers(); // stop update timers, to avoid updates during disconnecting (a short time frame)
if (this->m_contextVoiceAvailable) this->m_contextVoice->leaveAllVoiceRooms();
if (this->m_contextAudioAvailable) this->m_contextAudio->leaveAllVoiceRooms();
msgs = this->m_contextNetwork->disconnectFromNetwork();
}
if (!msgs.isEmpty()) this->displayStatusMessages(msgs);
@@ -246,11 +246,11 @@ bool MainWindow::isContextNetworkAvailableCheck()
}
/*
* Is the voice context available?
* Is the audio context available?
*/
bool MainWindow::isContextVoiceAvailableCheck()
bool MainWindow::isContextAudioAvailableCheck()
{
if (this->m_contextVoiceAvailable) return true;
if (this->m_contextAudioAvailable) return true;
this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeCore, CStatusMessage::SeverityError, "Voice context not available"));
return false;
}
@@ -375,7 +375,7 @@ void MainWindow::setContextAvailability()
qint64 t = QDateTime::currentMSecsSinceEpoch();
this->m_coreAvailable = this->m_contextApplication->ping(t) == t;
this->m_contextNetworkAvailable = this->m_coreAvailable || this->m_contextNetwork->usingLocalObjects();
this->m_contextVoiceAvailable = this->m_coreAvailable || this->m_contextVoice->usingLocalObjects();
this->m_contextAudioAvailable = this->m_coreAvailable || this->m_contextAudio->usingLocalObjects();
}
/*
@@ -409,9 +409,9 @@ void MainWindow::updateGuiStatusInformation()
// handle voice, mute
QString voice("unavailable");
if (this->m_contextVoiceAvailable)
if (this->m_contextAudioAvailable)
{
voice = this->m_contextVoice->usingLocalObjects() ? "local" : now;
voice = this->m_contextAudio->usingLocalObjects() ? "local" : now;
this->ui->pb_SoundMute->setEnabled(true);
}
else
@@ -422,7 +422,7 @@ void MainWindow::updateGuiStatusInformation()
// update status fields
this->ui->le_StatusNetworkContext->setText(network);
this->ui->le_StatusVoiceContext->setText(voice);
this->ui->le_StatusAudioContext->setText(voice);
this->ui->cb_StatusWithDBus->setCheckState(this->m_coreMode ? Qt::Checked : Qt::Unchecked);
// Connected button

View File

@@ -12,7 +12,7 @@
#include "infowindow.h"
#include "guimodeenums.h"
#include "blackcore/context_voice.h"
#include "blackcore/context_audio.h"
#include "blackcore/context_network.h"
#include "blackcore/context_settings_interface.h"
#include "blackcore/context_application.h"
@@ -25,6 +25,7 @@
#include "blackgui/statusmessagelistmodel.h"
#include "blackgui/keyboardkeylistmodel.h"
#include "blackmisc/nwtextmessage.h"
#include "blacksound/soundgenerator.h"
#include <QMainWindow>
#include <QTextEdit>
#include <QTableView>
@@ -129,11 +130,11 @@ private:
GuiModes::CoreMode m_coreMode;
bool m_coreAvailable;
bool m_contextNetworkAvailable;
bool m_contextVoiceAvailable;
bool m_contextAudioAvailable;
QScopedPointer<BlackCore::CCoreRuntime> m_coreRuntime; /*!< runtime, if working with local core */
BlackCore::IContextApplication *m_contextApplication; /*!< overall application state */
BlackCore::IContextNetwork *m_contextNetwork;
BlackCore::IContextVoice *m_contextVoice;
BlackCore::IContextAudio *m_contextAudio;
BlackCore::IContextSettings *m_contextSettings;
BlackCore::IContextSimulator *m_contextSimulator;
BlackMisc::Aviation::CAircraft m_ownAircraft; /*!< own aircraft's state */
@@ -203,7 +204,7 @@ private:
/*!
* \brief Context voice availability check, otherwise status message
*/
bool isContextVoiceAvailableCheck();
bool isContextAudioAvailableCheck();
/*!
* \brief Own cockpit, update from context

View File

@@ -523,7 +523,7 @@ QStatusBar QLabel {
</widget>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="le_StatusVoiceContext">
<widget class="QLineEdit" name="le_StatusAudioContext">
<property name="readOnly">
<bool>true</bool>
</property>
@@ -3131,7 +3131,7 @@ QStatusBar QLabel {
<tabstops>
<tabstop>cb_StatusWithDBus</tabstop>
<tabstop>le_StatusNetworkContext</tabstop>
<tabstop>le_StatusVoiceContext</tabstop>
<tabstop>le_StatusAudioContext</tabstop>
<tabstop>tv_StatusMessages</tabstop>
<tabstop>le_CommandLineInput</tabstop>
<tabstop>tw_AtcStations</tabstop>

View File

@@ -130,11 +130,11 @@ void MainWindow::updateCockpitFromContext()
//
// Voice room override
//
if (this->m_contextVoiceAvailable)
if (this->m_contextAudioAvailable)
{
// get all rooms, it is important to get the rooms from voice context here
// these are the ones featuring the real audio status
CVoiceRoomList rooms = this->m_contextVoice->getComVoiceRoomsWithAudioStatus();
CVoiceRoomList rooms = this->m_contextAudio->getComVoiceRoomsWithAudioStatus();
Q_ASSERT(rooms.size() == 2);
Q_ASSERT(this->m_modelUsersVoiceCom1);
Q_ASSERT(this->m_modelUsersVoiceCom2);
@@ -145,12 +145,12 @@ void MainWindow::updateCockpitFromContext()
bool com2Connected = room2.isConnected();
// update views
this->m_modelUsersVoiceCom1->update(this->m_contextVoice->getCom1RoomUsers());
this->m_modelUsersVoiceCom1->update(this->m_contextAudio->getCom1RoomUsers());
this->ui->tv_CockpitVoiceRoom1->resizeColumnsToContents();
this->ui->tv_CockpitVoiceRoom1->resizeRowsToContents();
this->ui->tv_CockpitVoiceRoom1->horizontalHeader()->setStretchLastSection(true);
this->m_modelUsersVoiceCom2->update(this->m_contextVoice->getCom2RoomUsers());
this->m_modelUsersVoiceCom2->update(this->m_contextAudio->getCom2RoomUsers());
this->ui->tv_CockpitVoiceRoom2->resizeColumnsToContents();
this->ui->tv_CockpitVoiceRoom2->resizeRowsToContents();
this->ui->tv_CockpitVoiceRoom2->horizontalHeader()->setStretchLastSection(true);
@@ -316,7 +316,7 @@ void MainWindow::sendCockpitUpdates()
*/
void MainWindow::setAudioVoiceRooms()
{
if (!this->m_contextVoiceAvailable) return;
if (!this->m_contextAudioAvailable) return;
if (!this->m_contextNetworkAvailable) return;
// make fields readonly if not overriding
@@ -347,7 +347,7 @@ void MainWindow::setAudioVoiceRooms()
}
// set the real voice rooms for audio output
this->m_contextVoice->setComVoiceRooms(room1, room2);
this->m_contextAudio->setComVoiceRooms(room1, room2);
}
/*
@@ -362,10 +362,10 @@ void MainWindow::testSelcal()
CStatusMessage(CStatusMessage::TypeValidation, CStatusMessage::SeverityWarning, "invalid SELCAL codde"));
return;
}
if (this->m_contextVoiceAvailable)
if (this->m_contextAudioAvailable)
{
CSelcal selcal(selcalCode);
this->m_contextVoice->playSelcalTone(selcal);
this->m_contextAudio->playSelcalTone(selcal);
}
else
{

View File

@@ -6,6 +6,8 @@
#include "blackcore/context_simulator_proxy.h"
#include "blackcore/context_application_impl.h"
#include "blackcore/context_application_proxy.h"
#include "blackcore/context_audio_impl.h"
#include "blackcore/context_audio_proxy.h"
#include "blackcore/coreruntime.h"
#include "blackgui/atcstationlistmodel.h"
#include "blackgui/keyboardkeylistmodel.h"
@@ -167,8 +169,8 @@ void MainWindow::init(GuiModes::CoreMode coreMode)
{
this->m_dBusConnection = QDBusConnection::sessionBus();
this->m_contextNetwork = new BlackCore::IContextNetwork(BlackCore::CDBusServer::ServiceName, this->m_dBusConnection, this);
this->m_contextVoice = new BlackCore::IContextVoice(BlackCore::CDBusServer::ServiceName, this->m_dBusConnection, this);
this->m_contextSettings = new BlackCore::IContextSettings(BlackCore::CDBusServer::ServiceName, this->m_dBusConnection, this);
this->m_contextAudio = new BlackCore::CContextAudioProxy(BlackCore::CDBusServer::ServiceName, this->m_dBusConnection, this);
this->m_contextApplication = new BlackCore::CContextApplicationProxy(BlackCore::CDBusServer::ServiceName, this->m_dBusConnection, this);
this->m_contextSimulator = new BlackCore::CContextSimulatorProxy(BlackCore::CDBusServer::ServiceName, this->m_dBusConnection, this);
}
@@ -176,7 +178,7 @@ void MainWindow::init(GuiModes::CoreMode coreMode)
{
this->m_coreRuntime.reset(new CCoreRuntime(false, this));
this->m_contextNetwork = this->m_coreRuntime->getIContextNetwork();
this->m_contextVoice = this->m_coreRuntime->getIContextVoice();
this->m_contextAudio = this->m_coreRuntime->getIContextAudio();
this->m_contextSettings = this->m_coreRuntime->getIContextSettings();
this->m_contextApplication = this->m_coreRuntime->getIContextApplication();
this->m_contextSimulator = this->m_coreRuntime->getIContextSimulator();
@@ -224,7 +226,7 @@ void MainWindow::init(GuiModes::CoreMode coreMode)
this->connect(this->m_timerCollectedCockpitUpdates, &QTimer::timeout, this, &MainWindow::sendCockpitUpdates);
this->connect(this->m_timerAudioTests, &QTimer::timeout, this, &MainWindow::audioTestUpdate);
this->connect(this->m_timerSimulator, &QTimer::timeout, this, &MainWindow::timerBasedUpdates);
connect = this->connect(this->m_contextVoice, &IContextVoice::audioTestCompleted, this, &MainWindow::audioTestUpdate);
connect = this->connect(this->m_contextAudio, &IContextAudio::audioTestCompleted, this, &MainWindow::audioTestUpdate);
// start timers, update timers will be started when network is connected
this->m_timerContextWatchdog->start(2 * 1000);

View File

@@ -26,9 +26,9 @@ void MainWindow::appendTextMessagesToGui(const CTextMessageList &messages, bool
if (this->m_ownAircraft.isActiveFrequencyWithin25kHzChannel(message.getFrequency()))
{
// this is SELCAL for me
if (this->m_contextVoiceAvailable)
if (this->m_contextAudioAvailable)
{
CAudioDevice dev = this->m_contextVoice->getCurrentAudioDevices().getOutputDevices()[0];
CAudioDevice dev = this->m_contextAudio->getCurrentAudioDevices().getOutputDevices()[0];
BlackSound::CSoundGenerator::playSelcal(90, CSelcal(currentSelcal), dev);
}
else

View File

@@ -3,7 +3,7 @@
#include "blackgui/atcstationlistmodel.h"
#include "blackcore/dbus_server.h"
#include "blackcore/context_network.h"
#include "blackcore/context_voice.h"
#include "blackcore/context_audio.h"
#include "blacksound/soundgenerator.h"
using namespace BlackCore;
@@ -23,11 +23,11 @@ using namespace BlackMisc::Math;
*/
void MainWindow::setAudioDeviceLists()
{
if (!this->isContextVoiceAvailableCheck()) return;
if (!this->isContextAudioAvailableCheck()) return;
this->ui->cb_SettingsAudioOutputDevice->clear();
this->ui->cb_SettingsAudioInputDevice->clear();
foreach(CAudioDevice device, this->m_contextVoice->getAudioDevices())
foreach(CAudioDevice device, this->m_contextAudio->getAudioDevices())
{
if (device.getType() == CAudioDevice::InputDevice)
{
@@ -39,7 +39,7 @@ void MainWindow::setAudioDeviceLists()
}
}
foreach(CAudioDevice device, this->m_contextVoice->getCurrentAudioDevices())
foreach(CAudioDevice device, this->m_contextAudio->getCurrentAudioDevices())
{
if (device.getType() == CAudioDevice::InputDevice)
{
@@ -58,9 +58,9 @@ void MainWindow::setAudioDeviceLists()
void MainWindow::audioDeviceSelected(int index)
{
if (!this->m_init) return; // not during init
if (!this->isContextVoiceAvailableCheck()) return;
if (!this->isContextAudioAvailableCheck()) return;
if (index < 0)return;
CAudioDeviceList devices = this->m_contextVoice->getAudioDevices();
CAudioDeviceList devices = this->m_contextAudio->getAudioDevices();
if (devices.isEmpty()) return;
CAudioDevice selectedDevice;
QObject *sender = QObject::sender();
@@ -69,14 +69,14 @@ void MainWindow::audioDeviceSelected(int index)
CAudioDeviceList inputDevices = devices.getInputDevices();
if (index >= inputDevices.size()) return;
selectedDevice = inputDevices[index];
this->m_contextVoice->setCurrentAudioDevice(selectedDevice);
this->m_contextAudio->setCurrentAudioDevice(selectedDevice);
}
else if (sender == this->ui->cb_SettingsAudioOutputDevice)
{
CAudioDeviceList outputDevices = devices.getOutputDevices();
if (index >= outputDevices.size()) return;
selectedDevice = outputDevices[index];
this->m_contextVoice->setCurrentAudioDevice(selectedDevice);
this->m_contextAudio->setCurrentAudioDevice(selectedDevice);
}
}
@@ -85,7 +85,7 @@ void MainWindow::audioDeviceSelected(int index)
*/
void MainWindow::audioVolumes()
{
if (!this->m_contextVoiceAvailable)
if (!this->m_contextAudioAvailable)
{
this->ui->pb_SoundMute->setEnabled(false);
this->ui->pb_SoundMaxVolume->setEnabled(false);
@@ -103,7 +103,7 @@ void MainWindow::audioVolumes()
if (sender == this->ui->pb_SoundMute)
{
if (this->m_contextVoice->isMuted())
if (this->m_contextAudio->isMuted())
{
// muted right now, now unmute
muted = false;
@@ -146,7 +146,7 @@ void MainWindow::audioVolumes()
// update own aircraft, also set volume/mute in voice
this->m_ownAircraft.setCom1System(com1);
this->m_ownAircraft.setCom2System(com2);
this->m_contextVoice->setVolumes(this->m_ownAircraft.getCom1System(), this->m_ownAircraft.getCom2System());
this->m_contextAudio->setVolumes(this->m_ownAircraft.getCom1System(), this->m_ownAircraft.getCom2System());
}
/*
@@ -154,7 +154,7 @@ void MainWindow::audioVolumes()
*/
void MainWindow::startAudioTest()
{
if (!this->m_contextVoiceAvailable)
if (!this->m_contextAudioAvailable)
{
CStatusMessage m(CStatusMessage::TypeAudio, CStatusMessage::SeverityError, "voice context not available");
this->displayStatusMessage(m);
@@ -174,13 +174,13 @@ void MainWindow::startAudioTest()
if (sender == this->ui->pb_SettingsAudioMicrophoneTest)
{
this->m_audioTestRunning = MicrophoneTest;
this->m_contextVoice->runMicrophoneTest();
this->m_contextAudio->runMicrophoneTest();
this->ui->pte_SettingsAudioTestActionAndResult->appendPlainText("Speak normally for 5 seconds");
}
else if (sender == this->ui->pb_SettingsAudioSquelchTest)
{
this->m_audioTestRunning = SquelchTest;
this->m_contextVoice->runSquelchTest();
this->m_contextAudio->runSquelchTest();
this->ui->pte_SettingsAudioTestActionAndResult->appendPlainText("Silence for 5 seconds");
}
this->ui->prb_SettingsAudioTestProgress->setVisible(true);
@@ -210,16 +210,16 @@ void MainWindow::audioTestUpdate()
// getting here we assume the audio test finished signal
// fetch results
this->ui->pte_SettingsAudioTestActionAndResult->clear();
if (this->m_contextVoiceAvailable)
if (this->m_contextAudioAvailable)
{
if (this->m_audioTestRunning == SquelchTest)
{
double s = this->m_contextVoice->getSquelchValue();
double s = this->m_contextAudio->getSquelchValue();
this->ui->pte_SettingsAudioTestActionAndResult->appendPlainText(QString::number(s));
}
else if (this->m_audioTestRunning == MicrophoneTest)
{
QString m = this->m_contextVoice->getMicrophoneTestResult();
QString m = this->m_contextAudio->getMicrophoneTestResult();
this->ui->pte_SettingsAudioTestActionAndResult->appendPlainText(m);
}
}
@@ -236,8 +236,8 @@ void MainWindow::audioTestUpdate()
*/
void MainWindow::playNotifcationSound(CSoundGenerator::Notification notification) const
{
if (!this->m_contextVoiceAvailable) return;
if (!this->m_contextAudioAvailable) return;
if (!this->ui->cb_SettingsAudioPlayNotificationSounds->isChecked()) return;
if (notification == CSoundGenerator::NotificationTextMessage && !this->ui->cb_SettingsAudioNotificationTextMessage->isChecked()) return;
this->m_contextVoice->playNotification(static_cast<uint>(notification));
this->m_contextAudio->playNotification(static_cast<uint>(notification));
}