mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
[AFV] Allow to log. input receiver
This commit is contained in:
committed by
Mat Sutcliffe
parent
2c6794a009
commit
9e6716e515
@@ -18,6 +18,8 @@
|
||||
|
||||
#include <QtMath>
|
||||
#include <QDebug>
|
||||
#include <QStringLiteral>
|
||||
#include <QStringBuilder>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackSound::SampleProvider;
|
||||
@@ -105,7 +107,7 @@ namespace BlackCore
|
||||
{
|
||||
m_callsign = callsign;
|
||||
CallsignDelayCache::instance().initialise(callsign);
|
||||
m_type = aircraftType;
|
||||
m_aircraftType = aircraftType;
|
||||
m_decoder.resetState();
|
||||
m_inUse = true;
|
||||
setEffects();
|
||||
@@ -125,7 +127,7 @@ namespace BlackCore
|
||||
{
|
||||
m_callsign = callsign;
|
||||
CallsignDelayCache::instance().initialise(callsign);
|
||||
m_type = aircraftType;
|
||||
m_aircraftType = aircraftType;
|
||||
m_decoder.resetState();
|
||||
m_inUse = true;
|
||||
setEffects(true);
|
||||
@@ -169,7 +171,7 @@ namespace BlackCore
|
||||
m_inUse = false;
|
||||
setEffects();
|
||||
m_callsign.clear();
|
||||
m_type.clear();
|
||||
m_aircraftType.clear();
|
||||
}
|
||||
|
||||
QVector<qint16> CCallsignSampleProvider::decodeOpus(const QByteArray &opusData)
|
||||
@@ -230,6 +232,13 @@ namespace BlackCore
|
||||
setEffects();
|
||||
}
|
||||
|
||||
QString CCallsignSampleProvider::toQString() const
|
||||
{
|
||||
return QStringLiteral("In use: ") % boolToYesNo(m_inUse) %
|
||||
QStringLiteral(" cs: ") % m_callsign %
|
||||
QStringLiteral(" type: ") % m_aircraftType;
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace BlackCore
|
||||
const QString &callsign() const { return m_callsign; }
|
||||
|
||||
//! Type
|
||||
const QString &type() const { return m_type; }
|
||||
const QString &type() const { return m_aircraftType; }
|
||||
|
||||
//! Is active?
|
||||
//! @{
|
||||
@@ -73,6 +73,9 @@ namespace BlackCore
|
||||
//! Bypass effects
|
||||
void setBypassEffects(bool bypassEffects);
|
||||
|
||||
//! Info
|
||||
QString toQString() const;
|
||||
|
||||
private:
|
||||
void timerElapsed();
|
||||
void idle();
|
||||
@@ -88,7 +91,7 @@ namespace BlackCore
|
||||
const int m_idleTimeoutMs = 500;
|
||||
|
||||
QString m_callsign;
|
||||
QString m_type;
|
||||
QString m_aircraftType;
|
||||
bool m_inUse = false;
|
||||
|
||||
bool m_bypassEffects = false;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "blacksound/sampleprovider/samples.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringBuilder>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Audio;
|
||||
@@ -115,13 +116,14 @@ namespace BlackCore
|
||||
// CLogMessage(this).debug(u"AFV Click...");
|
||||
}
|
||||
|
||||
//! \todo KB 2020-04 not entirely correct, as it can be the number is the same, but changed callsign
|
||||
if (numberOfInUseInputs != m_lastNumberOfInUseInputs)
|
||||
{
|
||||
QStringList receivingCallsigns;
|
||||
for (const CCallsignSampleProvider *voiceInput : m_voiceInputs)
|
||||
{
|
||||
const QString callsign = voiceInput->callsign();
|
||||
if (! callsign.isEmpty())
|
||||
if (!callsign.isEmpty())
|
||||
{
|
||||
receivingCallsigns.push_back(callsign);
|
||||
}
|
||||
@@ -151,7 +153,7 @@ namespace BlackCore
|
||||
voiceInput = *it;
|
||||
}
|
||||
|
||||
if (! voiceInput)
|
||||
if (!voiceInput)
|
||||
{
|
||||
it = std::find_if(m_voiceInputs.begin(), m_voiceInputs.end(), [](const CCallsignSampleProvider * p) { return p->inUse() == false; });
|
||||
if (it != m_voiceInputs.end())
|
||||
@@ -208,6 +210,29 @@ namespace BlackCore
|
||||
return m_frequencyHz;
|
||||
}
|
||||
|
||||
void CReceiverSampleProvider::logVoiceInputs(const QString &prefix, qint64 timeCheckOffsetMs)
|
||||
{
|
||||
if (timeCheckOffsetMs > 100)
|
||||
{
|
||||
const qint64 now = QDateTime::currentMSecsSinceEpoch();
|
||||
if (m_lastLogMessage + timeCheckOffsetMs > now) { return; }
|
||||
m_lastLogMessage = now;
|
||||
}
|
||||
|
||||
QString l;
|
||||
int no = 0;
|
||||
for (const CCallsignSampleProvider *sp : m_voiceInputs)
|
||||
{
|
||||
if (!sp || !sp->inUse()) { continue; } // only log the ones in use
|
||||
l += (l.isEmpty() ? QStringLiteral("") : QStringLiteral("\n")) %
|
||||
prefix %
|
||||
QString::number(no++) % QStringLiteral(": ") % sp->toQString();
|
||||
}
|
||||
|
||||
if (l.isEmpty()) { return; }
|
||||
CLogMessage(this).debug(l);
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -87,6 +87,10 @@ namespace BlackCore
|
||||
//! Get frequency in Hz
|
||||
uint getFrequencyHz() const;
|
||||
|
||||
//! Log all inputs
|
||||
//! \private DEBUG only
|
||||
void logVoiceInputs(const QString &prefix = {}, qint64 timeCheckOffsetMs = -1);
|
||||
|
||||
signals:
|
||||
//! Receving callsigns have changed
|
||||
void receivingCallsignsChanged(const TransceiverReceivingCallsignsChangedArgs &args);
|
||||
@@ -100,10 +104,11 @@ namespace BlackCore
|
||||
quint16 m_id;
|
||||
BlackMisc::CSettingReadOnly<BlackMisc::Audio::TSettings> m_audioSettings { this };
|
||||
|
||||
BlackSound::SampleProvider::CVolumeSampleProvider *m_volume = nullptr;
|
||||
BlackSound::SampleProvider::CMixingSampleProvider *m_mixer = nullptr;
|
||||
BlackSound::SampleProvider::CVolumeSampleProvider *m_volume = nullptr;
|
||||
BlackSound::SampleProvider::CMixingSampleProvider *m_mixer = nullptr;
|
||||
BlackSound::SampleProvider::CSinusGenerator *m_blockTone = nullptr;
|
||||
QVector<CCallsignSampleProvider *> m_voiceInputs;
|
||||
qint64 m_lastLogMessage = -1;
|
||||
|
||||
QString m_receivingCallsignsString;
|
||||
BlackMisc::Aviation::CCallsignSet m_receivingCallsigns;
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
|
||||
#include "soundcardsampleprovider.h"
|
||||
#include "blackmisc/metadatautils.h"
|
||||
#include "blackconfig/buildconfig.h"
|
||||
|
||||
using namespace BlackConfig;
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackSound::SampleProvider;
|
||||
|
||||
@@ -143,9 +145,15 @@ namespace BlackCore
|
||||
{
|
||||
receiverInput->addSilentSamples(audioDto, rxTransceiver.frequency, rxTransceiver.distanceRatio);
|
||||
}
|
||||
|
||||
// debug ONLY
|
||||
if (CBuildConfig::isLocalDeveloperDebugBuild())
|
||||
{
|
||||
receiverInput->logVoiceInputs(QStringLiteral("Transceiver %1 ").arg(rxTransceiver.id), 1500);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // each transceiver
|
||||
} // filtered rx transceivers
|
||||
}
|
||||
|
||||
void CSoundcardSampleProvider::updateRadioTransceivers(const QVector<TransceiverDto> &radioTransceivers)
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace BlackCore
|
||||
m_output(new COutput(this)),
|
||||
m_voiceServerTimer(new QTimer(this))
|
||||
{
|
||||
this->setObjectName("AFV client");
|
||||
this->setObjectName("AFV client: " + apiServer );
|
||||
m_connection->setReceiveAudio(false);
|
||||
|
||||
connect(m_input, &CInput::opusDataAvailable, this, &CAfvClient::opusDataAvailable);
|
||||
@@ -123,7 +123,7 @@ namespace BlackCore
|
||||
void CAfvClient::connectWithContexts()
|
||||
{
|
||||
if (m_connectedWithContext) { return; }
|
||||
if (!hasContexts()) { return; }
|
||||
if (!hasContexts()) { return; }
|
||||
this->disconnect(sApp->getIContextOwnAircraft());
|
||||
sApp->getIContextOwnAircraft()->disconnect(this);
|
||||
connect(sApp->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftCockpit, this, &CAfvClient::onUpdateTransceiversFromContext, Qt::QueuedConnection);
|
||||
@@ -169,14 +169,16 @@ namespace BlackCore
|
||||
|
||||
// thread safe connect
|
||||
{
|
||||
QPointer<CAfvClient> myself(this);
|
||||
QMutexLocker lock(&m_mutexConnection);
|
||||
|
||||
// async connection
|
||||
m_connection->connectTo(cid, password, callsign, client,
|
||||
{
|
||||
// this is the callback when the connection has been established
|
||||
this, [ = ](bool authenticated)
|
||||
{
|
||||
// this is the callback when the connection has been established
|
||||
if (!myself) { return; }
|
||||
|
||||
// HF stations aliased
|
||||
const QVector<StationDto> aliasedStations = m_connection->getAllAliasedStations();
|
||||
@@ -388,7 +390,7 @@ namespace BlackCore
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
/* disabled because NOT used
|
||||
double CAfvClient::getDeviceInputVolume() const
|
||||
{
|
||||
if (m_input) { return m_input->getDeviceInputVolume(); }
|
||||
|
||||
@@ -51,8 +51,8 @@ namespace BlackCore
|
||||
|
||||
m_username = username;
|
||||
m_password = password;
|
||||
m_client = client;
|
||||
m_networkVersion = networkVersion;
|
||||
m_client = client;
|
||||
m_isAuthenticated = false;
|
||||
|
||||
QUrl url(m_addressUrl);
|
||||
@@ -254,7 +254,7 @@ namespace BlackCore
|
||||
// posted in QAM thread, reply is nullptr if called from another thread
|
||||
sApp->postToNetwork(request, CApplication::NoLogRequestId, json.toJson(),
|
||||
{
|
||||
this, [ = ](QNetworkReply * nwReply)
|
||||
this, [ = ](QNetworkReply *nwReply)
|
||||
{
|
||||
// called in "this" thread
|
||||
const QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> reply(nwReply);
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace BlackSound
|
||||
CBufferedWaveProvider::CBufferedWaveProvider(const QAudioFormat &format, QObject *parent) :
|
||||
ISampleProvider(parent)
|
||||
{
|
||||
const QString on = QStringLiteral("%1 format: ").arg(this->metaObject()->className(), BlackSound::toQString(format));
|
||||
const QString on = QStringLiteral("%1 format: '%2'").arg(this->metaObject()->className(), BlackSound::toQString(format));
|
||||
this->setObjectName(on);
|
||||
|
||||
// Set buffer size to 10 secs
|
||||
|
||||
Reference in New Issue
Block a user