]> Repos - portaudio/commitdiff
Report HostAPI errors in paex_write_sine.c to aid debugging.
authorphilburk <philburk@0f58301d-fd10-0410-b4af-bbb618454e57>
Sat, 1 Sep 2012 19:37:10 +0000 (19:37 +0000)
committerphilburk <philburk@0f58301d-fd10-0410-b4af-bbb618454e57>
Sat, 1 Sep 2012 19:37:10 +0000 (19:37 +0000)
examples/paex_write_sine.c

index 720cc367bab88e0e7b8ee95337b15b9ff9948821..31ec842639f9dcf436a5719c7a151040554611ec 100644 (file)
@@ -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;
 }