[AFV] Ref T739, cmd.line args for "no audio"

This commit is contained in:
Klaus Basan
2019-10-27 01:47:07 +02:00
committed by Mat Sutcliffe
parent 0fa9bcb520
commit 5150fb4e86
6 changed files with 52 additions and 13 deletions

View File

@@ -11,6 +11,7 @@
#include "blackcore/db/networkwatchdog.h"
#include "blackcore/context/contextnetwork.h"
#include "blackcore/context/contextsimulatorimpl.h"
#include "blackcore/context/contextaudio.h"
#include "blackcore/context/contextapplication.h"
#include "blackcore/cookiemanager.h"
#include "blackcore/corefacade.h"
@@ -1312,7 +1313,12 @@ namespace BlackCore
void CApplication::addVatlibOptions()
{
this->addParserOptions(BlackCore::Context::IContextNetwork::getCmdLineOptions());
this->addParserOptions(IContextNetwork::getCmdLineOptions());
}
void CApplication::addAudioOptions()
{
this->addParserOptions(CContextAudioBase::getCmdLineOptions());
}
QString CApplication::getCmdDBusAddressValue() const

View File

@@ -264,18 +264,21 @@ namespace BlackCore
//! Add the VATLIB options
void addVatlibOptions();
//! Add the audio options
void addAudioOptions();
//! Private resource dir for developer's own resource files
QString getCmdSwiftPrivateSharedDir() const;
//! Delegates to QCommandLineParser::isSet
bool isParserOptionSet(const QString &option) const;
//! Called by installer?
bool isInstallerOptionSet() const;
//! Skip the single application check
bool skipSingleApplicationCheck() const;
//! Delegates to QCommandLineParser::isSet
bool isParserOptionSet(const QString &option) const;
//! Delegates to QCommandLineParser::isSet
bool isParserOptionSet(const QCommandLineOption &option) const;

View File

@@ -108,10 +108,17 @@ namespace BlackCore
CContextAudioBase::CContextAudioBase(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) :
IContextAudio(mode, runtime),
CIdentifiable(this),
m_voiceClient(new CAfvClient(CVoiceSetup().getAfvVoiceServerUrl(), this))
CIdentifiable(this)
{
this->initVoiceClient();
if (CContextAudioBase::isNoAudioSet())
{
CLogMessage(this).info(u"Voice client disabled");
}
else
{
this->initVoiceClient();
}
const CSettings as = m_audioSettings.getThreadLocal();
this->setVoiceOutputVolume(as.getOutVolume());
m_selcalPlayer = new CSelcalPlayer(CAudioDeviceInfo::getDefaultOutputDevice(), this);
@@ -132,10 +139,8 @@ namespace BlackCore
void CContextAudioBase::initVoiceClient()
{
if (!m_voiceClient)
{
m_voiceClient = new CAfvClient(CVoiceSetup().getAfvVoiceServerUrl(), this);
}
if (!m_voiceClient) { return; }
m_voiceClient = new CAfvClient(CVoiceSetup().getAfvVoiceServerUrl(), this);
const CVoiceSetup vs = m_voiceSettings.getThreadLocal();
m_voiceClient->updateVoiceServerUrl(vs.getAfvVoiceServerUrl());
@@ -159,7 +164,7 @@ namespace BlackCore
#endif
Q_ASSERT_X(CThreadUtils::isApplicationThread(m_voiceClient->thread()), Q_FUNC_INFO, "Should be in main thread");
m_voiceClient->start();
m_voiceClient->start(); // thread
Q_ASSERT_X(m_voiceClient->owner() == this, Q_FUNC_INFO, "Wrong owner");
Q_ASSERT_X(!CThreadUtils::isApplicationThread(m_voiceClient->thread()), Q_FUNC_INFO, "Must NOT be in main thread");
@@ -199,7 +204,8 @@ namespace BlackCore
void CContextAudioBase::enableVoiceClientAndStart()
{
this->initVoiceClient();
if (m_voiceClient) {
if (m_voiceClient)
{
m_voiceClient->startAudio();
this->connectAudioWithNetworkCredentials();
}
@@ -255,6 +261,21 @@ namespace BlackCore
return m_voiceClient && m_voiceClient->isStarted();
}
const QList<QCommandLineOption> &CContextAudioBase::getCmdLineOptions()
{
static const QList<QCommandLineOption> opts
{
QCommandLineOption({{"n", "noaudio"}, QCoreApplication::translate("CContextAudioBase", "No audio for GUI or core.", "noaudio")})
};
return opts;
}
bool CContextAudioBase::isNoAudioSet()
{
if (!sApp) { return false; }
return sApp->isParserOptionSet("noaudio");
}
QString CContextAudioBase::audioRunsWhereInfo() const
{
const QString s = QStringLiteral("[%1] Audio on '%2', '%3'.").arg(boolToEnabledDisabled(this->isAudioStarted()), audioRunsWhere().getMachineName(), audioRunsWhere().getProcessName());

View File

@@ -38,6 +38,7 @@
#include <QObject>
#include <QString>
#include <QCommandLineOption>
// clazy:excludeall=const-signal-or-slot
@@ -198,6 +199,12 @@ namespace BlackCore
//! \todo WORKAROUND to hide the "local signals"
Afv::Clients::CAfvClient *afvClient() const { return m_voiceClient; }
//! Cmd.line arguments
static const QList<QCommandLineOption> &getCmdLineOptions();
//! No audio?
static bool isNoAudioSet();
// -------- parts which can run in core and GUI, referring to local voice client ------------
public slots:

View File

@@ -36,6 +36,7 @@ int main(int argc, char *argv[])
a.addWindowStateOption();
a.addDBusAddressOption();
a.addVatlibOptions();
a.addAudioOptions();
if (!a.parseAndSynchronizeSetup()) { return EXIT_FAILURE; }
const QString dBusAdress(a.getCmdDBusAddressValue());

View File

@@ -24,6 +24,7 @@ CSwiftGuiStdApplication::CSwiftGuiStdApplication() :
this->addParserOption(m_cmdFacadeMode);
this->addDBusAddressOption();
this->addVatlibOptions();
this->addAudioOptions();
}
CStatusMessageList CSwiftGuiStdApplication::startHookIn()