kopia lustrzana https://gitlab.com/eliggett/wfview
Mitigate potential empty buffer crash.
rodzic
01fd2f420d
commit
6d8d1df45e
|
@ -867,7 +867,7 @@ void audioHandler::start()
|
|||
audioInput->start(this);
|
||||
}
|
||||
else {
|
||||
this->open(QIODevice::ReadOnly);
|
||||
this->open(QIODevice::ReadOnly | QIODevice::Unbuffered);
|
||||
audioOutput->start(this);
|
||||
}
|
||||
}
|
||||
|
@ -1006,9 +1006,10 @@ void audioHandler::stateChanged(QAudio::State state)
|
|||
{
|
||||
if (state == QAudio::IdleState && audioOutput->error() == QAudio::UnderrunError) {
|
||||
qDebug(logAudio()) << this->metaObject()->className() << "RX:Buffer underrun";
|
||||
//QMutexLocker locker(&mutex);
|
||||
//audioOutput->suspend();
|
||||
//buffer.clear();
|
||||
#ifdef Q_OS_WIN
|
||||
QMutexLocker locker(&mutex);
|
||||
audioOutput->suspend();
|
||||
#endif
|
||||
}
|
||||
//qDebug(logAudio()) << this->metaObject()->className() << ": state = " << state;
|
||||
}
|
||||
|
|
|
@ -1226,21 +1226,26 @@ void udpBase::sendTrackedPacket(QByteArray d)
|
|||
void udpBase::purgeOldEntries()
|
||||
{
|
||||
// Erase old entries from the tx packet buffer
|
||||
txSeqBuf.erase(std::remove_if(txSeqBuf.begin(), txSeqBuf.end(), [](const SEQBUFENTRY& v)
|
||||
{ return v.timeSent.secsTo(QTime::currentTime()) > PURGE_SECONDS; }), txSeqBuf.end());
|
||||
|
||||
|
||||
// Erase old entries from the missing packets buffer
|
||||
rxMissing.erase(std::remove_if(rxMissing.begin(), rxMissing.end(), [](const SEQBUFENTRY& v)
|
||||
{ return v.timeSent.secsTo(QTime::currentTime()) > PURGE_SECONDS; }), rxMissing.end());
|
||||
|
||||
std::sort(rxSeqBuf.begin(), rxSeqBuf.end());
|
||||
|
||||
if (rxSeqBuf.length() > 400)
|
||||
if (!txSeqBuf.isEmpty())
|
||||
{
|
||||
rxSeqBuf.remove(0, 200);
|
||||
txSeqBuf.erase(std::remove_if(txSeqBuf.begin(), txSeqBuf.end(), [](const SEQBUFENTRY& v)
|
||||
{ return v.timeSent.secsTo(QTime::currentTime()) > PURGE_SECONDS; }), txSeqBuf.end());
|
||||
}
|
||||
|
||||
// Erase old entries from the missing packets buffer
|
||||
if (!rxMissing.isEmpty()) {
|
||||
rxMissing.erase(std::remove_if(rxMissing.begin(), rxMissing.end(), [](const SEQBUFENTRY& v)
|
||||
{ return v.timeSent.secsTo(QTime::currentTime()) > PURGE_SECONDS; }), rxMissing.end());
|
||||
}
|
||||
|
||||
if (!rxSeqBuf.isEmpty()) {
|
||||
std::sort(rxSeqBuf.begin(), rxSeqBuf.end());
|
||||
|
||||
if (rxSeqBuf.length() > 400)
|
||||
{
|
||||
rxSeqBuf.remove(0, 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Ładowanie…
Reference in New Issue