From: philburk Date: Fri, 22 Jun 2012 21:58:10 +0000 (+0000) Subject: Added counters for status flags in patest_wire.c. It then prints how many under and... X-Git-Tag: pa_stable_v19_20140130_r1919~61 X-Git-Url: https://andrewgundersen.net/repos?a=commitdiff_plain;h=44bdc45b2a52a2c4c94fbb9d9c69438599cb4180;p=portaudio Added counters for status flags in patest_wire.c. It then prints how many under and overflows occured. This was added to help debug issue #171. --- diff --git a/test/patest_wire.c b/test/patest_wire.c index 936fba6..ba3477b 100644 --- a/test/patest_wire.c +++ b/test/patest_wire.c @@ -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: