kopia lustrzana https://gitlab.com/eliggett/wfview
Add some more audio status
rodzic
30ca8aa44a
commit
00f15a059e
|
@ -83,8 +83,8 @@ audioConverter::~audioConverter()
|
|||
bool audioConverter::convert(audioPacket audio)
|
||||
{
|
||||
|
||||
// If inFormat and outFormat are identical, just emit the data back.
|
||||
if (audio.data.size() > 0 && inFormat != outFormat)
|
||||
// If inFormat and outFormat are identical, just emit the data back (removed as it doesn't then process amplitude)
|
||||
if (audio.data.size() > 0)
|
||||
{
|
||||
|
||||
if (inFormat.codec() == "audio/opus")
|
||||
|
|
|
@ -35,9 +35,7 @@ audioHandler::~audioHandler()
|
|||
converterThread->quit();
|
||||
converterThread->wait();
|
||||
}
|
||||
}
|
||||
|
||||
bool audioHandler::init(audioSetup setup)
|
||||
}bool audioHandler::init(audioSetup setup)
|
||||
{
|
||||
if (isInitialized) {
|
||||
return false;
|
||||
|
@ -108,6 +106,7 @@ bool audioHandler::init(audioSetup setup)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
if (outFormat.sampleType()==QAudioFormat::SignedInt) {
|
||||
|
@ -254,7 +253,12 @@ void audioHandler::convertedOutput(audioPacket packet) {
|
|||
|
||||
currentLatency = packet.time.msecsTo(QTime::currentTime()) + (outFormat.durationForBytes(audioOutput->bufferSize() - audioOutput->bytesFree()) / 1000);
|
||||
if (audioDevice != Q_NULLPTR) {
|
||||
audioDevice->write(packet.data);
|
||||
if (audioDevice->write(packet.data) < packet.data.size()) {
|
||||
qDebug(logAudio()) << (setup.isinput ? "Input" : "Output") << "Buffer full!";
|
||||
isOverrun=true;
|
||||
} else {
|
||||
isOverrun = false;
|
||||
}
|
||||
if (lastReceived.msecsTo(QTime::currentTime()) > 100) {
|
||||
qDebug(logAudio()) << (setup.isinput ? "Input" : "Output") << "Time since last audio packet" << lastReceived.msecsTo(QTime::currentTime()) << "Expected around" << setup.blockSize;
|
||||
}
|
||||
|
@ -267,7 +271,7 @@ void audioHandler::convertedOutput(audioPacket packet) {
|
|||
}
|
||||
*/
|
||||
lastSentSeq = packet.seq;
|
||||
emit haveLevels(getAmplitude(), setup.latency, currentLatency, isUnderrun);
|
||||
emit haveLevels(getAmplitude(), setup.latency, currentLatency, isUnderrun, isOverrun);
|
||||
|
||||
amplitude = packet.amplitude;
|
||||
}
|
||||
|
@ -310,7 +314,7 @@ void audioHandler::convertedInput(audioPacket audio)
|
|||
}
|
||||
lastReceived = QTime::currentTime();
|
||||
amplitude = audio.amplitude;
|
||||
emit haveLevels(getAmplitude(), setup.latency, currentLatency, isUnderrun);
|
||||
emit haveLevels(getAmplitude(), setup.latency, currentLatency, isUnderrun, isOverrun);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ signals:
|
|||
void audioMessage(QString message);
|
||||
void sendLatency(quint16 newSize);
|
||||
void haveAudioData(const audioPacket& data);
|
||||
void haveLevels(quint16 amplitude,quint16 latency,quint16 current,bool under);
|
||||
void haveLevels(quint16 amplitude,quint16 latency,quint16 current,bool under,bool over);
|
||||
void setupConverter(QAudioFormat in, QAudioFormat out, quint8 opus, quint8 resamp);
|
||||
void sendToConverter(audioPacket audio);
|
||||
|
||||
|
@ -117,6 +117,7 @@ private:
|
|||
|
||||
|
||||
bool isUnderrun = false;
|
||||
bool isOverrun = true;
|
||||
bool isInitialized=false;
|
||||
bool isReady = false;
|
||||
bool audioBuffered = false;
|
||||
|
|
|
@ -143,18 +143,20 @@ void udpHandler::receiveDataFromUserToRig(QByteArray data)
|
|||
}
|
||||
}
|
||||
|
||||
void udpHandler::getRxLevels(quint16 amplitude,quint16 latency,quint16 current, bool under) {
|
||||
void udpHandler::getRxLevels(quint16 amplitude,quint16 latency,quint16 current, bool under, bool over) {
|
||||
status.rxAudioLevel = amplitude;
|
||||
status.rxLatency = latency;
|
||||
status.rxCurrentLatency = current;
|
||||
status.rxUnderrun = under;
|
||||
status.rxOverrun = over;
|
||||
}
|
||||
|
||||
void udpHandler::getTxLevels(quint16 amplitude,quint16 latency, quint16 current, bool under) {
|
||||
void udpHandler::getTxLevels(quint16 amplitude,quint16 latency, quint16 current, bool under, bool over) {
|
||||
status.txAudioLevel = amplitude;
|
||||
status.txLatency = latency;
|
||||
status.txCurrentLatency = current;
|
||||
status.txUnderrun = under;
|
||||
status.txOverrun = over;
|
||||
}
|
||||
|
||||
void udpHandler::dataReceived()
|
||||
|
@ -208,13 +210,19 @@ void udpHandler::dataReceived()
|
|||
}
|
||||
|
||||
QString tempLatency;
|
||||
if (status.rxCurrentLatency < status.rxLatency*1.2 && !status.rxUnderrun)
|
||||
if (status.rxCurrentLatency < status.rxLatency*1.2 && !status.rxUnderrun && !status.rxOverrun)
|
||||
{
|
||||
tempLatency = QString("%1 ms").arg(status.rxCurrentLatency,3);
|
||||
}
|
||||
else {
|
||||
else if (status.rxUnderrun){
|
||||
tempLatency = QString("<span style = \"color:red\">%1 ms</span>").arg(status.rxCurrentLatency,3);
|
||||
}
|
||||
else if (status.rxOverrun){
|
||||
tempLatency = QString("<span style = \"color:orange\">%1 ms</span>").arg(status.rxCurrentLatency,3);
|
||||
} else
|
||||
{
|
||||
tempLatency = QString("<span style = \"color:green\">%1 ms</span>").arg(status.rxCurrentLatency,3);
|
||||
}
|
||||
QString txString="";
|
||||
if (txSetup.codec == 0) {
|
||||
txString = "(no tx)";
|
||||
|
@ -306,8 +314,8 @@ void udpHandler::dataReceived()
|
|||
QObject::connect(audio, SIGNAL(haveAudioData(audioPacket)), this, SLOT(receiveAudioData(audioPacket)));
|
||||
QObject::connect(this, SIGNAL(haveChangeLatency(quint16)), audio, SLOT(changeLatency(quint16)));
|
||||
QObject::connect(this, SIGNAL(haveSetVolume(unsigned char)), audio, SLOT(setVolume(unsigned char)));
|
||||
QObject::connect(audio, SIGNAL(haveRxLevels(quint16, quint16, quint16,bool)), this, SLOT(getRxLevels(quint16, quint16,quint16,bool)));
|
||||
QObject::connect(audio, SIGNAL(haveTxLevels(quint16, quint16,quint16,bool)), this, SLOT(getTxLevels(quint16, quint16,quint16,bool)));
|
||||
QObject::connect(audio, SIGNAL(haveRxLevels(quint16, quint16, quint16,bool,bool)), this, SLOT(getRxLevels(quint16, quint16,quint16,bool,bool)));
|
||||
QObject::connect(audio, SIGNAL(haveTxLevels(quint16, quint16,quint16,bool,bool)), this, SLOT(getTxLevels(quint16, quint16,quint16,bool,bool)));
|
||||
|
||||
streamOpened = true;
|
||||
}
|
||||
|
@ -935,7 +943,7 @@ udpAudio::udpAudio(QHostAddress local, QHostAddress ip, quint16 audioPort, quint
|
|||
connect(this, SIGNAL(haveAudioData(audioPacket)), rxaudio, SLOT(incomingAudio(audioPacket)));
|
||||
connect(this, SIGNAL(haveChangeLatency(quint16)), rxaudio, SLOT(changeLatency(quint16)));
|
||||
connect(this, SIGNAL(haveSetVolume(unsigned char)), rxaudio, SLOT(setVolume(unsigned char)));
|
||||
connect(rxaudio, SIGNAL(haveLevels(quint16, quint16, quint16,bool)), this, SLOT(getRxLevels(quint16, quint16, quint16,bool)));
|
||||
connect(rxaudio, SIGNAL(haveLevels(quint16, quint16, quint16,bool,bool)), this, SLOT(getRxLevels(quint16, quint16, quint16,bool,bool)));
|
||||
connect(rxAudioThread, SIGNAL(finished()), rxaudio, SLOT(deleteLater()));
|
||||
|
||||
|
||||
|
@ -956,7 +964,7 @@ udpAudio::udpAudio(QHostAddress local, QHostAddress ip, quint16 audioPort, quint
|
|||
|
||||
connect(this, SIGNAL(setupTxAudio(audioSetup)), txaudio, SLOT(init(audioSetup)));
|
||||
connect(txaudio, SIGNAL(haveAudioData(audioPacket)), this, SLOT(receiveAudioData(audioPacket)));
|
||||
connect(txaudio, SIGNAL(haveLevels(quint16, quint16, quint16, bool)), this, SLOT(getTxLevels(quint16, quint16, quint16, bool)));
|
||||
connect(txaudio, SIGNAL(haveLevels(quint16, quint16, quint16, bool,bool)), this, SLOT(getTxLevels(quint16, quint16, quint16, bool,bool)));
|
||||
|
||||
connect(txAudioThread, SIGNAL(finished()), txaudio, SLOT(deleteLater()));
|
||||
emit setupTxAudio(txSetup);
|
||||
|
@ -1086,13 +1094,13 @@ void udpAudio::setVolume(unsigned char value)
|
|||
emit haveSetVolume(value);
|
||||
}
|
||||
|
||||
void udpAudio::getRxLevels(quint16 amplitude,quint16 latency, quint16 current, bool under) {
|
||||
void udpAudio::getRxLevels(quint16 amplitude,quint16 latency, quint16 current, bool under, bool over) {
|
||||
|
||||
emit haveRxLevels(amplitude,latency, current, under);
|
||||
emit haveRxLevels(amplitude,latency, current, under, over);
|
||||
}
|
||||
|
||||
void udpAudio::getTxLevels(quint16 amplitude,quint16 latency, quint16 current, bool under) {
|
||||
emit haveTxLevels(amplitude,latency, current, under);
|
||||
void udpAudio::getTxLevels(quint16 amplitude,quint16 latency, quint16 current, bool under, bool over) {
|
||||
emit haveTxLevels(amplitude,latency, current, under, over);
|
||||
}
|
||||
|
||||
void udpAudio::dataReceived()
|
||||
|
|
14
udphandler.h
14
udphandler.h
|
@ -46,6 +46,8 @@ struct networkStatus {
|
|||
quint16 txLatency;
|
||||
bool rxUnderrun;
|
||||
bool txUnderrun;
|
||||
bool txOverrun;
|
||||
bool rxOverrun;
|
||||
quint16 rxCurrentLatency;
|
||||
quint16 txCurrentLatency;
|
||||
quint32 packetsSent=0;
|
||||
|
@ -193,14 +195,14 @@ signals:
|
|||
|
||||
void haveChangeLatency(quint16 value);
|
||||
void haveSetVolume(unsigned char value);
|
||||
void haveRxLevels(quint16 amplitude, quint16 latency, quint16 current, bool under);
|
||||
void haveTxLevels(quint16 amplitude, quint16 latency, quint16 current, bool under);
|
||||
void haveRxLevels(quint16 amplitude, quint16 latency, quint16 current, bool under, bool over);
|
||||
void haveTxLevels(quint16 amplitude, quint16 latency, quint16 current, bool under, bool over);
|
||||
|
||||
public slots:
|
||||
void changeLatency(quint16 value);
|
||||
void setVolume(unsigned char value);
|
||||
void getRxLevels(quint16 amplitude, quint16 latency, quint16 current, bool under);
|
||||
void getTxLevels(quint16 amplitude, quint16 latency, quint16 current, bool under);
|
||||
void getRxLevels(quint16 amplitude, quint16 latency, quint16 current, bool under, bool over);
|
||||
void getTxLevels(quint16 amplitude, quint16 latency, quint16 current, bool under, bool over);
|
||||
void receiveAudioData(audioPacket audio);
|
||||
|
||||
private:
|
||||
|
@ -251,8 +253,8 @@ public slots:
|
|||
void setVolume(unsigned char value);
|
||||
void init();
|
||||
void setCurrentRadio(quint8 radio);
|
||||
void getRxLevels(quint16 amplitude, quint16 latency, quint16 current, bool under);
|
||||
void getTxLevels(quint16 amplitude, quint16 latency, quint16 current, bool under);
|
||||
void getRxLevels(quint16 amplitude, quint16 latency, quint16 current, bool under, bool over);
|
||||
void getTxLevels(quint16 amplitude, quint16 latency, quint16 current, bool under, bool over);
|
||||
|
||||
|
||||
signals:
|
||||
|
|
Ładowanie…
Reference in New Issue