If audio device fails to open, retry 10 times before giving up.

merge-requests/9/merge
Phil Taylor 2022-05-14 01:27:44 +01:00
rodzic 48562aa23b
commit c1461947eb
2 zmienionych plików z 8 dodań i 0 usunięć

Wyświetl plik

@ -208,6 +208,12 @@ bool rtHandler::init(audioSetup setup)
} }
catch (RtAudioError& e) { catch (RtAudioError& e) {
qInfo(logAudio()) << "Error opening:" << QString::fromStdString(e.getMessage()); qInfo(logAudio()) << "Error opening:" << QString::fromStdString(e.getMessage());
// Try again?
if (retryConnectCount < 10) {
QTimer::singleShot(500, this, std::bind(&rtHandler::init, this, setup));
retryConnectCount++;
return false;
}
} }
} }
else else

Wyświetl plik

@ -16,6 +16,7 @@
#include <QAudioFormat> #include <QAudioFormat>
#include <QTime> #include <QTime>
#include <QMap> #include <QMap>
#include <QTimer>
/* wfview Packet types */ /* wfview Packet types */
@ -108,6 +109,7 @@ private:
bool isUnderrun = false; bool isUnderrun = false;
bool isOverrun = false; bool isOverrun = false;
QMutex audioMutex; QMutex audioMutex;
int retryConnectCount = 0;
}; };
#endif // rtHandler_H #endif // rtHandler_H