Ensure buffer is at least 1/2 filled before starting

merge-requests/9/head
Phil Taylor 2022-01-14 20:23:59 +00:00
rodzic 918238835d
commit b4884e773a
2 zmienionych plików z 15 dodań i 2 usunięć

Wyświetl plik

@ -449,6 +449,15 @@ qint64 audioHandler::readData(char* buffer, qint64 nBytes)
if (!isReady) {
isReady = true;
}
if (!audioBuffered) {
#if defined(RTAUDIO)
return 0;
#elif defined(PORTAUDIO)
return 0;
#else
return nBytes;
#endif
}
audioPacket packet;
if (ringBuf->size()>0)
{
@ -458,7 +467,7 @@ qint64 audioHandler::readData(char* buffer, qint64 nBytes)
{
if (!ringBuf->try_read(packet))
{
qDebug(logAudio()) << "No more data available but buffer is not full! sentlen:" << sentlen << " nBytes:" << nBytes ;
qDebug(logAudio()) << (setup.isinput ? "Input" : "Output") << "buffer is empty, sentlen:" << sentlen << " nBytes:" << nBytes ;
break;
}
currentLatency = packet.time.msecsTo(QTime::currentTime());
@ -739,6 +748,10 @@ void audioHandler::incomingAudio(audioPacket inPacket)
incomingAudio(inPacket); // Call myself again to run the packet a second time (FEC)
}
lastSentSeq = inPacket.seq;
if (ringBuf->size() > ringBuf->capacity() / 2)
{
audioBuffered = true;
}
return;
}

Wyświetl plik

@ -165,7 +165,7 @@ private:
void reinit();
bool isInitialized=false;
bool isReady = false;
bool audioBuffered = false;
#if defined(RTAUDIO)
RtAudio* audio = Q_NULLPTR;
int audioDevice = 0;