double lowLatency;
double highLatency;
double finalLatency;
- double sampleRate = 44100.0;
+ double sampleRate = SAMPLE_RATE;
const PaDeviceInfo *pdi = Pa_GetDeviceInfo( deviceIndex );
double previousLatency = 0.0;
int numChannels = 1;
-
+ float toleranceRatio = 1.0;
+
printf("------------------------ paqaCheckMultipleSuggested - %s\n",
(isInput ? "INPUT" : "OUTPUT") );
if( isInput )
streamParameters.device = deviceIndex;
streamParameters.hostApiSpecificStreamInfo = NULL;
streamParameters.sampleFormat = paFloat32;
+ sampleRate = pdi->defaultSampleRate;
printf(" lowLatency = %g\n", lowLatency );
printf(" highLatency = %g\n", highLatency );
printf(" numChannels = %d\n", numChannels );
+ printf(" sampleRate = %g\n", sampleRate );
if( (highLatency - lowLatency) < 0.001 )
{
for( i=0; i<numLoops; i++ )
{
- streamParameters.suggestedLatency = lowLatency + ((highLatency - lowLatency) * i /(numLoops - 1.0));
+ if( numLoops == 1 )
+ streamParameters.suggestedLatency = lowLatency;
+ else
+ streamParameters.suggestedLatency = lowLatency + ((highLatency - lowLatency) * i /(numLoops - 1));
printf(" suggestedLatency[%d] = %6.4f\n", i, streamParameters.suggestedLatency );
finalLatency = streamInfo->outputLatency;
}
printf(" finalLatency = %6.4f\n", finalLatency );
- QA_ASSERT_CLOSE( "final latency should be close to suggested latency",
- streamParameters.suggestedLatency, finalLatency, (streamParameters.suggestedLatency * 0.3) );
-
- QA_ASSERT_TRUE( " final latency should increase with suggested latency", (finalLatency > previousLatency) );
- previousLatency = finalLatency;
+ /* For the default low & high latency values, expect quite close; for other requested
+ * values, at worst the next power-of-2 may result (eg 513 -> 1024) */
+ if( i == 0 | i == ( numLoops - 1 ))
+ toleranceRatio = 0.1;
+ else
+ toleranceRatio = 1.0;
+ QA_ASSERT_CLOSE( "final latency should be close to suggested latency",
+ streamParameters.suggestedLatency, finalLatency, (streamParameters.suggestedLatency * toleranceRatio) );
+ if( i == 0 )
+ previousLatency = finalLatency;
}
-
+ if( numLoops > 1 )
+ QA_ASSERT_TRUE( " final latency should increase with suggested latency", (finalLatency > previousLatency) );
+
return 0;
error:
return -1;
for( id=0; id<numDevices; id++ ) /* Iterate through all devices. */
{
pdi = Pa_GetDeviceInfo( id );
- printf("Using device #%d: '%s' (%s)\n", id, pdi->name, Pa_GetHostApiInfo(pdi->hostApi)->name);
+ printf("\nUsing device #%d: '%s' (%s)\n", id, pdi->name, Pa_GetHostApiInfo(pdi->hostApi)->name);
if( pdi->maxOutputChannels > 0 )
{
- if( (result = paqaCheckMultipleSuggested( id, 0 )) != 0 ) goto error;
+ if( (result = paqaCheckMultipleSuggested( id, 0 )) != 0 )
+ printf("OUTPUT CHECK FAILED !!! #%d: '%s'\n", id, pdi->name);
}
if( pdi->maxInputChannels > 0 )
{
- if( (result = paqaCheckMultipleSuggested( id, 1 )) != 0 ) goto error;
+ if( (result = paqaCheckMultipleSuggested( id, 1 )) != 0 )
+ printf("INPUT CHECK FAILED !!! #%d: '%s'\n", id, pdi->name);
}
}
return 0;
if( pdi->maxOutputChannels > 0 )
{
printf(" Output defaultLowOutputLatency = %f seconds\n", pdi->defaultLowOutputLatency);
- printf(" Output info: defaultHighOutputLatency = %f seconds\n", pdi->defaultHighOutputLatency);
+ printf(" Output defaultHighOutputLatency = %f seconds\n", pdi->defaultHighOutputLatency);
QA_ASSERT_TRUE( "defaultLowOutputLatency should be > 0", (pdi->defaultLowOutputLatency > 0.0) );
QA_ASSERT_TRUE( "defaultHighOutputLatency should be > 0", (pdi->defaultHighOutputLatency > 0.0) );
//QA_ASSERT_TRUE( "defaultHighOutputLatency should be > Low", (pdi->defaultHighOutputLatency > pdi->defaultLowOutputLatency) );
const PaDeviceInfo *deviceInfo;
int i;
int framesPerBuffer;
- double sampleRate = 44100;
-
- printf("PortAudio QA: investigate output latency. SR = %d, BufSize = %d\n", SAMPLE_RATE, FRAMES_PER_BUFFER);
+ double sampleRate = SAMPLE_RATE;
+ printf("\nPortAudio QA: investigate output latency.\n");
+
/* initialise sinusoidal wavetable */
for( i=0; i<TABLE_SIZE; i++ )
{
goto error;
}
+ printf("\n\nNow running Audio Output Tests...\n");
+ printf("-------------------------------------\n");
+
outputParameters.channelCount = 2; /* stereo output */
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
deviceInfo = Pa_GetDeviceInfo( outputParameters.device );
printf("Using device #%d: '%s' (%s)\n", outputParameters.device, deviceInfo->name, Pa_GetHostApiInfo(deviceInfo->hostApi)->name);
printf("Device info: defaultLowOutputLatency = %f seconds\n", deviceInfo->defaultLowOutputLatency);
printf("Device info: defaultHighOutputLatency = %f seconds\n", deviceInfo->defaultHighOutputLatency);
+ sampleRate = deviceInfo->defaultSampleRate;
+ printf("Sample Rate for following tests: %g\n", sampleRate);
outputParameters.hostApiSpecificStreamInfo = NULL;
-
+ printf("-------------------------------------\n");
+
// Try to use a small buffer that is smaller than we think the device can handle.
// Try to force combining multiple user buffers into a host buffer.
printf("------------- Try a very small buffer.\n");