kopia lustrzana https://gitlab.com/eliggett/wfview
Change udpserver to use new audiosetup struct properly.
rodzic
d8a0431e36
commit
eb70b92aed
|
@ -2,9 +2,10 @@
|
||||||
#include "logcategories.h"
|
#include "logcategories.h"
|
||||||
|
|
||||||
#define STALE_CONNECTION 15
|
#define STALE_CONNECTION 15
|
||||||
|
udpServer::udpServer(SERVERCONFIG config, audioSetup outAudio, audioSetup inAudio) :
|
||||||
udpServer::udpServer(SERVERCONFIG config) :
|
config(config),
|
||||||
config(config)
|
outAudio(outAudio),
|
||||||
|
inAudio(inAudio)
|
||||||
{
|
{
|
||||||
qInfo(logUdpServer()) << "Starting udp server";
|
qInfo(logUdpServer()) << "Starting udp server";
|
||||||
}
|
}
|
||||||
|
@ -373,29 +374,23 @@ void udpServer::controlReceived()
|
||||||
|
|
||||||
if (txaudio == Q_NULLPTR)
|
if (txaudio == Q_NULLPTR)
|
||||||
{
|
{
|
||||||
bool uLaw = false;
|
outAudio.ulaw = false;
|
||||||
quint8 channels = 1;
|
outAudio.radioChan = 1;
|
||||||
quint8 samples = 8;
|
outAudio.bits = 8;
|
||||||
txSampleRate = current->txSampleRate;
|
outAudio.codec = current->txCodec;
|
||||||
txCodec = current->txCodec;
|
|
||||||
|
|
||||||
if (current->txCodec == 0x01 || current->txCodec == 0x20) {
|
if (current->txCodec == 0x01 || current->txCodec == 0x20) {
|
||||||
uLaw = true;
|
outAudio.ulaw = true;
|
||||||
}
|
}
|
||||||
if (current->txCodec == 0x08 || current->txCodec == 0x10 || current->txCodec == 0x20) {
|
if (current->txCodec == 0x08 || current->txCodec == 0x10 || current->txCodec == 0x20) {
|
||||||
channels = 2;
|
outAudio.radioChan = 2;
|
||||||
}
|
}
|
||||||
if (current->txCodec == 0x04 || current->txCodec == 0x10) {
|
if (current->txCodec == 0x04 || current->txCodec == 0x10) {
|
||||||
samples = 16;
|
outAudio.bits = 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
//setup.port = config.audioOutput;
|
outAudio.samplerate = current->txSampleRate;
|
||||||
setup.bits = samples;
|
outAudio.latency = current->txBufferLen;
|
||||||
setup.radioChan = channels;
|
|
||||||
setup.ulaw = uLaw;
|
|
||||||
setup.samplerate = current->txSampleRate;
|
|
||||||
setup.latency = current->txBufferLen;
|
|
||||||
setup.isinput = false;
|
|
||||||
|
|
||||||
txaudio = new audioHandler();
|
txaudio = new audioHandler();
|
||||||
txAudioThread = new QThread(this);
|
txAudioThread = new QThread(this);
|
||||||
|
@ -407,7 +402,7 @@ void udpServer::controlReceived()
|
||||||
connect(txAudioThread, SIGNAL(finished()), txaudio, SLOT(deleteLater()));
|
connect(txAudioThread, SIGNAL(finished()), txaudio, SLOT(deleteLater()));
|
||||||
|
|
||||||
|
|
||||||
emit setupTxAudio(setup);
|
emit setupTxAudio(outAudio);
|
||||||
hasTxAudio = datagram.senderAddress();
|
hasTxAudio = datagram.senderAddress();
|
||||||
|
|
||||||
connect(this, SIGNAL(haveAudioData(audioPacket)), txaudio, SLOT(incomingAudio(audioPacket)));
|
connect(this, SIGNAL(haveAudioData(audioPacket)), txaudio, SLOT(incomingAudio(audioPacket)));
|
||||||
|
@ -415,22 +410,26 @@ void udpServer::controlReceived()
|
||||||
}
|
}
|
||||||
if (rxaudio == Q_NULLPTR)
|
if (rxaudio == Q_NULLPTR)
|
||||||
{
|
{
|
||||||
bool uLaw = false;
|
inAudio.ulaw = false;
|
||||||
quint8 channels = 1;
|
inAudio.radioChan = 1;
|
||||||
quint8 samples = 8;
|
inAudio.bits = 8;
|
||||||
|
inAudio.codec = current->txCodec;
|
||||||
|
|
||||||
rxSampleRate = current->rxSampleRate;
|
rxSampleRate = current->rxSampleRate;
|
||||||
rxCodec = current->rxCodec;
|
rxCodec = current->rxCodec;
|
||||||
|
|
||||||
if (current->rxCodec == 0x01 || current->rxCodec == 0x20) {
|
if (current->rxCodec == 0x01 || current->rxCodec == 0x20) {
|
||||||
uLaw = true;
|
inAudio.ulaw = true;
|
||||||
}
|
}
|
||||||
if (current->rxCodec == 0x08 || current->rxCodec == 0x10 || current->rxCodec == 0x20) {
|
if (current->rxCodec == 0x08 || current->rxCodec == 0x10 || current->rxCodec == 0x20) {
|
||||||
channels = 2;
|
inAudio.radioChan = 2;
|
||||||
}
|
}
|
||||||
if (current->rxCodec == 0x04 || current->rxCodec == 0x10) {
|
if (current->rxCodec == 0x04 || current->rxCodec == 0x10) {
|
||||||
samples = 16;
|
inAudio.bits = 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inAudio.samplerate = current->rxSampleRate;
|
||||||
|
|
||||||
rxaudio = new audioHandler();
|
rxaudio = new audioHandler();
|
||||||
rxAudioThread = new QThread(this);
|
rxAudioThread = new QThread(this);
|
||||||
rxaudio->moveToThread(rxAudioThread);
|
rxaudio->moveToThread(rxAudioThread);
|
||||||
|
@ -439,16 +438,7 @@ void udpServer::controlReceived()
|
||||||
connect(this, SIGNAL(setupRxAudio(audioSetup)), rxaudio, SLOT(init(audioSetup)));
|
connect(this, SIGNAL(setupRxAudio(audioSetup)), rxaudio, SLOT(init(audioSetup)));
|
||||||
connect(rxAudioThread, SIGNAL(finished()), rxaudio, SLOT(deleteLater()));
|
connect(rxAudioThread, SIGNAL(finished()), rxaudio, SLOT(deleteLater()));
|
||||||
|
|
||||||
setup.bits = samples;
|
emit setupRxAudio(inAudio);
|
||||||
setup.radioChan = channels;
|
|
||||||
setup.ulaw = uLaw;
|
|
||||||
setup.samplerate = current->rxSampleRate;
|
|
||||||
setup.latency = 150;
|
|
||||||
setup.isinput = true;
|
|
||||||
//setup.port = config.audioInput;
|
|
||||||
setup.resampleQuality = config.resampleQuality;
|
|
||||||
|
|
||||||
emit setupRxAudio(setup);
|
|
||||||
|
|
||||||
rxAudioTimer = new QTimer();
|
rxAudioTimer = new QTimer();
|
||||||
rxAudioTimer->setTimerType(Qt::PreciseTimer);
|
rxAudioTimer->setTimerType(Qt::PreciseTimer);
|
||||||
|
|
|
@ -39,7 +39,7 @@ class udpServer : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
udpServer(SERVERCONFIG config);
|
udpServer(SERVERCONFIG config,audioSetup outAudio, audioSetup inAudio);
|
||||||
~udpServer();
|
~udpServer();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -163,6 +163,9 @@ private:
|
||||||
audioHandler* txaudio = Q_NULLPTR;
|
audioHandler* txaudio = Q_NULLPTR;
|
||||||
QThread* txAudioThread = Q_NULLPTR;
|
QThread* txAudioThread = Q_NULLPTR;
|
||||||
|
|
||||||
|
audioSetup inAudio;
|
||||||
|
audioSetup outAudio;
|
||||||
|
|
||||||
QTimer* rxAudioTimer=Q_NULLPTR;
|
QTimer* rxAudioTimer=Q_NULLPTR;
|
||||||
quint16 rxSampleRate = 0;
|
quint16 rxSampleRate = 0;
|
||||||
quint16 txSampleRate = 0;
|
quint16 txSampleRate = 0;
|
||||||
|
|
15
wfmain.cpp
15
wfmain.cpp
|
@ -764,17 +764,8 @@ void wfmain::setServerToPrefs()
|
||||||
// Start server if enabled in config
|
// Start server if enabled in config
|
||||||
if (serverConfig.enabled) {
|
if (serverConfig.enabled) {
|
||||||
serverConfig.lan = prefs.enableLAN;
|
serverConfig.lan = prefs.enableLAN;
|
||||||
if (!serverConfig.lan) {
|
|
||||||
// How do we setup the audio for server????
|
|
||||||
serverConfig.resampleQuality = udpPrefs.resampleQuality;
|
|
||||||
serverConfig.audioInput = udpPrefs.audioInput;
|
|
||||||
serverConfig.audioOutput = udpPrefs.audioOutput;
|
|
||||||
serverConfig.baudRate = prefs.serialPortBaud;
|
|
||||||
serverConfig.audioInput = udpPrefs.audioInput;
|
|
||||||
serverConfig.audioOutput = udpPrefs.audioOutput;
|
|
||||||
}
|
|
||||||
|
|
||||||
udp = new udpServer(serverConfig);
|
udp = new udpServer(serverConfig,rxSetup,txSetup);
|
||||||
|
|
||||||
serverThread = new QThread(this);
|
serverThread = new QThread(this);
|
||||||
|
|
||||||
|
@ -1306,7 +1297,7 @@ void wfmain::loadSettings()
|
||||||
txSetup.port = v.value<QAudioDeviceInfo>();
|
txSetup.port = v.value<QAudioDeviceInfo>();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
ui->audioOutputCombo->blockSignals(false);
|
ui->audioInputCombo->blockSignals(false);
|
||||||
|
|
||||||
rxSetup.resampleQuality = settings->value("ResampleQuality", udpDefPrefs.resampleQuality).toInt();
|
rxSetup.resampleQuality = settings->value("ResampleQuality", udpDefPrefs.resampleQuality).toInt();
|
||||||
txSetup.resampleQuality = rxSetup.resampleQuality;
|
txSetup.resampleQuality = rxSetup.resampleQuality;
|
||||||
|
@ -3736,6 +3727,7 @@ void wfmain::on_audioOutputCombo_currentIndexChanged(int value)
|
||||||
rxSetup.port = v.value<QAudioDeviceInfo>();
|
rxSetup.port = v.value<QAudioDeviceInfo>();
|
||||||
#endif
|
#endif
|
||||||
rxSetup.name = ui->audioOutputCombo->itemText(value);
|
rxSetup.name = ui->audioOutputCombo->itemText(value);
|
||||||
|
qDebug(logGui()) << "Changed default audio output to:" << rxSetup.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wfmain::on_audioInputCombo_currentIndexChanged(int value)
|
void wfmain::on_audioInputCombo_currentIndexChanged(int value)
|
||||||
|
@ -3748,6 +3740,7 @@ void wfmain::on_audioInputCombo_currentIndexChanged(int value)
|
||||||
txSetup.port = v.value<QAudioDeviceInfo>();
|
txSetup.port = v.value<QAudioDeviceInfo>();
|
||||||
#endif
|
#endif
|
||||||
txSetup.name = ui->audioInputCombo->itemText(value);
|
txSetup.name = ui->audioInputCombo->itemText(value);
|
||||||
|
qDebug(logGui()) << "Changed default audio input to:" << txSetup.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wfmain::on_audioSampleRateCombo_currentIndexChanged(QString text)
|
void wfmain::on_audioSampleRateCombo_currentIndexChanged(QString text)
|
||||||
|
|
Ładowanie…
Reference in New Issue