if( data->countUnderflows && (statusFlags & paOutputUnderflow) )
+ {
data->outputUnderflowCount++;
-
+ }
for( i=0; i<framesPerBuffer; i++ )
{
float output = 0.0;
PaStream *stream;
PaError err;
int safeSineCount, stressedSineCount;
+ int sineCount;
int safeUnderflowCount, stressedUnderflowCount;
paTestData data = {0};
double load;
+ double suggestedLatency;
printf("PortAudio Test: output sine waves, count underflows. SR = %d, BufSize = %d. MAX_LOAD = %f\n",
}
outputParameters.channelCount = 1; /* mono output */
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
- outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
+ suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
+ outputParameters.suggestedLatency = suggestedLatency;
outputParameters.hostApiSpecificStreamInfo = NULL;
err = Pa_OpenStream(
/* 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));
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;
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: