Fix underrun handler

merge-requests/9/merge
Phil Taylor 2022-04-06 22:02:43 +01:00
rodzic f00051ecd4
commit 0f7a5566fc
2 zmienionych plików z 11 dodań i 7 usunięć

Wyświetl plik

@ -166,7 +166,12 @@ bool audioHandler::init(audioSetup setupIn)
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "thread id" << QThread::currentThreadId();
underTimer = new QTimer();
underTimer->setSingleShot(true);
connect(underTimer, &QTimer::timeout, this, &audioHandler::clearUnderrun);
this->start();
return true;
}
@ -571,15 +576,15 @@ void audioHandler::stateChanged(QAudio::State state)
case QAudio::IdleState:
{
isUnderrun = true;
if (underTimer->isActive()) {
underTimer->stop();
}
break;
}
case QAudio::ActiveState:
{
//qDebug(logAudio()) << (setup.isinput ? "Input" : "Output") << "Audio started!";
if (underTimer == Q_NULLPTR) {
underTimer = new QTimer();
underTimer->setSingleShot(true);
connect(underTimer, &QTimer::timeout, this, &audioHandler::clearUnderrun);
if (!underTimer->isActive()) {
underTimer->start(500);
}
break;
@ -601,6 +606,5 @@ void audioHandler::stateChanged(QAudio::State state)
void audioHandler::clearUnderrun()
{
isUnderrun = false;
delete underTimer;
underTimer = Q_NULLPTR;
underTimer->stop();
}

Wyświetl plik

@ -142,7 +142,7 @@ private:
OpusEncoder* encoder=Q_NULLPTR;
OpusDecoder* decoder=Q_NULLPTR;
QTimer * underTimer=Q_NULLPTR;
QTimer* underTimer;
};