From b9d82e4d3488894a17d582368bf19cac59c76746 Mon Sep 17 00:00:00 2001 From: philburk Date: Sat, 1 Sep 2012 19:37:10 +0000 Subject: [PATCH] Report HostAPI errors in paex_write_sine.c to aid debugging. --- examples/paex_write_sine.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/examples/paex_write_sine.c b/examples/paex_write_sine.c index 720cc36..31ec842 100644 --- a/examples/paex_write_sine.c +++ b/examples/paex_write_sine.c @@ -71,7 +71,6 @@ int main(void) int right_inc = 3; /* higher pitch so we can distinguish left and right. */ int i, j, k; int bufferCount; - printf("PortAudio Test: output sine wave. SR = %d, BufSize = %d\n", SAMPLE_RATE, FRAMES_PER_BUFFER); @@ -92,7 +91,7 @@ int main(void) } outputParameters.channelCount = 2; /* stereo output */ outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */ - outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency; + outputParameters.suggestedLatency = 0.050; // Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency; outputParameters.hostApiSpecificStreamInfo = NULL; err = Pa_OpenStream( @@ -150,10 +149,18 @@ int main(void) printf("Test finished.\n"); return err; + error: - Pa_Terminate(); fprintf( stderr, "An error occured while using the portaudio stream\n" ); fprintf( stderr, "Error number: %d\n", err ); fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); + // Print more information about the error. + if( err == paUnanticipatedHostError ) + { + const PaHostErrorInfo *hostErrorInfo = Pa_GetLastHostErrorInfo(); + fprintf( stderr, "Host API error = #%d, hostApiType = %d\n", hostErrorInfo->errorCode, hostErrorInfo->hostApiType ); + fprintf( stderr, "Host API error = %s\n", hostErrorInfo->errorText ); + } + Pa_Terminate(); return err; } -- 2.43.0