diff --git a/packettypes.h b/packettypes.h index cdb7c9c..51888ce 100644 --- a/packettypes.h +++ b/packettypes.h @@ -16,7 +16,7 @@ #define STALE_CONNECTION 15 // Not heard from in this many seconds #define BUFSIZE 500 // Number of packets to buffer #define MAX_MISSING 50 // Make the maximum number of possible missing packets much less than total buffer size! -#define TXAUDIO_PERIOD 20 +#define AUDIO_PERIOD 20 #define GUIDLEN 16 diff --git a/servermain.cpp b/servermain.cpp index c83ee18..ea3d29d 100644 --- a/servermain.cpp +++ b/servermain.cpp @@ -595,7 +595,7 @@ void servermain::loadSettings() && deviceInfo.realm() == "wasapi" #endif ) { - qDebug(logSystem()) << "Audio output: " << deviceInfo.deviceName() << "Realm:" << deviceInfo.realm(); + qDebug(logSystem()) << "Audio output: " << deviceInfo.deviceName(); tempPrefs->txAudioSetup.port = deviceInfo; txDeviceFound = true; } @@ -608,7 +608,7 @@ void servermain::loadSettings() && deviceInfo.realm() == "wasapi" #endif ) { - qDebug(logSystem()) << "Audio input: " << deviceInfo.deviceName() << "Realm:" << deviceInfo.realm(); + qDebug(logSystem()) << "Audio input: " << deviceInfo.deviceName(); tempPrefs->rxAudioSetup.port = deviceInfo; rxDeviceFound = true; } @@ -715,5 +715,6 @@ void servermain::powerRigOff() void servermain::receiveStateInfo(rigstate* state) { qInfo("Received rig state for wfmain"); + Q_UNUSED(state); //rigState = state; } diff --git a/udphandler.cpp b/udphandler.cpp index 2bb5a88..0f6f6c3 100644 --- a/udphandler.cpp +++ b/udphandler.cpp @@ -1005,7 +1005,7 @@ void udpAudio::dataReceived() control_packet_t in = (control_packet_t)r.constData(); if (in->type == 0x04 && enableTx) { - txAudioTimer->start(TXAUDIO_PERIOD); + txAudioTimer->start(AUDIO_PERIOD); } break; diff --git a/udpserver.cpp b/udpserver.cpp index 8ec7255..c983033 100644 --- a/udpserver.cpp +++ b/udpserver.cpp @@ -363,7 +363,7 @@ void udpServer::controlReceived() radio->txAudioThread->start(QThread::TimeCriticalPriority); - //connect(this, SIGNAL(setupTxAudio(audioSetup)), txaudio, SLOT(init(audioSetup))); + connect(this, SIGNAL(setupTxAudio(audioSetup)), radio->txaudio, SLOT(init(audioSetup))); connect(radio->txAudioThread, SIGNAL(finished()), radio->txaudio, SLOT(deleteLater())); // Not sure how we make this work in QT5.9? @@ -372,10 +372,9 @@ void udpServer::controlReceived() radio->txaudio->init(radio->txAudioSetup); }, Qt::QueuedConnection); #else - #warning "QT 5.9 is not fully supported" + emit setupTxAudio(radio->txAudioSetup) + #warning "QT 5.9 is not fully supported multiple rigs will NOT work!" #endif - - emit setupTxAudio(outAudio); hasTxAudio = datagram.senderAddress(); connect(this, SIGNAL(haveAudioData(audioPacket)), radio->txaudio, SLOT(incomingAudio(audioPacket))); @@ -404,6 +403,7 @@ void udpServer::controlReceived() radio->rxAudioThread->start(QThread::TimeCriticalPriority); + connect(this, SIGNAL(setupRxAudio(audioSetup)), radio->rxaudio, SLOT(init(audioSetup))); connect(radio->rxAudioThread, SIGNAL(finished()), radio->rxaudio, SLOT(deleteLater())); #if (QT_VERSION >= QT_VERSION_CHECK(5,10,0)) @@ -411,13 +411,14 @@ void udpServer::controlReceived() radio->rxaudio->init(radio->rxAudioSetup); }, Qt::QueuedConnection); #else - #warning "QT 5.9 is not fully supported" + #warning "QT 5.9 is not fully supported multiple rigs will NOT work!" + setupRxAudio(radio->rxAudioSetup); #endif radio->rxAudioTimer = new QTimer(); radio->rxAudioTimer->setTimerType(Qt::PreciseTimer); connect(radio->rxAudioTimer, &QTimer::timeout, this, std::bind(&udpServer::sendRxAudio, this)); - radio->rxAudioTimer->start(TXAUDIO_PERIOD); + radio->rxAudioTimer->start(AUDIO_PERIOD); } } @@ -578,13 +579,13 @@ void udpServer::civReceived() if (!memcmp(radio->guid, current->guid, sizeof(radio->guid))) { // Only send to the rig that it belongs to! - #if (QT_VERSION >= QT_VERSION_CHECK(5,10,0)) QMetaObject::invokeMethod(radio->rig, [=]() { radio->rig->dataFromServer(r.mid(0x15));; }, Qt::DirectConnection); #else - #warning "QT 5.9 is not fully supported" + #warning "QT 5.9 is not fully supported, multiple rigs will NOT work!" + emit haveDataFromServer(r.mid(0x15)); #endif } @@ -1714,13 +1715,13 @@ void udpServer::sendRetransmitRequest(CLIENT* c) QByteArray missingSeqs; - QTime missingTime = QTime::currentTime(); + //QTime missingTime = QTime::currentTime(); if (c->missMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) { for (auto it = c->rxMissing.begin(); it != c->rxMissing.end(); ++it) { - if (&it != Q_NULLPTR && it.value() < 4) + if (&it.key() != Q_NULLPTR && it.value() < 4) { missingSeqs.append(it.key() & 0xff); missingSeqs.append(it.key() >> 8 & 0xff); diff --git a/wfmain.cpp b/wfmain.cpp index 48af1df..d2955e7 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -1139,14 +1139,26 @@ void wfmain::setAudioDevicesUI() // Enumerate audio devices, need to do before settings are loaded. const auto audioOutputs = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput); for (const QAudioDeviceInfo& deviceInfo : audioOutputs) { - ui->audioOutputCombo->addItem(deviceInfo.deviceName(), QVariant::fromValue(deviceInfo)); - ui->serverTXAudioOutputCombo->addItem(deviceInfo.deviceName(), QVariant::fromValue(deviceInfo)); +#ifdef Q_OS_WIN + if (deviceInfo.realm() == "wasapi") { +#endif + ui->audioOutputCombo->addItem(deviceInfo.deviceName(), QVariant::fromValue(deviceInfo)); + ui->serverTXAudioOutputCombo->addItem(deviceInfo.deviceName(), QVariant::fromValue(deviceInfo)); +#ifdef Q_OS_WIN + } +#endif } const auto audioInputs = QAudioDeviceInfo::availableDevices(QAudio::AudioInput); for (const QAudioDeviceInfo& deviceInfo : audioInputs) { - ui->audioInputCombo->addItem(deviceInfo.deviceName(), QVariant::fromValue(deviceInfo)); - ui->serverRXAudioInputCombo->addItem(deviceInfo.deviceName(), QVariant::fromValue(deviceInfo)); +#ifdef Q_OS_WIN + if (deviceInfo.realm() == "wasapi") { +#endif + ui->audioInputCombo->addItem(deviceInfo.deviceName(), QVariant::fromValue(deviceInfo)); + ui->serverRXAudioInputCombo->addItem(deviceInfo.deviceName(), QVariant::fromValue(deviceInfo)); +#ifdef Q_OS_WIN + } +#endif } // Set these to default audio devices initially. rxSetup.port = QAudioDeviceInfo::defaultOutputDevice();