From 03c9a5d2d5b2f31f17e7b26be4d5cf28bb28cf5a Mon Sep 17 00:00:00 2001 From: philburk Date: Wed, 2 Mar 2011 22:12:23 +0000 Subject: [PATCH] Fix random code insertion caused by buggy editor on Linux. Report actual buffer sizes. --- qa/loopback/src/audio_analyzer.c | 2 + qa/loopback/src/paqa.c | 110 +++++++++++++++++++------------ 2 files changed, 71 insertions(+), 41 deletions(-) diff --git a/qa/loopback/src/audio_analyzer.c b/qa/loopback/src/audio_analyzer.c index ff21379..a57feb0 100644 --- a/qa/loopback/src/audio_analyzer.c +++ b/qa/loopback/src/audio_analyzer.c @@ -447,6 +447,8 @@ int PaQa_MeasureLatency( PaQaRecording *recording, PaQaTestTone *testTone, PaQaA int cycleSize = (int) (period + 0.5); //printf("PaQa_AnalyseRecording: frequency = %8f, frameRate = %8f, period = %8f, cycleSize = %8d\n", // testTone->frequency, testTone->sampleRate, period, cycleSize ); + analysisResult->latency = -1; + analysisResult->valid = (0); // Set up generator to find matching first cycle. QA_ASSERT_TRUE( "cycleSize out of bounds", (cycleSize < MAX_BUFFER_SIZE) ); diff --git a/qa/loopback/src/paqa.c b/qa/loopback/src/paqa.c index 1fcc48b..a4fac28 100644 --- a/qa/loopback/src/paqa.c +++ b/qa/loopback/src/paqa.c @@ -56,9 +56,10 @@ int g_testsFailed = 0; #define MAX_NUM_RECORDINGS (8) #define MAX_BACKGROUND_NOISE_RMS (0.0004) #define LOOPBACK_DETECTION_DURATION_SECONDS (0.8) -#define DEFAULT_FRAMES_PER_BUFFER (128) +#define DEFAULT_FRAMES_PER_BUFFER (0) #define DEFAULT_HIGH_LATENCY_MSEC (100) #define PAQA_WAIT_STREAM_MSEC (100) +#define PAQA_TEST_DURATION (1.2) // Use two separate streams instead of one full duplex stream. #define PAQA_FLAG_TWO_STREAMS (1<<0) @@ -737,8 +738,14 @@ static int PaQa_SingleLoopBackTest( UserOptions *userOptions, TestParameters *te if( i==0 ) { + printf( "%4d-%4d | ", + loopbackContext.minFramesPerBuffer, + loopbackContext.maxFramesPerBuffer + ); + double latencyMSec = 1000.0 * analysisResult.latency / testParams->sampleRate; printf("%7.2f | ", latencyMSec ); + } if( analysisResult.valid ) @@ -763,7 +770,7 @@ static int PaQa_SingleLoopBackTest( UserOptions *userOptions, TestParameters *te } else { - printf( "[%d] NO SIGNAL, ", i ); + printf( "[%d] No or low signal, ampRatio = %f", i, analysisResult.amplitudeRatio ); numBadChannels += 1; } @@ -773,17 +780,15 @@ static int PaQa_SingleLoopBackTest( UserOptions *userOptions, TestParameters *te printf( "OK" ); } - printf( ", %d/%d/%d/%d, ", + printf( ", %d/%d/%d/%d ", loopbackContext.inputOverflowCount, loopbackContext.inputUnderflowCount, loopbackContext.outputOverflowCount, - loopbackContext.outputUnderflowCount ); + loopbackContext.outputUnderflowCount + ); printf( "\n" ); - - // Sleep to see if this lets the audio drivers stabilize. - Pa_Sleep( 500 ); - + PaQa_TeardownLoopbackContext( &loopbackContext ); if( numBadChannels > 0 ) { @@ -806,7 +811,7 @@ static void PaQa_SetDefaultTestParameters( TestParameters *testParamsPtr, PaDevi testParamsPtr->samplesPerFrame = 2; testParamsPtr->amplitude = 0.5; testParamsPtr->sampleRate = 44100; - testParamsPtr->maxFrames = (int) (1.0 * testParamsPtr->sampleRate); + testParamsPtr->maxFrames = (int) (PAQA_TEST_DURATION * testParamsPtr->sampleRate); testParamsPtr->framesPerBuffer = DEFAULT_FRAMES_PER_BUFFER; testParamsPtr->baseFrequency = 200.0; testParamsPtr->flags = PAQA_FLAG_TWO_STREAMS; @@ -829,6 +834,7 @@ static void PaQa_OverrideTestParameters( TestParameters *testParamsPtr, UserOpt if( userOptions->sampleRate >= 0 ) { testParamsPtr->sampleRate = userOptions->sampleRate; + testParamsPtr->maxFrames = (int) (PAQA_TEST_DURATION * testParamsPtr->sampleRate); } if( userOptions->framesPerBuffer >= 0 ) { @@ -887,41 +893,58 @@ static int PaQa_AnalyzeLoopbackConnection( UserOptions *userOptions, PaDeviceInd // Loop though combinations of audio parameters. for( iFlags=0; iFlags\n"); + printf("|-sRate-|-fr/buf-|- frm/buf -|-latency-|-channel results--------------------|\n"); // Loop though various sample rates. - savedValue = testParams.sampleRate; - for( iRate=0; iRatesampleRate < 0 ) { - // SAMPLE RATE - testParams.sampleRate = sampleRates[iRate]; - testParams.maxFrames = (int) (1.2 * testParams.sampleRate); - - int numBadChannels = PaQa_SingleLoopBackTest( userOptions, &testParams ); - totalBadChannels += numBadChannels; + savedValue = testParams.sampleRate; + for( iRate=0; iRateframesPerBuffer < 0 ) + { + savedValue = testParams.framesPerBuffer; + for( iSize=0; iSizemaxInputChannels < 2 ) { return 0; } + outputDeviceInfo = Pa_GetDeviceInfo( outputDevice ); - QA_ASSERT_TRUE( "Pa_GetDeviceInfo for output returned NULL.", (outputDeviceInfo != NULL) ); + if( outputDeviceInfo == NULL ) + { + printf("ERROR - Pa_GetDeviceInfo for output returned NULL.\n"); + return paInvalidDevice; + } if( outputDeviceInfo->maxOutputChannels < 2 ) { return 0; @@ -1041,7 +1073,7 @@ int PaQa_CheckForLoopBack( UserOptions *userOptions, PaDeviceIndex inputDevice, { printf( "Output not supported for this format!\n" ); return 0; - }! + } PaQa_SetupLoopbackContext( &loopbackContext, &testParams ); @@ -1158,7 +1190,6 @@ static int ScanForLoopback(UserOptions *userOptions) else if (userOptions->outputDevice >= 0) { // Just scan for input. - QA_ASSERT_TRUE( "No good loopback cable found.", (numLoopbacks > 0) ); for( iIn=0; iInoutputDevice ); @@ -1169,8 +1200,6 @@ static int ScanForLoopback(UserOptions *userOptions) // Scan both. for( iOut=0; iOut 0) ); for( iIn=0; iIn