]> Repos - portaudio/commitdiff
Added counters for status flags in patest_wire.c. It then prints how many under and...
authorphilburk <philburk@0f58301d-fd10-0410-b4af-bbb618454e57>
Fri, 22 Jun 2012 21:58:10 +0000 (21:58 +0000)
committerphilburk <philburk@0f58301d-fd10-0410-b4af-bbb618454e57>
Fri, 22 Jun 2012 21:58:10 +0000 (21:58 +0000)
This was added to help debug issue #171.

test/patest_wire.c

index 936fba64b03d6714ab00e5b08e4d903e2c4a4898..ba3477b368943d0eae1490be51da091676f71588 100644 (file)
@@ -63,6 +63,13 @@ typedef struct WireConfig_s
     int numInputChannels;
     int numOutputChannels;
     int framesPerCallback;
+    /* count status flags */
+    int numInputUnderflows;
+    int numInputOverflows;
+    int numOutputUnderflows;
+    int numOutputOverflows;
+    int numPrimingOutputs;
+    int numCallbacks;
 } WireConfig_t;
 
 #define USE_FLOAT_INPUT        (1)
@@ -124,6 +131,14 @@ static int wireCallback( const void *inputBuffer, void *outputBuffer,
     /* This may get called with NULL inputBuffer during initial setup. */
     if( inputBuffer == NULL) return 0;
 
+    /* Count flags */
+    if( (statusFlags & paInputUnderflow) != 0 ) config->numInputUnderflows += 1;
+    if( (statusFlags & paInputOverflow) != 0 ) config->numInputOverflows += 1;
+    if( (statusFlags & paOutputUnderflow) != 0 ) config->numOutputUnderflows += 1;
+    if( (statusFlags & paOutputOverflow) != 0 ) config->numOutputOverflows += 1;
+    if( (statusFlags & paPrimingOutput) != 0 ) config->numPrimingOutputs += 1;
+    config->numCallbacks += 1;
+    
     inChannel=0, outChannel=0;
     while( !(inDone && outDone) )
     {
@@ -272,6 +287,13 @@ static PaError TestConfiguration( WireConfig_t *config )
     outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
     outputParameters.hostApiSpecificStreamInfo = NULL;
 
+    config->numInputUnderflows = 0;
+    config->numInputOverflows = 0;
+    config->numOutputUnderflows = 0;
+    config->numOutputOverflows = 0;
+    config->numPrimingOutputs = 0;
+    config->numCallbacks = 0;
+
     err = Pa_OpenStream(
               &stream,
               &inputParameters,
@@ -286,13 +308,22 @@ static PaError TestConfiguration( WireConfig_t *config )
     err = Pa_StartStream( stream );
     if( err != paNoError ) goto error;
     
-    printf("Hit ENTER for next configuration, or 'q' to quit.\n");  fflush(stdout);
+    printf("Now recording and playing. - Hit ENTER for next configuration, or 'q' to quit.\n");  fflush(stdout);
     c = getchar();
     
     printf("Closing stream.\n");
     err = Pa_CloseStream( stream );
     if( err != paNoError ) goto error;
 
+#define CHECK_FLAG_COUNT(member) \
+    if( config->member > 0 ) printf("FLAGS SET: " #member " = %d\n", config->member );
+    CHECK_FLAG_COUNT( numInputUnderflows );
+    CHECK_FLAG_COUNT( numInputOverflows );
+    CHECK_FLAG_COUNT( numOutputUnderflows );
+    CHECK_FLAG_COUNT( numOutputOverflows );
+    CHECK_FLAG_COUNT( numPrimingOutputs );
+    printf("number of callbacks = %d\n", config->numCallbacks );
+
     if( c == 'q' ) return 1;
 
 error: