From 449b017527c5a19f85705d2b3e0ec053b66741c1 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Wed, 3 Mar 2021 09:49:49 +0000 Subject: [PATCH] remove redundant code from audiohandler --- audiohandler.cpp | 13 ++++--------- audiohandler.h | 4 ++-- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/audiohandler.cpp b/audiohandler.cpp index 25a182a..98d166d 100644 --- a/audiohandler.cpp +++ b/audiohandler.cpp @@ -737,7 +737,7 @@ audioHandler::audioHandler(QObject* parent) : isUlaw(false), latency(0), isInput(0), - volume(1.0f) + chunkAvailable(false) { } @@ -897,11 +897,6 @@ void audioHandler::start() } } -void audioHandler::setVolume(float volume) -{ - volume = volume; -} - void audioHandler::flush() { @@ -941,13 +936,13 @@ qint64 audioHandler::readData(char* data, qint64 maxlen) //qDebug(logAudio()) << "Looking for: " << maxlen << " bytes"; + // We must lock the mutex for the entire time that the buffer may be modified. + QMutexLocker locker(&mutex); // Get next packet from buffer. if (!audioBuffer.isEmpty()) { - // We must lock the mutex for the entire time that the buffer may be modified. - QMutexLocker locker(&mutex); - + // Output buffer is ALWAYS 16 bit. int divisor = 16 / radioSampleBits; diff --git a/audiohandler.h b/audiohandler.h index 27f86e7..4dae53e 100644 --- a/audiohandler.h +++ b/audiohandler.h @@ -73,15 +73,15 @@ private: QMutex mutex; - bool chunkAvailable; bool isInitialized; QAudioOutput* audioOutput; QAudioInput* audioInput; bool isUlaw; quint16 latency; bool isInput; // Used to determine whether input or output audio - float volume; int chunkSize; + bool chunkAvailable; + quint16 lastSeq; QAudioFormat format;