kopia lustrzana https://gitlab.com/eliggett/wfview
Use goto statement for error handling.
rodzic
b95cf79318
commit
466571a758
|
@ -92,11 +92,7 @@ bool rtHandler::init(audioSetup setup)
|
||||||
}
|
}
|
||||||
catch (RtAudioError& e) {
|
catch (RtAudioError& e) {
|
||||||
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "Device exception:" << aParams.deviceId << ":" << QString::fromStdString(e.getMessage());
|
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "Device exception:" << aParams.deviceId << ":" << QString::fromStdString(e.getMessage());
|
||||||
if (retryConnectCount < 10) {
|
goto errorHandler;
|
||||||
QTimer::singleShot(500, this, std::bind(&rtHandler::init, this, setup));
|
|
||||||
retryConnectCount++;
|
|
||||||
}
|
|
||||||
return isInitialized;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.probed)
|
if (info.probed)
|
||||||
|
@ -110,7 +106,7 @@ bool rtHandler::init(audioSetup setup)
|
||||||
if (info.nativeFormats == 0)
|
if (info.nativeFormats == 0)
|
||||||
{
|
{
|
||||||
qCritical(logAudio()) << " No natively supported data formats!";
|
qCritical(logAudio()) << " No natively supported data formats!";
|
||||||
return false;
|
goto errorHandler;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
qDebug(logAudio()) << " Supported formats:" <<
|
qDebug(logAudio()) << " Supported formats:" <<
|
||||||
|
@ -137,11 +133,7 @@ bool rtHandler::init(audioSetup setup)
|
||||||
else if (outFormat.channelCount() < 1)
|
else if (outFormat.channelCount() < 1)
|
||||||
{
|
{
|
||||||
qCritical(logAudio()) << (setup.isinput ? "Input" : "Output") << "No channels found, aborting setup.";
|
qCritical(logAudio()) << (setup.isinput ? "Input" : "Output") << "No channels found, aborting setup.";
|
||||||
if (retryConnectCount < 10) {
|
goto errorHandler;
|
||||||
QTimer::singleShot(500, this, std::bind(&rtHandler::init, this, setup));
|
|
||||||
retryConnectCount++;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
aParams.nChannels = outFormat.channelCount();
|
aParams.nChannels = outFormat.channelCount();
|
||||||
|
@ -170,7 +162,7 @@ bool rtHandler::init(audioSetup setup)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
qCritical(logAudio()) << "Cannot find supported sample format!";
|
qCritical(logAudio()) << "Cannot find supported sample format!";
|
||||||
return false;
|
goto errorHandler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,27 +209,32 @@ 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?
|
// Try again?
|
||||||
if (retryConnectCount < 10) {
|
goto errorHandler;
|
||||||
QTimer::singleShot(500, this, std::bind(&rtHandler::init, this, setup));
|
|
||||||
retryConnectCount++;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qCritical(logAudio()) << (setup.isinput ? "Input" : "Output") << QString::fromStdString(info.name) << "(" << aParams.deviceId << ") could not be probed, check audio configuration!";
|
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << QString::fromStdString(info.name) << "(" << aParams.deviceId << ") could not be probed, check audio configuration!";
|
||||||
if (retryConnectCount < 10) {
|
goto errorHandler;
|
||||||
QTimer::singleShot(500, this, std::bind(&rtHandler::init, this, setup));
|
|
||||||
retryConnectCount++;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this->setVolume(setup.localAFgain);
|
this->setVolume(setup.localAFgain);
|
||||||
|
|
||||||
|
|
||||||
return isInitialized;
|
return isInitialized;
|
||||||
|
|
||||||
|
errorHandler:
|
||||||
|
if (retryConnectCount < 10) {
|
||||||
|
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "*** Attempting to reconnect to audio device in 500ms";
|
||||||
|
QTimer::singleShot(500, this, std::bind(&rtHandler::init, this, setup));
|
||||||
|
retryConnectCount++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qCritical(logAudio()) << (setup.isinput ? "Input" : "Output") << "*** Retry count exceeded, giving up!";
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue