From 7cb9ae9195af04b1bf237f4d508e7b0af7664aa0 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Mon, 22 Mar 2021 15:16:41 +0000 Subject: [PATCH] Small fixes to UDP server --- audiohandler.cpp | 2 ++ udpserver.cpp | 28 +++++++++++++--------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/audiohandler.cpp b/audiohandler.cpp index 0351ece..31c2b27 100644 --- a/audiohandler.cpp +++ b/audiohandler.cpp @@ -745,9 +745,11 @@ audioHandler::~audioHandler() { stop(); if (audioOutput != Q_NULLPTR) { + audioOutput->stop(); delete audioOutput; } if (audioInput != Q_NULLPTR) { + audioInput->stop(); delete audioInput; } diff --git a/udpserver.cpp b/udpserver.cpp index 8b10c13..8c96f18 100644 --- a/udpserver.cpp +++ b/udpserver.cpp @@ -649,27 +649,25 @@ void udpServer::audioReceived() current->seqPrefix++; } - // 0xac is the smallest possible audio packet. - audioPacket tempAudio; - tempAudio.seq = (quint32)current->seqPrefix << 16 | in->seq; - tempAudio.time = QTime::currentTime();; - tempAudio.sent = 0; - tempAudio.datain = r.mid(0x18); - // Prefer signal/slot to forward audio as it is thread/safe - // Need to do more testing but latency appears fine. - //if (hasTxAudio == datagram.senderAddress()) - //{ - qDebug(logUdpServer()) << "sending tx audio " << in->seq; + if (hasTxAudio == datagram.senderAddress()) + { + // 0xac is the smallest possible audio packet. + audioPacket tempAudio; + tempAudio.seq = (quint32)current->seqPrefix << 16 | in->seq; + tempAudio.time = QTime::currentTime();; + tempAudio.sent = 0; + tempAudio.datain = r.mid(0x18); + //qDebug(logUdpServer()) << "sending tx audio " << in->seq; emit haveAudioData(tempAudio); - //} - //rxaudio->incomingAudio(tempAudio); + } } break; } } - commonReceived(&audioClients, current, r); - + if (current != Q_NULLPTR) { + commonReceived(&audioClients, current, r); + } } }