Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional error reporting in case of PortAudio failures. #695

Merged
merged 2 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions USER_MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
24 changes: 22 additions & 2 deletions src/audio/PortAudioDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
//
//=========================================================================

#include <sstream>
#include <iomanip>
#include <cstring>
#include "PortAudioDevice.h"
#include "portaudio.h"
Expand Down Expand Up @@ -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_);
Expand All @@ -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;
}
Expand Down
13 changes: 12 additions & 1 deletion src/audio/PortAudioEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
//
//=========================================================================

#include <sstream>
#include <iomanip>
#include <mutex>
#include <condition_variable>

Expand Down Expand Up @@ -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
Expand Down
Loading