kopia lustrzana https://gitlab.com/eliggett/wfview
Merge branch 'wfserver'
commit
49773706d7
|
@ -43,28 +43,28 @@ class audioHandler : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit audioHandler(QObject* parent = nullptr);
|
audioHandler(QObject* parent = nullptr);
|
||||||
~audioHandler();
|
virtual ~audioHandler();
|
||||||
|
|
||||||
int getLatency();
|
virtual int getLatency();
|
||||||
|
|
||||||
void start();
|
virtual void start();
|
||||||
void stop();
|
virtual void stop();
|
||||||
|
|
||||||
quint16 getAmplitude();
|
virtual quint16 getAmplitude();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
bool init(audioSetup setup);
|
virtual bool init(audioSetup setup);
|
||||||
void changeLatency(const quint16 newSize);
|
virtual void changeLatency(const quint16 newSize);
|
||||||
void setVolume(unsigned char volume);
|
virtual void setVolume(unsigned char volume);
|
||||||
void incomingAudio(const audioPacket data);
|
virtual void incomingAudio(const audioPacket data);
|
||||||
void convertedInput(audioPacket audio);
|
virtual void convertedInput(audioPacket audio);
|
||||||
void convertedOutput(audioPacket audio);
|
virtual void convertedOutput(audioPacket audio);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void stateChanged(QAudio::State state);
|
virtual void stateChanged(QAudio::State state);
|
||||||
void clearUnderrun();
|
virtual void clearUnderrun();
|
||||||
void getNextAudioChunk();
|
virtual void getNextAudioChunk();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void audioMessage(QString message);
|
void audioMessage(QString message);
|
||||||
|
@ -82,7 +82,7 @@ private:
|
||||||
|
|
||||||
|
|
||||||
bool isUnderrun = false;
|
bool isUnderrun = false;
|
||||||
bool isOverrun = true;
|
bool isOverrun = false;
|
||||||
bool isInitialized=false;
|
bool isInitialized=false;
|
||||||
bool isReady = false;
|
bool isReady = false;
|
||||||
bool audioBuffered = false;
|
bool audioBuffered = false;
|
||||||
|
@ -113,7 +113,7 @@ private:
|
||||||
volatile bool ready = false;
|
volatile bool ready = false;
|
||||||
audioPacket tempBuf;
|
audioPacket tempBuf;
|
||||||
quint16 currentLatency;
|
quint16 currentLatency;
|
||||||
float amplitude;
|
float amplitude=0.0;
|
||||||
qreal volume = 1.0;
|
qreal volume = 1.0;
|
||||||
|
|
||||||
audioSetup setup;
|
audioSetup setup;
|
||||||
|
|
|
@ -8,12 +8,6 @@
|
||||||
commHandler::commHandler(QObject* parent) : QObject(parent)
|
commHandler::commHandler(QObject* parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
//constructor
|
//constructor
|
||||||
// grab baud rate and other comm port details
|
|
||||||
// if they need to be changed later, please
|
|
||||||
// destroy this and create a new one.
|
|
||||||
port = new QSerialPort();
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: The following should become arguments and/or functions
|
// TODO: The following should become arguments and/or functions
|
||||||
// Add signal/slot everywhere for comm port setup.
|
// Add signal/slot everywhere for comm port setup.
|
||||||
// Consider how to "re-setup" and how to save the state for next time.
|
// Consider how to "re-setup" and how to save the state for next time.
|
||||||
|
@ -22,13 +16,7 @@ commHandler::commHandler(QObject* parent) : QObject(parent)
|
||||||
portName = "/dev/ttyUSB0";
|
portName = "/dev/ttyUSB0";
|
||||||
this->PTTviaRTS = false;
|
this->PTTviaRTS = false;
|
||||||
|
|
||||||
setupComm(); // basic parameters
|
init();
|
||||||
openPort();
|
|
||||||
//qInfo(logSerial()) << "Serial buffer size: " << port->readBufferSize();
|
|
||||||
//port->setReadBufferSize(1024); // manually. 256 never saw any return from the radio. why...
|
|
||||||
//qInfo(logSerial()) << "Serial buffer size: " << port->readBufferSize();
|
|
||||||
|
|
||||||
connect(port, SIGNAL(readyRead()), this, SLOT(receiveDataIn()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
commHandler::commHandler(QString portName, quint32 baudRate, quint8 wfFormat, QObject* parent) : QObject(parent)
|
commHandler::commHandler(QString portName, quint32 baudRate, quint8 wfFormat, QObject* parent) : QObject(parent)
|
||||||
|
@ -38,7 +26,6 @@ commHandler::commHandler(QString portName, quint32 baudRate, quint8 wfFormat, QO
|
||||||
// if they need to be changed later, please
|
// if they need to be changed later, please
|
||||||
// destroy this and create a new one.
|
// destroy this and create a new one.
|
||||||
|
|
||||||
port = new QSerialPort();
|
|
||||||
|
|
||||||
if (wfFormat == 1) { // Single waterfall packet
|
if (wfFormat == 1) { // Single waterfall packet
|
||||||
combineWf = true;
|
combineWf = true;
|
||||||
|
@ -52,7 +39,19 @@ commHandler::commHandler(QString portName, quint32 baudRate, quint8 wfFormat, QO
|
||||||
stopbits = 1;
|
stopbits = 1;
|
||||||
this->portName = portName;
|
this->portName = portName;
|
||||||
this->PTTviaRTS = false;
|
this->PTTviaRTS = false;
|
||||||
|
init();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void commHandler::init()
|
||||||
|
{
|
||||||
|
if (port != Q_NULLPTR) {
|
||||||
|
delete port;
|
||||||
|
port = Q_NULLPTR;
|
||||||
|
isConnected = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
port = new QSerialPort();
|
||||||
setupComm(); // basic parameters
|
setupComm(); // basic parameters
|
||||||
openPort();
|
openPort();
|
||||||
// qInfo(logSerial()) << "Serial buffer size: " << port->readBufferSize();
|
// qInfo(logSerial()) << "Serial buffer size: " << port->readBufferSize();
|
||||||
|
@ -60,9 +59,10 @@ commHandler::commHandler(QString portName, quint32 baudRate, quint8 wfFormat, QO
|
||||||
//qInfo(logSerial()) << "Serial buffer size: " << port->readBufferSize();
|
//qInfo(logSerial()) << "Serial buffer size: " << port->readBufferSize();
|
||||||
|
|
||||||
connect(port, SIGNAL(readyRead()), this, SLOT(receiveDataIn()));
|
connect(port, SIGNAL(readyRead()), this, SLOT(receiveDataIn()));
|
||||||
|
connect(port, SIGNAL(error(QSerialPort::SerialPortError)), this, SLOT(handleError(QSerialPort::SerialPortError)));
|
||||||
|
lastDataReceived = QTime::currentTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
commHandler::~commHandler()
|
commHandler::~commHandler()
|
||||||
{
|
{
|
||||||
qInfo(logSerial()) << "Closing serial port: " << port->portName();
|
qInfo(logSerial()) << "Closing serial port: " << port->portName();
|
||||||
|
@ -87,16 +87,16 @@ void commHandler::receiveDataFromUserToRig(const QByteArray &data)
|
||||||
|
|
||||||
void commHandler::sendDataOut(const QByteArray &writeData)
|
void commHandler::sendDataOut(const QByteArray &writeData)
|
||||||
{
|
{
|
||||||
mutex.lock();
|
|
||||||
// Recycle port to attempt reconnection.
|
// Recycle port to attempt reconnection.
|
||||||
if (!this->isConnected) {
|
if (lastDataReceived.msecsTo(QTime::currentTime()) > 2000) {
|
||||||
closePort();
|
qDebug(logSerial()) << "Serial port error? Attempting reconnect...";
|
||||||
openPort();
|
lastDataReceived = QTime::currentTime();
|
||||||
}
|
QTimer::singleShot(500, this, SLOT(init()));
|
||||||
|
|
||||||
if (!this->isConnected) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mutex.lock();
|
||||||
|
|
||||||
qint64 bytesWritten;
|
qint64 bytesWritten;
|
||||||
|
|
||||||
if(PTTviaRTS)
|
if(PTTviaRTS)
|
||||||
|
@ -162,6 +162,7 @@ void commHandler::receiveDataIn()
|
||||||
// because we know what constitutes a valid "frame" of data.
|
// because we know what constitutes a valid "frame" of data.
|
||||||
|
|
||||||
// new code:
|
// new code:
|
||||||
|
lastDataReceived = QTime::currentTime();
|
||||||
port->startTransaction();
|
port->startTransaction();
|
||||||
inPortData = port->readAll();
|
inPortData = port->readAll();
|
||||||
|
|
||||||
|
@ -371,3 +372,17 @@ void commHandler::printHex(const QByteArray &pdata, bool printVert, bool printHo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void commHandler::handleError(QSerialPort::SerialPortError err)
|
||||||
|
{
|
||||||
|
switch (err) {
|
||||||
|
case QSerialPort::NoError:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (lastDataReceived.msecsTo(QTime::currentTime()) > 2000) {
|
||||||
|
qDebug(logSerial()) << "Serial port" << port->portName() << "Error, attempting disconnect/reconnect";
|
||||||
|
lastDataReceived = QTime::currentTime();
|
||||||
|
QTimer::singleShot(500, this, SLOT(init()));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
#include <QtSerialPort/QSerialPort>
|
#include <QtSerialPort/QSerialPort>
|
||||||
|
#include <QTime>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
// This class abstracts the comm port in a useful way and connects to
|
// This class abstracts the comm port in a useful way and connects to
|
||||||
// the command creator and command parser.
|
// the command creator and command parser.
|
||||||
|
@ -25,6 +27,8 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
void setUseRTSforPTT(bool useRTS);
|
void setUseRTSforPTT(bool useRTS);
|
||||||
void setRTS(bool rtsOn);
|
void setRTS(bool rtsOn);
|
||||||
|
void handleError(QSerialPort::SerialPortError error);
|
||||||
|
void init();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void receiveDataIn(); // from physical port
|
void receiveDataIn(); // from physical port
|
||||||
|
@ -58,7 +62,7 @@ private:
|
||||||
unsigned char buffer[256];
|
unsigned char buffer[256];
|
||||||
|
|
||||||
QString portName;
|
QString portName;
|
||||||
QSerialPort *port;
|
QSerialPort *port=Q_NULLPTR;
|
||||||
qint32 baudrate;
|
qint32 baudrate;
|
||||||
unsigned char stopbits;
|
unsigned char stopbits;
|
||||||
bool rolledBack;
|
bool rolledBack;
|
||||||
|
@ -82,6 +86,7 @@ private:
|
||||||
quint8 spectrumInformation;
|
quint8 spectrumInformation;
|
||||||
quint8 spectrumOutOfRange;
|
quint8 spectrumOutOfRange;
|
||||||
quint8 lastSpectrum = 0;
|
quint8 lastSpectrum = 0;
|
||||||
|
QTime lastDataReceived;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COMMHANDLER_H
|
#endif // COMMHANDLER_H
|
||||||
|
|
|
@ -217,7 +217,11 @@ bool paHandler::init(audioSetup setup)
|
||||||
void paHandler::setVolume(unsigned char volume)
|
void paHandler::setVolume(unsigned char volume)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
this->volume = audiopot[volume] * 5;
|
||||||
|
#else
|
||||||
this->volume = audiopot[volume];
|
this->volume = audiopot[volume];
|
||||||
|
#endif
|
||||||
|
|
||||||
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "setVolume: " << volume << "(" << this->volume << ")";
|
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "setVolume: " << volume << "(" << this->volume << ")";
|
||||||
}
|
}
|
||||||
|
@ -246,6 +250,18 @@ int paHandler::writeData(const void* inputBuffer, void* outputBuffer,
|
||||||
packet.data.append((char*)inputBuffer, nFrames*inFormat.channelCount()*sizeof(float));
|
packet.data.append((char*)inputBuffer, nFrames*inFormat.channelCount()*sizeof(float));
|
||||||
emit sendToConverter(packet);
|
emit sendToConverter(packet);
|
||||||
|
|
||||||
|
if (status == paInputUnderflow) {
|
||||||
|
isUnderrun = true;
|
||||||
|
}
|
||||||
|
else if (status == paInputOverflow) {
|
||||||
|
isOverrun = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isUnderrun = false;
|
||||||
|
isOverrun = false;
|
||||||
|
}
|
||||||
|
|
||||||
return paContinue;
|
return paContinue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,44 +277,24 @@ void paHandler::convertedOutput(audioPacket packet) {
|
||||||
qDebug(logAudio()) << (setup.isinput ? "Input" : "Output") << "Error writing audio!";
|
qDebug(logAudio()) << (setup.isinput ? "Input" : "Output") << "Error writing audio!";
|
||||||
}
|
}
|
||||||
const PaStreamInfo* info = Pa_GetStreamInfo(audio);
|
const PaStreamInfo* info = Pa_GetStreamInfo(audio);
|
||||||
|
currentLatency = packet.time.msecsTo(QTime::currentTime()) + (info->outputLatency * 1000);
|
||||||
//currentLatency = packet.time.msecsTo(QTime::currentTime()) + (info->outputLatency * 1000);
|
|
||||||
currentLatency = (info->outputLatency * 1000);
|
|
||||||
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
currentLatency = packet.time.msecsTo(QTime::currentTime()) + (outFormat.durationForBytes(audioOutput->bufferSize() - audioOutput->bytesFree()) / 1000);
|
|
||||||
|
|
||||||
if (audioDevice != Q_NULLPTR) {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
lastReceived = QTime::currentTime();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lastSentSeq = packet.seq;
|
|
||||||
|
|
||||||
*/
|
|
||||||
amplitude = packet.amplitude;
|
amplitude = packet.amplitude;
|
||||||
emit haveLevels(getAmplitude(), setup.latency, currentLatency, false, false);
|
emit haveLevels(getAmplitude(), setup.latency, currentLatency, isUnderrun, isOverrun);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void paHandler::convertedInput(audioPacket audio)
|
void paHandler::convertedInput(audioPacket packet)
|
||||||
{
|
{
|
||||||
if (audio.data.size() > 0) {
|
if (packet.data.size() > 0) {
|
||||||
emit haveAudioData(audio);
|
emit haveAudioData(packet);
|
||||||
amplitude = audio.amplitude;
|
amplitude = packet.amplitude;
|
||||||
emit haveLevels(getAmplitude(), setup.latency, currentLatency, false,false);
|
const PaStreamInfo* info = Pa_GetStreamInfo(audio);
|
||||||
|
currentLatency = packet.time.msecsTo(QTime::currentTime()) + (info->inputLatency * 1000);
|
||||||
|
emit haveLevels(getAmplitude(), setup.latency, currentLatency, isUnderrun, isOverrun);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,5 +313,5 @@ int paHandler::getLatency()
|
||||||
|
|
||||||
quint16 paHandler::getAmplitude()
|
quint16 paHandler::getAmplitude()
|
||||||
{
|
{
|
||||||
return amplitude;
|
return static_cast<quint16>(amplitude * 255.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
/* Logarithmic taper for volume control */
|
/* Logarithmic taper for volume control */
|
||||||
#include "audiotaper.h"
|
#include "audiotaper.h"
|
||||||
|
|
||||||
|
#include "audiohandler.h"
|
||||||
|
|
||||||
/* Audio converter class*/
|
/* Audio converter class*/
|
||||||
#include "audioconverter.h"
|
#include "audioconverter.h"
|
||||||
|
@ -25,7 +26,7 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
class paHandler : public QObject
|
class paHandler : public audioHandler
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -80,7 +81,7 @@ private:
|
||||||
quint32 lastSentSeq = 0;
|
quint32 lastSentSeq = 0;
|
||||||
|
|
||||||
quint16 currentLatency;
|
quint16 currentLatency;
|
||||||
quint16 amplitude = 0;
|
float amplitude=0.0;
|
||||||
qreal volume = 1.0;
|
qreal volume = 1.0;
|
||||||
|
|
||||||
audioSetup setup;
|
audioSetup setup;
|
||||||
|
@ -88,6 +89,8 @@ private:
|
||||||
QAudioFormat outFormat;
|
QAudioFormat outFormat;
|
||||||
audioConverter* converter = Q_NULLPTR;
|
audioConverter* converter = Q_NULLPTR;
|
||||||
QThread* converterThread = Q_NULLPTR;
|
QThread* converterThread = Q_NULLPTR;
|
||||||
|
bool isUnderrun = false;
|
||||||
|
bool isOverrun = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PAHANDLER_H
|
#endif // PAHANDLER_H
|
||||||
|
|
|
@ -41,7 +41,7 @@ bool rtHandler::init(audioSetup setup)
|
||||||
}
|
}
|
||||||
|
|
||||||
this->setup = setup;
|
this->setup = setup;
|
||||||
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "PortAudio handler starting:" << setup.name;
|
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "RTAudio handler starting:" << setup.name;
|
||||||
|
|
||||||
if (setup.portInt==-1)
|
if (setup.portInt==-1)
|
||||||
{
|
{
|
||||||
|
@ -90,9 +90,9 @@ bool rtHandler::init(audioSetup setup)
|
||||||
try {
|
try {
|
||||||
info = audio->getDeviceInfo(aParams.deviceId);
|
info = audio->getDeviceInfo(aParams.deviceId);
|
||||||
}
|
}
|
||||||
catch (RtAudioError& e) {
|
catch (RtAudioError e) {
|
||||||
qInfo(logAudio()) << "Device error:" << aParams.deviceId << ":" << QString::fromStdString(e.getMessage());
|
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "Device exception:" << aParams.deviceId << ":" << QString::fromStdString(e.getMessage());
|
||||||
return isInitialized;
|
goto errorHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.probed)
|
if (info.probed)
|
||||||
|
@ -106,7 +106,7 @@ bool rtHandler::init(audioSetup setup)
|
||||||
if (info.nativeFormats == 0)
|
if (info.nativeFormats == 0)
|
||||||
{
|
{
|
||||||
qCritical(logAudio()) << " No natively supported data formats!";
|
qCritical(logAudio()) << " No natively supported data formats!";
|
||||||
return false;
|
goto errorHandler;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
qDebug(logAudio()) << " Supported formats:" <<
|
qDebug(logAudio()) << " Supported formats:" <<
|
||||||
|
@ -133,7 +133,7 @@ bool rtHandler::init(audioSetup setup)
|
||||||
else if (outFormat.channelCount() < 1)
|
else if (outFormat.channelCount() < 1)
|
||||||
{
|
{
|
||||||
qCritical(logAudio()) << (setup.isinput ? "Input" : "Output") << "No channels found, aborting setup.";
|
qCritical(logAudio()) << (setup.isinput ? "Input" : "Output") << "No channels found, aborting setup.";
|
||||||
return false;
|
goto errorHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
aParams.nChannels = outFormat.channelCount();
|
aParams.nChannels = outFormat.channelCount();
|
||||||
|
@ -162,7 +162,7 @@ bool rtHandler::init(audioSetup setup)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
qCritical(logAudio()) << "Cannot find supported sample format!";
|
qCritical(logAudio()) << "Cannot find supported sample format!";
|
||||||
return false;
|
goto errorHandler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,17 +208,33 @@ bool rtHandler::init(audioSetup setup)
|
||||||
}
|
}
|
||||||
catch (RtAudioError& e) {
|
catch (RtAudioError& e) {
|
||||||
qInfo(logAudio()) << "Error opening:" << QString::fromStdString(e.getMessage());
|
qInfo(logAudio()) << "Error opening:" << QString::fromStdString(e.getMessage());
|
||||||
|
// Try again?
|
||||||
|
goto errorHandler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qCritical(logAudio()) << (setup.isinput ? "Input" : "Output") << QString::fromStdString(info.name) << "(" << aParams.deviceId << ") could not be probed, check audio configuration!";
|
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << QString::fromStdString(info.name) << "(" << aParams.deviceId << ") could not be probed, check audio configuration!";
|
||||||
|
goto errorHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->setVolume(setup.localAFgain);
|
this->setVolume(setup.localAFgain);
|
||||||
|
|
||||||
|
|
||||||
return isInitialized;
|
return isInitialized;
|
||||||
|
|
||||||
|
errorHandler:
|
||||||
|
if (retryConnectCount < 10) {
|
||||||
|
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "*** Attempting to reconnect to audio device in 500ms";
|
||||||
|
QTimer::singleShot(500, this, std::bind(&rtHandler::init, this, setup));
|
||||||
|
retryConnectCount++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qCritical(logAudio()) << (setup.isinput ? "Input" : "Output") << "*** Retry count exceeded, giving up!";
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -334,5 +350,5 @@ int rtHandler::getLatency()
|
||||||
|
|
||||||
quint16 rtHandler::getAmplitude()
|
quint16 rtHandler::getAmplitude()
|
||||||
{
|
{
|
||||||
return amplitude;
|
return static_cast<quint16>(amplitude * 255.0);
|
||||||
}
|
}
|
||||||
|
|
12
rthandler.h
12
rthandler.h
|
@ -6,7 +6,7 @@
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifndef Q_OS_LINUX
|
||||||
#include "RtAudio.h"
|
#include "RtAudio.h"
|
||||||
#else
|
#else
|
||||||
#include "rtaudio/RtAudio.h"
|
#include "rtaudio/RtAudio.h"
|
||||||
|
@ -16,6 +16,7 @@
|
||||||
#include <QAudioFormat>
|
#include <QAudioFormat>
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
|
||||||
/* wfview Packet types */
|
/* wfview Packet types */
|
||||||
|
@ -24,14 +25,14 @@
|
||||||
/* Logarithmic taper for volume control */
|
/* Logarithmic taper for volume control */
|
||||||
#include "audiotaper.h"
|
#include "audiotaper.h"
|
||||||
|
|
||||||
|
#include "audiohandler.h"
|
||||||
/* Audio converter class*/
|
/* Audio converter class*/
|
||||||
#include "audioconverter.h"
|
#include "audioconverter.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
class rtHandler : public QObject
|
class rtHandler : public audioHandler
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -96,7 +97,7 @@ private:
|
||||||
quint32 lastSentSeq = 0;
|
quint32 lastSentSeq = 0;
|
||||||
|
|
||||||
quint16 currentLatency;
|
quint16 currentLatency;
|
||||||
quint16 amplitude = 0;
|
float amplitude = 0.0;
|
||||||
qreal volume = 1.0;
|
qreal volume = 1.0;
|
||||||
|
|
||||||
audioSetup setup;
|
audioSetup setup;
|
||||||
|
@ -106,8 +107,9 @@ private:
|
||||||
QThread* converterThread = Q_NULLPTR;
|
QThread* converterThread = Q_NULLPTR;
|
||||||
QByteArray arrayBuffer;
|
QByteArray arrayBuffer;
|
||||||
bool isUnderrun = false;
|
bool isUnderrun = false;
|
||||||
bool isOverrun = true;
|
bool isOverrun = false;
|
||||||
QMutex audioMutex;
|
QMutex audioMutex;
|
||||||
|
int retryConnectCount = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // rtHandler_H
|
#endif // rtHandler_H
|
||||||
|
|
|
@ -43,21 +43,29 @@ void selectRadio::setInUse(quint8 radio, quint8 busy, QString user, QString ip)
|
||||||
ui->table->setItem(radio, 4, new QTableWidgetItem(ip));
|
ui->table->setItem(radio, 4, new QTableWidgetItem(ip));
|
||||||
for (int f = 0; f < 5; f++) {
|
for (int f = 0; f < 5; f++) {
|
||||||
if (busy == 1)
|
if (busy == 1)
|
||||||
|
{
|
||||||
ui->table->item(radio, f)->setBackground(Qt::darkGreen);
|
ui->table->item(radio, f)->setBackground(Qt::darkGreen);
|
||||||
|
}
|
||||||
else if (busy == 2)
|
else if (busy == 2)
|
||||||
|
{
|
||||||
ui->table->item(radio, f)->setBackground(Qt::red);
|
ui->table->item(radio, f)->setBackground(Qt::red);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
ui->table->item(radio, f)->setBackground(Qt::black);
|
ui->table->item(radio, f)->setBackground(Qt::black);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void selectRadio::on_table_cellClicked(int row, int col) {
|
void selectRadio::on_table_cellClicked(int row, int col) {
|
||||||
qInfo() << "Clicked on " << row << "," << col;
|
qInfo() << "Clicked on " << row << "," << col;
|
||||||
|
if (ui->table->item(row, col)->backgroundColor() != Qt::darkGreen) {
|
||||||
ui->table->selectRow(row);
|
ui->table->selectRow(row);
|
||||||
emit selectedRadio(row);
|
emit selectedRadio(row);
|
||||||
this->setVisible(false);
|
this->setVisible(false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void selectRadio::on_cancelButton_clicked() {
|
void selectRadio::on_cancelButton_clicked() {
|
||||||
|
|
|
@ -89,7 +89,7 @@ void servermain::openRig()
|
||||||
{
|
{
|
||||||
//qInfo(logSystem()) << "Got rig";
|
//qInfo(logSystem()) << "Got rig";
|
||||||
QMetaObject::invokeMethod(radio->rig, [=]() {
|
QMetaObject::invokeMethod(radio->rig, [=]() {
|
||||||
radio->rig->commSetup(radio->civAddr, radio->serialPort, radio->baudRate, QString("none"),prefs.tcpPort,0);
|
radio->rig->commSetup(radio->civAddr, radio->serialPort, radio->baudRate, QString("none"),prefs.tcpPort,radio->waterfallFormat);
|
||||||
}, Qt::QueuedConnection);
|
}, Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -458,6 +458,7 @@ void servermain::loadSettings()
|
||||||
settings->setValue("SerialPortBaud", defPrefs.serialPortBaud);
|
settings->setValue("SerialPortBaud", defPrefs.serialPortBaud);
|
||||||
settings->setValue("AudioInput", "default");
|
settings->setValue("AudioInput", "default");
|
||||||
settings->setValue("AudioOutput", "default");
|
settings->setValue("AudioOutput", "default");
|
||||||
|
settings->setValue("WaterfallFormat", 0);
|
||||||
}
|
}
|
||||||
settings->endArray();
|
settings->endArray();
|
||||||
|
|
||||||
|
@ -497,6 +498,7 @@ void servermain::loadSettings()
|
||||||
tempPrefs->baudRate = (quint32)settings->value("SerialPortBaud", defPrefs.serialPortBaud).toInt();
|
tempPrefs->baudRate = (quint32)settings->value("SerialPortBaud", defPrefs.serialPortBaud).toInt();
|
||||||
tempPrefs->rxAudioSetup.name = settings->value("AudioInput", "default").toString();
|
tempPrefs->rxAudioSetup.name = settings->value("AudioInput", "default").toString();
|
||||||
tempPrefs->txAudioSetup.name = settings->value("AudioOutput", "default").toString();
|
tempPrefs->txAudioSetup.name = settings->value("AudioOutput", "default").toString();
|
||||||
|
tempPrefs->waterfallFormat = settings->value("WaterfallFormat", 0).toInt();
|
||||||
tempPrefs->rxAudioSetup.type = prefs.audioSystem;
|
tempPrefs->rxAudioSetup.type = prefs.audioSystem;
|
||||||
tempPrefs->txAudioSetup.type = prefs.audioSystem;
|
tempPrefs->txAudioSetup.type = prefs.audioSystem;
|
||||||
|
|
||||||
|
|
|
@ -69,10 +69,10 @@ private:
|
||||||
|
|
||||||
uint16_t sendAudioSeq = 0;
|
uint16_t sendAudioSeq = 0;
|
||||||
|
|
||||||
QObject* rxaudio = Q_NULLPTR;
|
audioHandler* rxaudio = Q_NULLPTR;
|
||||||
QThread* rxAudioThread = Q_NULLPTR;
|
QThread* rxAudioThread = Q_NULLPTR;
|
||||||
|
|
||||||
QObject* txaudio = Q_NULLPTR;
|
audioHandler* txaudio = Q_NULLPTR;
|
||||||
QThread* txAudioThread = Q_NULLPTR;
|
QThread* txAudioThread = Q_NULLPTR;
|
||||||
|
|
||||||
QTimer* txAudioTimer = Q_NULLPTR;
|
QTimer* txAudioTimer = Q_NULLPTR;
|
||||||
|
|
|
@ -395,13 +395,13 @@ void udpServer::controlReceived()
|
||||||
connect(radio->txAudioThread, SIGNAL(finished()), radio->txaudio, SLOT(deleteLater()));
|
connect(radio->txAudioThread, SIGNAL(finished()), radio->txaudio, SLOT(deleteLater()));
|
||||||
|
|
||||||
// Not sure how we make this work in QT5.9?
|
// Not sure how we make this work in QT5.9?
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(7,10,0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(5,10,0))
|
||||||
QMetaObject::invokeMethod((audioHandler*)radio->txaudio, [=]() {
|
QMetaObject::invokeMethod(radio->txaudio, [=]() {
|
||||||
radio->txaudio->init(radio->txAudioSetup);
|
radio->txaudio->init(radio->txAudioSetup);
|
||||||
}, Qt::QueuedConnection);
|
}, Qt::QueuedConnection);
|
||||||
#else
|
#else
|
||||||
emit setupTxAudio(radio->txAudioSetup);
|
emit setupTxAudio(radio->txAudioSetup);
|
||||||
//#warning "QT 5.9 is not fully supported multiple rigs will NOT work!"
|
#warning "QT 5.9 is not fully supported multiple rigs will NOT work!"
|
||||||
#endif
|
#endif
|
||||||
hasTxAudio = datagram.senderAddress();
|
hasTxAudio = datagram.senderAddress();
|
||||||
|
|
||||||
|
@ -442,7 +442,7 @@ void udpServer::controlReceived()
|
||||||
connect(radio->rxAudioThread, SIGNAL(finished()), radio->rxaudio, SLOT(deleteLater()));
|
connect(radio->rxAudioThread, SIGNAL(finished()), radio->rxaudio, SLOT(deleteLater()));
|
||||||
connect(radio->rxaudio, SIGNAL(haveAudioData(audioPacket)), this, SLOT(receiveAudioData(audioPacket)));
|
connect(radio->rxaudio, SIGNAL(haveAudioData(audioPacket)), this, SLOT(receiveAudioData(audioPacket)));
|
||||||
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(7,10,0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(5,10,0))
|
||||||
QMetaObject::invokeMethod(radio->rxaudio, [=]() {
|
QMetaObject::invokeMethod(radio->rxaudio, [=]() {
|
||||||
radio->rxaudio->init(radio->rxAudioSetup);
|
radio->rxaudio->init(radio->rxAudioSetup);
|
||||||
}, Qt::QueuedConnection);
|
}, Qt::QueuedConnection);
|
||||||
|
|
|
@ -70,12 +70,13 @@ struct RIGCONFIG {
|
||||||
rigCapabilities rigCaps;
|
rigCapabilities rigCaps;
|
||||||
rigCommander* rig = Q_NULLPTR;
|
rigCommander* rig = Q_NULLPTR;
|
||||||
QThread* rigThread = Q_NULLPTR;
|
QThread* rigThread = Q_NULLPTR;
|
||||||
QObject* rxaudio = Q_NULLPTR;
|
audioHandler* rxaudio = Q_NULLPTR;
|
||||||
QThread* rxAudioThread = Q_NULLPTR;
|
QThread* rxAudioThread = Q_NULLPTR;
|
||||||
QObject* txaudio = Q_NULLPTR;
|
audioHandler* txaudio = Q_NULLPTR;
|
||||||
QThread* txAudioThread = Q_NULLPTR;
|
QThread* txAudioThread = Q_NULLPTR;
|
||||||
QTimer* rxAudioTimer = Q_NULLPTR;
|
QTimer* rxAudioTimer = Q_NULLPTR;
|
||||||
QTimer* connectTimer = Q_NULLPTR;
|
QTimer* connectTimer = Q_NULLPTR;
|
||||||
|
quint8 waterfallFormat;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
2
wfmain.h
2
wfmain.h
|
@ -41,7 +41,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include <portaudio.h>
|
#include <portaudio.h>
|
||||||
#ifdef Q_OS_WIN
|
#ifndef Q_OS_LINUX
|
||||||
#include "RtAudio.h"
|
#include "RtAudio.h"
|
||||||
#else
|
#else
|
||||||
#include "rtaudio/RtAudio.h"
|
#include "rtaudio/RtAudio.h"
|
||||||
|
|
|
@ -41,8 +41,8 @@ win32:DEFINES += __WINDOWS_WASAPI__
|
||||||
#linux:DEFINES += __LINUX_OSS__
|
#linux:DEFINES += __LINUX_OSS__
|
||||||
linux:DEFINES += __LINUX_PULSE__
|
linux:DEFINES += __LINUX_PULSE__
|
||||||
macx:DEFINES += __MACOSX_CORE__
|
macx:DEFINES += __MACOSX_CORE__
|
||||||
win32:SOURCES += ../rtaudio/RTAudio.cpp
|
!linux:SOURCES += ../rtaudio/RTAudio.cpp
|
||||||
win32:HEADERS += ../rtaudio/RTAUdio.h
|
!linux:HEADERS += ../rtaudio/RTAUdio.h
|
||||||
!linux:INCLUDEPATH += ../rtaudio
|
!linux:INCLUDEPATH += ../rtaudio
|
||||||
linux:LIBS += -lpulse -lpulse-simple -lrtaudio -lpthread
|
linux:LIBS += -lpulse -lpulse-simple -lrtaudio -lpthread
|
||||||
|
|
||||||
|
|
|
@ -38,9 +38,10 @@ win32:DEFINES += __WINDOWS_WASAPI__
|
||||||
#linux:DEFINES += __LINUX_OSS__
|
#linux:DEFINES += __LINUX_OSS__
|
||||||
linux:DEFINES += __LINUX_PULSE__
|
linux:DEFINES += __LINUX_PULSE__
|
||||||
macx:DEFINES += __MACOSX_CORE__
|
macx:DEFINES += __MACOSX_CORE__
|
||||||
win32:SOURCES += ../rtaudio/RTAudio.cpp
|
!linux:SOURCES += ../rtaudio/RTAudio.cpp
|
||||||
win32:HEADERS += ../rtaudio/RTAUdio.h
|
!linux:HEADERS += ../rtaudio/RTAUdio.h
|
||||||
!linux:INCLUDEPATH += ../rtaudio
|
!linux:INCLUDEPATH += ../rtaudio
|
||||||
|
|
||||||
linux:LIBS += -lpulse -lpulse-simple -lrtaudio -lpthread
|
linux:LIBS += -lpulse -lpulse-simple -lrtaudio -lpthread
|
||||||
|
|
||||||
win32:INCLUDEPATH += ../portaudio/include
|
win32:INCLUDEPATH += ../portaudio/include
|
||||||
|
|
Ładowanie…
Reference in New Issue