Merge branch 'wfserver'

merge-requests/9/merge
Roeland Jansen 2022-05-24 11:18:41 +02:00
commit b4f379d52d
2 zmienionych plików z 16 dodań i 2 usunięć

Wyświetl plik

@ -33,7 +33,7 @@ bool debugMode=false;
Q_UNUSED(sig) Q_UNUSED(sig)
qDebug() << "Exiting via SIGNAL"; qDebug() << "Exiting via SIGNAL";
if (w!=Q_NULLPTR) w->deleteLater(); if (w!=Q_NULLPTR) w->deleteLater();
qApp->quit(); QCoreApplication::quit();
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
return true; return true;
@ -177,6 +177,8 @@ int main(int argc, char *argv[])
SetConsoleCtrlHandler((PHANDLER_ROUTINE)cleanup, TRUE); SetConsoleCtrlHandler((PHANDLER_ROUTINE)cleanup, TRUE);
#else #else
signal(SIGINT, cleanup); signal(SIGINT, cleanup);
signal(SIGTERM, cleanup);
signal(SIGKILL, cleanup);
#endif #endif
w = new servermain(serialPortCL, hostCL, settingsFile); w = new servermain(serialPortCL, hostCL, settingsFile);
#else #else

Wyświetl plik

@ -6,6 +6,7 @@
#include <objbase.h> #include <objbase.h>
#endif #endif
#define RT_EXCEPTION
rtHandler::rtHandler(QObject* parent) rtHandler::rtHandler(QObject* parent)
{ {
@ -16,13 +17,17 @@ rtHandler::~rtHandler()
{ {
if (isInitialized) { if (isInitialized) {
#ifdef RT_EXCEPTION
try { try {
#endif
audio->abortStream(); audio->abortStream();
audio->closeStream(); audio->closeStream();
#ifdef RT_EXCEPTION
} }
catch (RtAudioError& e) { catch (RtAudioError& e) {
qInfo(logAudio()) << "Error closing stream:" << aParams.deviceId << ":" << QString::fromStdString(e.getMessage()); qInfo(logAudio()) << "Error closing stream:" << aParams.deviceId << ":" << QString::fromStdString(e.getMessage());
} }
#endif
delete audio; delete audio;
} }
@ -87,14 +92,17 @@ bool rtHandler::init(audioSetup setup)
} }
aParams.firstChannel = 0; aParams.firstChannel = 0;
#ifdef RT_EXCEPTION
try { try {
#endif
info = audio->getDeviceInfo(aParams.deviceId); info = audio->getDeviceInfo(aParams.deviceId);
#ifdef RT_EXCEPTION
} }
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());
goto errorHandler; goto errorHandler;
} }
#endif
if (info.probed) if (info.probed)
{ {
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << QString::fromStdString(info.name) << "(" << aParams.deviceId << ") successfully probed"; qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << QString::fromStdString(info.name) << "(" << aParams.deviceId << ") successfully probed";
@ -190,7 +198,9 @@ bool rtHandler::init(audioSetup setup)
// Per channel chunk size. // Per channel chunk size.
this->chunkSize = (outFormat.bytesForDuration(setup.blockSize * 1000) / (outFormat.sampleSize()/8) / outFormat.channelCount()); this->chunkSize = (outFormat.bytesForDuration(setup.blockSize * 1000) / (outFormat.sampleSize()/8) / outFormat.channelCount());
#ifdef RT_EXCEPTION
try { try {
#endif
if (setup.isinput) { if (setup.isinput) {
audio->openStream(NULL, &aParams, sampleFormat, outFormat.sampleRate(), &this->chunkSize, &staticWrite, this, &options); audio->openStream(NULL, &aParams, sampleFormat, outFormat.sampleRate(), &this->chunkSize, &staticWrite, this, &options);
emit setupConverter(outFormat, inFormat, 7, setup.resampleQuality); emit setupConverter(outFormat, inFormat, 7, setup.resampleQuality);
@ -205,12 +215,14 @@ bool rtHandler::init(audioSetup setup)
isInitialized = true; isInitialized = true;
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "device successfully opened"; qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "device successfully opened";
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "detected latency:" << audio->getStreamLatency(); qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "detected latency:" << audio->getStreamLatency();
#ifdef RT_EXCEPTION
} }
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?
goto errorHandler; goto errorHandler;
} }
#endif
} }
else else
{ {