kopia lustrzana https://gitlab.com/eliggett/wfview
Merge branch 'wfserver' of https://gitlab.com/eliggett/wfview into wfserver
commit
066c1b58ac
|
@ -82,10 +82,9 @@ audioConverter::~audioConverter()
|
|||
bool audioConverter::convert(audioPacket audio)
|
||||
{
|
||||
|
||||
if (audio.data.size() == 0)
|
||||
// If inFormat and outFormat are identical, just emit the data back.
|
||||
if (audio.data.size() != 0 && inFormat != outFormat)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (inFormat.codec() == "audio/opus")
|
||||
{
|
||||
|
@ -300,6 +299,8 @@ bool audioConverter::convert(audioPacket audio)
|
|||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
emit converted(audio);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -85,6 +85,7 @@ static inline QAudioFormat toQAudioFormat(quint8 codec, quint32 sampleRate)
|
|||
format.setSampleType(QAudioFormat::UnSignedInt);
|
||||
format.setByteOrder(QAudioFormat::LittleEndian);
|
||||
format.setCodec("audio/pcm");
|
||||
format.setSampleRate(sampleRate);
|
||||
|
||||
if (codec == 0x01 || codec == 0x20) {
|
||||
/* Set sample to be what is expected by the encoder and the output of the decoder */
|
||||
|
@ -108,7 +109,6 @@ static inline QAudioFormat toQAudioFormat(quint8 codec, quint32 sampleRate)
|
|||
format.setCodec("audio/opus");
|
||||
}
|
||||
|
||||
format.setSampleRate(sampleRate);
|
||||
return format;
|
||||
}
|
||||
|
||||
|
|
|
@ -209,8 +209,8 @@ void audioHandler::setVolume(unsigned char volume)
|
|||
|
||||
void audioHandler::incomingAudio(audioPacket packet)
|
||||
{
|
||||
//QTime startProcessing = QTime::currentTime();
|
||||
if (audioDevice != Q_NULLPTR) {
|
||||
|
||||
if (audioDevice != Q_NULLPTR && packet.data.size() > 0) {
|
||||
packet.volume = volume;
|
||||
|
||||
emit sendToConverter(packet);
|
||||
|
@ -221,6 +221,8 @@ void audioHandler::incomingAudio(audioPacket packet)
|
|||
|
||||
void audioHandler::convertedOutput(audioPacket packet) {
|
||||
|
||||
if (packet.data.size() > 0 ) {
|
||||
|
||||
currentLatency = packet.time.msecsTo(QTime::currentTime()) + (outFormat.durationForBytes(audioOutput->bufferSize() - audioOutput->bytesFree()) / 1000);
|
||||
if (audioDevice != Q_NULLPTR) {
|
||||
audioDevice->write(packet.data);
|
||||
|
@ -239,14 +241,15 @@ void audioHandler::convertedOutput(audioPacket packet) {
|
|||
emit haveLevels(getAmplitude(), setup.latency, currentLatency, isUnderrun);
|
||||
|
||||
amplitude = packet.amplitude;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void audioHandler::getNextAudioChunk()
|
||||
{
|
||||
if (audioDevice) {
|
||||
tempBuf.data.append(audioDevice->readAll());
|
||||
|
||||
while (tempBuf.data.length() >= outFormat.bytesForDuration(setup.blockSize * 1000)) {
|
||||
}
|
||||
if (tempBuf.data.length() >= outFormat.bytesForDuration(setup.blockSize * 1000)) {
|
||||
audioPacket packet;
|
||||
packet.time = QTime::currentTime();
|
||||
packet.sent = 0;
|
||||
|
@ -259,13 +262,19 @@ void audioHandler::getNextAudioChunk()
|
|||
|
||||
emit sendToConverter(packet);
|
||||
}
|
||||
return;
|
||||
|
||||
/* If there is still enough data in the buffer, call myself again in 20ms */
|
||||
if (tempBuf.data.length() >= outFormat.bytesForDuration(setup.blockSize * 1000)) {
|
||||
QTimer::singleShot(setup.blockSize, this, &audioHandler::getNextAudioChunk);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void audioHandler::convertedInput(audioPacket audio)
|
||||
{
|
||||
if (audio.data.size() > 0) {
|
||||
emit haveAudioData(audio);
|
||||
if (lastReceived.msecsTo(QTime::currentTime()) > 100) {
|
||||
qDebug(logAudio()) << (setup.isinput ? "Input" : "Output") << "Time since last audio packet" << lastReceived.msecsTo(QTime::currentTime()) << "Expected around" << setup.blockSize ;
|
||||
|
@ -273,6 +282,7 @@ void audioHandler::convertedInput(audioPacket audio)
|
|||
lastReceived = QTime::currentTime();
|
||||
amplitude = audio.amplitude;
|
||||
emit haveLevels(getAmplitude(), setup.latency, currentLatency, isUnderrun);
|
||||
}
|
||||
}
|
||||
|
||||
void audioHandler::changeLatency(const quint16 newSize)
|
||||
|
|
Ładowanie…
Reference in New Issue