Tests: paqa_latency issues and fixes
Alan Horstmann <gineera <at> aspect135.co.uk>
2012-03-01 22:45:49 GMT
Hi all,
I am working through the Portaudio tests on Linux, and have found a number of
issues and bugs. First up is paqa_latency, which has the most so far.
The defines SAMPLE_RATE and FRAMES_PER_BUFFER are not actually used - it is
thus pointless to print them out. The sample rate is separately hard-coded
to 44100 in 2 places. This means that any devices (there are some on this
machine) that only operate at 48000Hz are bound to fail. Instead I have used
the device default sample rate for the tests. The defines then could be
removed.
At present if one paqaCheckMultipleSuggested() fails the whole qa-test is
abandoned. By instead noting that failure and continuing with other checks
there is more rapid coverage.
When the lowlatency == highlatency, numLoops is set to 1. The following
calculation for latency:
lowLatency + ((highLatency - lowLatency) * i /(numLoops - 1))
then blows up and 'nan' is passed to OpenStream() as the latency value,
causing that to fail! An extra check deals with this condition (where the
device only accepts one value).
A couple of extra '\n's and fixing a printf typo make the output more
readable.
Here is a diff of changes I have made here (also attached to avoid wordwrap).
"qa_latency_fixes.diff"
Regards
Alan
diff -ru ../orig/qa/paqa_latency.c ./qa/paqa_latency.c
--- ../orig/qa/paqa_latency.c 2011-09-08 10:29:21.000000000 +0100
+++ ./qa/paqa_latency.c 2012-03-01 20:45:41.000000000 +0000
<at> <at> -220,7 +220,7 <at> <at>
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;
<at> <at> -243,10 +243,12 <at> <at>
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 )
{
<at> <at> -255,7 +257,10 <at> <at>
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 );
<at> <at> -307,14 +312,16 <at> <at>
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;
<at> <at> -337,7 +344,7 <at> <at>
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) );
<at> <at> -368,9 +375,9 <at> <at>
const PaDeviceInfo *deviceInfo;
int i;
int framesPerBuffer;
- double sampleRate = 44100;
+ double sampleRate = SAMPLE_RATE;
- printf("PortAudio QA: investigate output latency. SR = %d, BufSize =
%d\n", SAMPLE_RATE, FRAMES_PER_BUFFER);
+ printf("\nPortAudio QA: investigate output latency.\n");
/* initialise sinusoidal wavetable */
for( i=0; i<TABLE_SIZE; i++ )
<at> <at> -396,9 +403,11 <at> <at>
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("\nUsing 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;
// Try to use a small buffer that is smaller than we think the device can
handle.
_______________________________________________
Portaudio mailing list
Portaudio <at> music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio