kopia lustrzana https://gitlab.com/eliggett/wfview
Update audiohandler.cpp
rodzic
e4d5efb3d5
commit
2a889488c4
|
@ -249,23 +249,23 @@ void audioHandler::incomingAudio(audioPacket inPacket)
|
|||
unsigned char* in = (unsigned char*)inPacket.data.data();
|
||||
|
||||
//Decode the frame.
|
||||
QByteArray outPacket((getAudioSize(20, setup.format)) * sizeof(float) * setup.format.channelCount(), (char)0xff); // Preset the output buffer size.
|
||||
QByteArray outPacket((960) * sizeof(float) * setup.format.channelCount(), (char)0xff); // Preset the output buffer size.
|
||||
float* out = (float*)outPacket.data();
|
||||
int nSamples = opus_packet_get_nb_samples(in, livePacket.data.size(),setup.format.sampleRate());
|
||||
if (nSamples == -1) {
|
||||
// No opus data yet?
|
||||
return;
|
||||
}
|
||||
else if (nSamples != getAudioSize(20, setup.format))
|
||||
else if (nSamples != 960)
|
||||
{
|
||||
qDebug(logAudio()) << "Opus nSamples=" << nSamples << " expected:" << (getAudioSize(20, setup.format));
|
||||
qDebug(logAudio()) << "Opus nSamples=" << nSamples << " expected:" << 960;
|
||||
//return;
|
||||
}
|
||||
if (livePacket.seq > lastSentSeq + 1) {
|
||||
nSamples = opus_decode_float(decoder, Q_NULLPTR,0, out, getAudioSize(20, setup.format), 1);
|
||||
nSamples = opus_decode_float(decoder, Q_NULLPTR,0, out, 960, 1);
|
||||
}
|
||||
else {
|
||||
nSamples = opus_decode_float(decoder, in, livePacket.data.size(), out, (getAudioSize(20, setup.format)), 0);
|
||||
nSamples = opus_decode_float(decoder, in, livePacket.data.size(), out, 960, 0);
|
||||
}
|
||||
if (nSamples < 0)
|
||||
{
|
||||
|
@ -400,6 +400,11 @@ void audioHandler::getNextAudioChunk(QByteArray& ret)
|
|||
{
|
||||
audioPacket livePacket;
|
||||
livePacket.sent = 0;
|
||||
// Don't start sending until we have setup.latency of audio buffered
|
||||
if (audioDevice->bytesAvailable() < format.bytesForDuration((setup.latency*1000)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (audioDevice != Q_NULLPTR) {
|
||||
livePacket.data = audioDevice->read(format.bytesForDuration(20000)); // 20000uS is 20ms in NATIVE format.
|
||||
if (livePacket.data.length() > 0)
|
||||
|
|
Ładowanie…
Reference in New Issue