From 43f423f1ad6d24dbac1d9365254da59b127eeb59 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Mon, 2 May 2022 13:53:49 +0100 Subject: [PATCH] Tidy getnextaudiochunk() --- audiohandler.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/audiohandler.cpp b/audiohandler.cpp index 26ec64c..38b1f75 100644 --- a/audiohandler.cpp +++ b/audiohandler.cpp @@ -448,15 +448,11 @@ void audioHandler::getNextAudioChunk() tempBuf.data.append(audioDevice->readAll()); - if (tempBuf.data.length() < format.bytesForDuration(setup.blockSize * 1000)) { - return; - } - - audioPacket livePacket; - livePacket.time= QTime::currentTime(); - livePacket.sent = 0; - memcpy(&livePacket.guid, setup.guid, GUIDLEN); - while (tempBuf.data.length() > format.bytesForDuration(setup.blockSize * 1000)) { + while (tempBuf.data.length() >= format.bytesForDuration(setup.blockSize * 1000)) { + audioPacket livePacket; + livePacket.time = QTime::currentTime(); + livePacket.sent = 0; + memcpy(&livePacket.guid, setup.guid, GUIDLEN); QTime startProcessing = QTime::currentTime(); livePacket.data.clear(); livePacket.data = tempBuf.data.mid(0, format.bytesForDuration(setup.blockSize * 1000));