From 13b21598210ced77d5b147ed6db6804bcfba7947 Mon Sep 17 00:00:00 2001 From: philburk Date: Sun, 10 Apr 2016 18:12:03 +0000 Subject: [PATCH] patest_out_underflow: cleanup Replace some tabs. Print overflow under stress. Prevent accidental overrange of phases array. --- test/patest_out_underflow.c | 57 +++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/test/patest_out_underflow.c b/test/patest_out_underflow.c index e69def3..dee90f8 100644 --- a/test/patest_out_underflow.c +++ b/test/patest_out_underflow.c @@ -85,8 +85,9 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer, if( data->countUnderflows && (statusFlags & paOutputUnderflow) ) + { data->outputUnderflowCount++; - + } for( i=0; idefaultLowOutputLatency; + suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency; + outputParameters.suggestedLatency = suggestedLatency; outputParameters.hostApiSpecificStreamInfo = NULL; err = Pa_OpenStream( @@ -160,24 +164,23 @@ int main(void) /* Determine number of sines required to get to 50% */ do { - Pa_Sleep( 100 ); + Pa_Sleep( 100 ); load = Pa_GetStreamCpuLoad( stream ); printf("sineCount = %d, CPU load = %f\n", data.sineCount, load ); - if( load < 0.3 ) - { - data.sineCount += 10; - } - else if( load < 0.4 ) - { - data.sineCount += 2; - } - else - { - data.sineCount += 1; - } - + if( load < 0.3 ) + { + data.sineCount += 10; + } + else if( load < 0.4 ) + { + data.sineCount += 2; + } + else + { + data.sineCount += 1; + } } while( load < 0.5 && data.sineCount < (MAX_SINES-1)); @@ -187,16 +190,18 @@ int main(void) stressedSineCount = (int) (2.0 * data.sineCount * MAX_LOAD ); if( stressedSineCount > MAX_SINES ) stressedSineCount = MAX_SINES; - for( ; data.sineCount < stressedSineCount; data.sineCount+=4 ) + sineCount = data.sineCount; + for( ; sineCount < stressedSineCount; sineCount+=4 ) { + data.sineCount = sineCount; Pa_Sleep( 100 ); load = Pa_GetStreamCpuLoad( stream ); - printf("STRESSING: sineCount = %d, CPU load = %f\n", data.sineCount, load ); + printf("STRESSING: sineCount = %d, CPU load = %f\n", sineCount, load ); } - printf("Counting underflows for 5 seconds.\n"); + printf("Counting underflows for 2 seconds.\n"); data.countUnderflows = 1; - Pa_Sleep( 5000 ); + Pa_Sleep( 2000 ); stressedUnderflowCount = data.outputUnderflowCount; @@ -225,12 +230,16 @@ int main(void) Pa_Terminate(); + printf("suggestedLatency = %f\n", suggestedLatency); + + // Report pass or fail if( stressedUnderflowCount == 0 ) - printf("Test failed, no output underflows detected under stress.\n"); - else if( safeUnderflowCount != 0 ) - printf("Test failed, %d unexpected underflows detected under safe load.\n", safeUnderflowCount); + printf("Test FAILED, no output underflows detected under stress.\n"); else - printf("Test passed, %d expected output underflows detected under stress, 0 unexpected underflows detected under safe load.\n", stressedUnderflowCount ); + printf("Test %s, %d expected output underflows detected under stress, " + "%d unexpected underflows detected under safe load.\n", + (safeUnderflowCount == 0) ? "PASSED" : "FAILED", + stressedUnderflowCount, safeUnderflowCount ); return err; error: -- 2.43.0