From 4ca21b84cb512a16423beceec2607d61be9128eb Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Mon, 11 Apr 2022 00:33:39 +0100 Subject: [PATCH] More opus changes --- audiohandler.cpp | 8 ++++---- audiohandler.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/audiohandler.cpp b/audiohandler.cpp index 98fb87c..61bb905 100644 --- a/audiohandler.cpp +++ b/audiohandler.cpp @@ -399,7 +399,7 @@ void audioHandler::getNextAudioChunk() { tempBuf.data.append(audioDevice->readAll()); - if (tempBuf.data.length() <= format.bytesForDuration(setup.blockSize * 2000)) { + if (tempBuf.data.length() <= getAudioSize(setup.latency,format)) { return; } @@ -407,9 +407,9 @@ void audioHandler::getNextAudioChunk() livePacket.time= QTime::currentTime(); livePacket.sent = 0; memcpy(&livePacket.guid, setup.guid, GUIDLEN); - livePacket.data = tempBuf.data.left(format.bytesForDuration(setup.blockSize*2000)); - tempBuf.data.remove(0, format.bytesForDuration(setup.blockSize * 2000)); - //qDebug(logAudio()) << "Sending audio len" << livePacket.data.length() << "remaining" << tempBuf.data.length(); + livePacket.data = tempBuf.data.left(getAudioSize(setup.blockSize,format)); + tempBuf.data.remove(0, getAudioSize(setup.blockSize,format)); + qInfo(logAudio()) << "Sending audio len" << livePacket.data.length() << "remaining" << tempBuf.data.length(); if (livePacket.data.length() > 0) { Eigen::VectorXf samplesF; diff --git a/audiohandler.h b/audiohandler.h index ace1e5f..edbbd82 100644 --- a/audiohandler.h +++ b/audiohandler.h @@ -153,7 +153,7 @@ static inline qint64 getAudioSize(qint64 timeInMs, const QAudioFormat& format) #ifdef Q_OS_LINUX qint64 value = qint64(qCeil(format.channelCount() * (format.sampleSize() / 8) * format.sampleRate() / qreal(1000) * timeInMs)); #else - qint64 value = qint64(qCeil(format.channelCount() * (format.sampleSize() / 8) * format.sampleRate() / qreal(10000) * timeInMs)); + qint64 value = qint64(qCeil(format.channelCount() * (format.sampleSize() / 8) * format.sampleRate() / qreal(1000) * timeInMs)); #endif