From 2a133eb379922bbb29ac34a9da2475a33e31fb58 Mon Sep 17 00:00:00 2001 From: Mooneer Salem Date: Sat, 2 Mar 2024 13:33:51 -0800 Subject: [PATCH 1/2] Add additional error reporting in case of PortAudio failures. --- src/audio/PortAudioDevice.cpp | 24 ++++++++++++++++++++++-- src/audio/PortAudioEngine.cpp | 13 ++++++++++++- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/audio/PortAudioDevice.cpp b/src/audio/PortAudioDevice.cpp index 9caa0170f..efd6628b0 100644 --- a/src/audio/PortAudioDevice.cpp +++ b/src/audio/PortAudioDevice.cpp @@ -20,6 +20,8 @@ // //========================================================================= +#include +#include #include #include "PortAudioDevice.h" #include "portaudio.h" @@ -95,9 +97,18 @@ void PortAudioDevice::start() error = Pa_StartStream(deviceStream_); if (error != paNoError) { + std::string errText = Pa_GetErrorText(error); + if (error == paUnanticipatedHostError) + { + std::stringstream ss; + auto errInfo = Pa_GetLastHostErrorInfo(); + ss << " (error code " << std::hex << errInfo->errorCode << " - " << std::string(errInfo->errorText) << ")"; + errText += ss.str(); + } + if (onAudioErrorFunction) { - onAudioErrorFunction(*this, Pa_GetErrorText(error), onAudioErrorState); + onAudioErrorFunction(*this, errText, onAudioErrorState); } Pa_CloseStream(deviceStream_); @@ -106,9 +117,18 @@ void PortAudioDevice::start() } else { + std::string errText = Pa_GetErrorText(error); + if (error == paUnanticipatedHostError) + { + std::stringstream ss; + auto errInfo = Pa_GetLastHostErrorInfo(); + ss << " (error code " << std::hex << errInfo->errorCode << " - " << std::string(errInfo->errorText) << ")"; + errText += ss.str(); + } + if (onAudioErrorFunction) { - onAudioErrorFunction(*this, Pa_GetErrorText(error), onAudioErrorState); + onAudioErrorFunction(*this, errText, onAudioErrorState); } deviceStream_ = nullptr; } diff --git a/src/audio/PortAudioEngine.cpp b/src/audio/PortAudioEngine.cpp index e515d0d81..81aff5c4a 100644 --- a/src/audio/PortAudioEngine.cpp +++ b/src/audio/PortAudioEngine.cpp @@ -20,6 +20,8 @@ // //========================================================================= +#include +#include #include #include @@ -47,9 +49,18 @@ void PortAudioEngine::start() auto error = Pa_Initialize(); if (error != paNoError) { + std::string errText = Pa_GetErrorText(error); + if (error == paUnanticipatedHostError) + { + std::stringstream ss; + auto errInfo = Pa_GetLastHostErrorInfo(); + ss << " (error code " << std::hex << errInfo->errorCode << " - " << std::string(errInfo->errorText) << ")"; + errText += ss.str(); + } + if (onAudioErrorFunction) { - onAudioErrorFunction(*this, Pa_GetErrorText(error), onAudioErrorState); + onAudioErrorFunction(*this, errText, onAudioErrorState); } } else From f69782bb014cf7eec7f87b5cef0163d82cc086ef Mon Sep 17 00:00:00 2001 From: Mooneer Salem Date: Sat, 2 Mar 2024 13:35:45 -0800 Subject: [PATCH 2/2] Add PR #695 to changelog. --- USER_MANUAL.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/USER_MANUAL.md b/USER_MANUAL.md index c1aac021c..1b2a22a88 100644 --- a/USER_MANUAL.md +++ b/USER_MANUAL.md @@ -895,6 +895,8 @@ LDPC | Low Density Parity Check Codes - a family of powerful FEC codes * Cache PortAudio sound info to improve startup performance. (PR #689) * Fix typo in cardinal directions list. (PR #688) * Shrink size of callsign list to prevent it from disappearing off the screen. (PR #692) +2. Enhancements: + * Add additional error reporting in case of PortAudio failures. (PR #695) ## V1.9.8 February 2024