From 2e433ed71f63bfbd9b9507cfdc5092dadaf978bf Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Thu, 12 May 2022 15:53:48 +0100 Subject: [PATCH] Add pa/rt to server --- servermain.cpp | 1 + udpserver.cpp | 51 +++++++++++++++++++++++++++++++++++--------------- udpserver.h | 4 ++-- wfmain.cpp | 2 +- 4 files changed, 40 insertions(+), 18 deletions(-) diff --git a/servermain.cpp b/servermain.cpp index 6baed86..ce5a88f 100644 --- a/servermain.cpp +++ b/servermain.cpp @@ -498,6 +498,7 @@ void servermain::loadSettings() tempPrefs->rxAudioSetup.name = settings->value("AudioInput", "default").toString(); tempPrefs->txAudioSetup.name = settings->value("AudioOutput", "default").toString(); + QString tempPort = "auto"; if (tempPrefs->rigName=="") { diff --git a/udpserver.cpp b/udpserver.cpp index 3b5e505..255ba61 100644 --- a/udpserver.cpp +++ b/udpserver.cpp @@ -367,7 +367,22 @@ void udpServer::controlReceived() outAudio.isinput = false; - radio->txaudio = new audioHandler(); + + if (radio->txAudioSetup.type == qtAudio) { + radio->txaudio = new audioHandler(); + } + else if (radio->txAudioSetup.type == portAudio) { + radio->txaudio = new paHandler(); + } + else if (radio->txAudioSetup.type == rtAudio) { + radio->txaudio = new rtHandler(); + } + else + { + qCritical(logAudio()) << "Unsupported Transmit Audio Handler selected!"; + } + + //radio->txaudio = new audioHandler(); radio->txAudioThread = new QThread(this); radio->txAudioThread->setObjectName("txAudio()"); @@ -380,13 +395,13 @@ void udpServer::controlReceived() connect(radio->txAudioThread, SIGNAL(finished()), radio->txaudio, SLOT(deleteLater())); // Not sure how we make this work in QT5.9? -#if (QT_VERSION >= QT_VERSION_CHECK(5,10,0)) - QMetaObject::invokeMethod(radio->txaudio, [=]() { +#if (QT_VERSION >= QT_VERSION_CHECK(7,10,0)) + QMetaObject::invokeMethod((audioHandler*)radio->txaudio, [=]() { radio->txaudio->init(radio->txAudioSetup); }, Qt::QueuedConnection); #else 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 hasTxAudio = datagram.senderAddress(); @@ -395,21 +410,27 @@ void udpServer::controlReceived() } if ((!memcmp(radio->guid, current->guid, GUIDLEN) || config->rigs.size() == 1) && radio->rxaudio == Q_NULLPTR && !config->lan) { - #if !defined(PORTAUDIO) && !defined(RTAUDIO) - qInfo(logUdpServer()) << "Radio" << radio->rigName << "audio input(RX) :" << radio->rxAudioSetup.port.deviceName(); - qInfo(logUdpServer()) << "Radio" << radio->rigName << "audio output(TX) :" << radio->txAudioSetup.port.deviceName(); - #else - qInfo(logUdpServer()) << "Server audio input (RX):" << inAudio.name; - qInfo(logUdpServer()) << "Server audio output (TX):" << outAudio.name; - #endif - radio->rxAudioSetup.codec = current->rxCodec; radio->rxAudioSetup.sampleRate=current->rxSampleRate; radio->rxAudioSetup.latency = current->txBufferLen; radio->rxAudioSetup.isinput = true; memcpy(radio->rxAudioSetup.guid, radio->guid, GUIDLEN); - radio->rxaudio = new audioHandler(); + //radio->rxaudio = new audioHandler(); + if (radio->rxAudioSetup.type == qtAudio) { + radio->rxaudio = new audioHandler(); + } + else if (radio->rxAudioSetup.type == portAudio) { + radio->rxaudio = new paHandler(); + } + else if (radio->rxAudioSetup.type == rtAudio) { + radio->rxaudio = new rtHandler(); + } + else + { + qCritical(logAudio()) << "Unsupported Receive Audio Handler selected!"; + } + radio->rxAudioThread = new QThread(this); radio->rxAudioThread->setObjectName("rxAudio()"); @@ -421,12 +442,12 @@ void udpServer::controlReceived() connect(radio->rxAudioThread, SIGNAL(finished()), radio->rxaudio, SLOT(deleteLater())); connect(radio->rxaudio, SIGNAL(haveAudioData(audioPacket)), this, SLOT(receiveAudioData(audioPacket))); -#if (QT_VERSION >= QT_VERSION_CHECK(5,10,0)) +#if (QT_VERSION >= QT_VERSION_CHECK(7,10,0)) QMetaObject::invokeMethod(radio->rxaudio, [=]() { radio->rxaudio->init(radio->rxAudioSetup); }, Qt::QueuedConnection); #else - #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!" connect(this, SIGNAL(setupRxAudio(audioSetup)), radio->rxaudio, SLOT(init(audioSetup))); setupRxAudio(radio->rxAudioSetup); #endif diff --git a/udpserver.h b/udpserver.h index fe1682b..7b98e7c 100644 --- a/udpserver.h +++ b/udpserver.h @@ -70,9 +70,9 @@ struct RIGCONFIG { rigCapabilities rigCaps; rigCommander* rig = Q_NULLPTR; QThread* rigThread = Q_NULLPTR; - audioHandler* rxaudio = Q_NULLPTR; + QObject* rxaudio = Q_NULLPTR; QThread* rxAudioThread = Q_NULLPTR; - audioHandler* txaudio = Q_NULLPTR; + QObject* txaudio = Q_NULLPTR; QThread* txAudioThread = Q_NULLPTR; QTimer* rxAudioTimer = Q_NULLPTR; QTimer* connectTimer = Q_NULLPTR; diff --git a/wfmain.cpp b/wfmain.cpp index aea3a07..2b9ba68 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -466,7 +466,7 @@ void wfmain::removeRig() rigThread->disconnect(); rig->disconnect(); - + delete rigThread; delete rig; rig = Q_NULLPTR;