Improve error message when capture stream fails

Rather than just guessing at the cause of the error, include the actual
error string from PortAudio.
This commit is contained in:
Steve Daulton 2018-08-12 16:12:22 +01:00
parent 90286acb6a
commit 1d22ca5789
3 changed files with 12 additions and 4 deletions

View File

@ -1826,6 +1826,11 @@ bool AudioIO::StartPortAudioStream(double sampleRate,
return (mLastPaError == paNoError);
}
wxString AudioIO::LastPaErrorString()
{
return wxString::Format(wxT("%d %s."), (int) mLastPaError, Pa_GetErrorText(mLastPaError));
}
void AudioIO::StartMonitoring(double sampleRate)
{
if ( mPortStreamV19 || mStreamToken )

View File

@ -729,6 +729,10 @@ private:
volatile double mLastRecordingOffset;
PaError mLastPaError;
public:
wxString LastPaErrorString();
private:
AudacityProject *mOwningProject;
wxWeakRef<MeterPanel> mInputMeter{};
MeterPanel *mOutputMeter;

View File

@ -876,7 +876,7 @@ void ControlToolBar::StopPlaying(bool stopStream /* = true*/)
if( meter ) {
meter->Clear();
}
meter = project->GetCaptureMeter();
if( meter ) {
meter->Clear();
@ -1312,9 +1312,8 @@ bool ControlToolBar::DoRecord(AudacityProject &project,
CancelRecording();
// Show error message if stream could not be opened
ShowErrorDialog(this, _("Error"),
_("Error opening sound device.\nTry changing the audio host, recording device and the project sample rate."),
wxT("Error_opening_sound_device"));
wxString msg = wxString::Format(_("Error opening recording device.\nError code: %s"), gAudioIO->LastPaErrorString());
ShowErrorDialog(this, _("Error"), msg, wxT("Error_opening_sound_device"));
}
}