From da53f5371bbeb35b10cbb831b83b74e1bdd771f9 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Sat, 14 Aug 2021 12:03:04 +0100 Subject: [PATCH] Remove extra opus debugging --- audiohandler.cpp | 33 ++++----------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/audiohandler.cpp b/audiohandler.cpp index 7e073cf..b48e755 100644 --- a/audiohandler.cpp +++ b/audiohandler.cpp @@ -488,23 +488,12 @@ void audioHandler::incomingAudio(audioPacket inPacket) if (setup.codec == 0x40 || setup.codec == 0x80) { unsigned char* in = (unsigned char*)inPacket.data.data(); - qInfo(logAudio()) << "Opus Packet Received: << " << opus_packet_get_nb_channels(in) - << "channels, " << opus_packet_get_nb_samples(in, inPacket.data.size(), setup.samplerate) - << "samples" << opus_decoder_get_nb_samples(decoder, in, inPacket.data.size()) << "decoded samples"; - qInfo(logAudio()) << "Radio: channels" << setup.radioChan << "samplerate" << setup.samplerate; /* Decode the frame. */ - //QByteArray outPacket(this->chunkSize * sizeof(qint16) * setup.radioChan, (char)0xff); // Preset the output buffer size. QByteArray outPacket((setup.samplerate / 50) * sizeof(qint16) * setup.radioChan, (char)0xff); // Preset the output buffer size. qint16* out = (qint16*)outPacket.data(); int nSamples = 0; - if (lastSentSeq > 0 && lastSentSeq+1 < inPacket.seq) - { - nSamples = opus_decode(decoder, NULL, 0, out, (setup.samplerate / 50), 1); - } - else { - nSamples = opus_decode(decoder, in, inPacket.data.size(), out, (setup.samplerate / 50), 0); - } + nSamples = opus_decode(decoder, in, inPacket.data.size(), out, (setup.samplerate / 50), 0); if (nSamples < 0) { @@ -512,17 +501,13 @@ void audioHandler::incomingAudio(audioPacket inPacket) return; } else { - if (int(nSamples * sizeof(qint16)) != outPacket.size()) + if (int(nSamples * sizeof(qint16) * setup.radioChan) != outPacket.size()) { qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "Opus decoder mismatch: nBytes:" << nSamples * sizeof(qint16) << "outPacket:" << outPacket.size(); - outPacket.resize(nSamples * sizeof(qint16)); + outPacket.resize(nSamples * sizeof(qint16) * setup.radioChan); } - qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "Opus decoded" << inPacket.data.size() << "bytes, into" << outPacket.length() << "bytes"; inPacket.data.clear(); inPacket.data = outPacket; // Replace incoming data with converted. - //qint16* in16 = (qint16*)inPacket.data.data(); - //for (int i = 0; i < inPacket.data.length() / 2; i++) - // in16[i] = qToLittleEndian(in16[i]); } } @@ -655,8 +640,6 @@ void audioHandler::getNextAudioChunk(QByteArray& ret) if (err) { qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "Resampler error " << err << " inFrames:" << inFrames << " outFrames:" << outFrames; } - //qInfo(logAudio()) << "Resampler run " << err << " inFrames:" << inFrames << " outFrames:" << outFrames; - //qInfo(logAudio()) << "Resampler run inLen:" << packet->datain.length() << " outLen:" << packet->dataout.length(); packet.data.clear(); packet.data = outPacket; // Copy output packet back to input buffer. } @@ -685,9 +668,6 @@ void audioHandler::getNextAudioChunk(QByteArray& ret) { //Are we using the opus codec? qint16* in = (qint16*)packet.data.data(); - // Convert from little endian - //for (int i = 0; i < packet.data.length() / 2; i++) - // in[i] = qToBigEndian(in[i]); /* Encode the frame. */ QByteArray outPacket(1275, (char)0xff); // Preset the output buffer size to MAXIMUM possible Opus frame size @@ -700,15 +680,10 @@ void audioHandler::getNextAudioChunk(QByteArray& ret) return; } else { - outPacket.resize(nbBytes); - qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "Opus encoded" << packet.data.length() << "bytes, into" << outPacket.length() << "bytes"; + outPacket.resize(setup.radioChan); packet.data.clear(); packet.data = outPacket; // Replace incoming data with converted. } - qInfo(logAudio()) << "Opus Packet To Send: << " << opus_packet_get_nb_channels(out) - << "channels, " << opus_packet_get_nb_samples(out, outPacket.size(), setup.samplerate); - qInfo(logAudio()) << "Radio: channels" << setup.radioChan << "samplerate" << setup.samplerate; - } else if (setup.bits == 8) {