From: philburk Date: Thu, 8 Sep 2011 05:32:07 +0000 (+0000) Subject: Move paqa_devs and paqa_errs to qa folder. Clean up tests. X-Git-Tag: pa_stable_v19_20111121_r1788~22 X-Git-Url: https://andrewgundersen.net/repos?a=commitdiff_plain;h=d2054b201ed641086be570f64b56fa5705ab22b7;p=portaudio Move paqa_devs and paqa_errs to qa folder. Clean up tests. --- diff --git a/Makefile.in b/Makefile.in index 45d1be9..97f5c7c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -78,9 +78,12 @@ EXAMPLES = \ bin/paex_write_sine \ bin/paex_write_sine_nonint -TESTS = \ +SELFTESTS = \ bin/paqa_devs \ bin/paqa_errs \ + bin/paqa_latency + +TESTS = \ bin/patest1 \ bin/patest_buffer \ bin/patest_callbackstop \ @@ -152,12 +155,14 @@ SRC_DIRS = \ SUBDIRS = @ENABLE_CXX_TRUE@SUBDIRS += bindings/cpp -all: lib/$(PALIB) all-recursive tests examples +all: lib/$(PALIB) all-recursive tests examples selftests tests: bin-stamp $(TESTS) examples: bin-stamp $(EXAMPLES) +selftests: bin-stamp $(SELFTESTS) + loopback: bin-stamp bin/paloopback # With ASIO enabled we must link libportaudio and all test programs with CXX @@ -173,6 +178,10 @@ $(EXAMPLES): bin/%: lib/$(PALIB) $(MAKEFILE) $(PAINC) examples/%.c @WITH_ASIO_FALSE@ $(LIBTOOL) --mode=link $(CC) -o $@ $(CFLAGS) $(top_srcdir)/examples/$*.c lib/$(PALIB) $(LIBS) @WITH_ASIO_TRUE@ $(LIBTOOL) --mode=link --tag=CXX $(CXX) -o $@ $(CXXFLAGS) $(top_srcdir)/examples/$*.c lib/$(PALIB) $(LIBS) +$(SELFTESTS): bin/%: lib/$(PALIB) $(MAKEFILE) $(PAINC) qa/%.c + @WITH_ASIO_FALSE@ $(LIBTOOL) --mode=link $(CC) -o $@ $(CFLAGS) $(top_srcdir)/qa/$*.c lib/$(PALIB) $(LIBS) + @WITH_ASIO_TRUE@ $(LIBTOOL) --mode=link --tag=CXX $(CXX) -o $@ $(CXXFLAGS) $(top_srcdir)/qa/$*.c lib/$(PALIB) $(LIBS) + bin/paloopback: lib/$(PALIB) $(MAKEFILE) $(PAINC) $(LOOPBACK_OBJS) @WITH_ASIO_FALSE@ $(LIBTOOL) --mode=link $(CC) -o $@ $(CFLAGS) $(LOOPBACK_OBJS) lib/$(PALIB) $(LIBS) @WITH_ASIO_TRUE@ $(LIBTOOL) --mode=link --tag=CXX $(CXX) -o $@ $(CXXFLAGS) $(LOOPBACK_OBJS) lib/$(PALIB) $(LIBS) diff --git a/test/paqa_devs.c b/qa/paqa_devs.c similarity index 95% rename from test/paqa_devs.c rename to qa/paqa_devs.c index 3374829..4a19968 100644 --- a/test/paqa_devs.c +++ b/qa/paqa_devs.c @@ -1,5 +1,5 @@ /** @file paqa_devs.c - @ingroup test_src + @ingroup qa_src @brief Self Testing Quality Assurance app for PortAudio Try to open each device and run through all the possible configurations. This test does not verify @@ -213,7 +213,7 @@ int main(void) error: Pa_Terminate(); printf("QA Report: %d passed, %d failed.\n", gNumPassed, gNumFailed ); - return 0; + return (gNumFailed > 0) ? 1 : 0; } /******************************************************************* @@ -237,7 +237,9 @@ static void TestDevices( int mode ) for( jc=1; jc<=maxChannels; jc++ ) { - printf("Name = %s\n", pdi->name ); + printf("\n========================================================================\n"); + printf(" Device = %s\n", pdi->name ); + printf("========================================================================\n"); /* Try each standard sample rate. */ for( i=0; standardSampleRates[i] > 0; i++ ) { @@ -266,9 +268,10 @@ static int TestAdvance( int mode, PaDeviceIndex deviceID, double sampleRate, PaError result = paNoError; PaQaData myData; #define FRAMES_PER_BUFFER (64) + const int kNumSeconds = 100; /* Setup data for synthesis thread. */ - myData.framesLeft = (unsigned long) (sampleRate * 100); /* 100 seconds */ + myData.framesLeft = (unsigned long) (sampleRate * kNumSeconds); myData.numChannels = numChannels; myData.mode = mode; myData.format = format; @@ -297,8 +300,11 @@ static int TestAdvance( int mode, PaDeviceIndex deviceID, double sampleRate, ipp = &inputParameters; } else - ipp = NULL; - if( mode == MODE_OUTPUT ) /* Pa_GetDeviceInfo(paNoDevice) COREDUMPS!!! */ + { + ipp = NULL; + } + + if( mode == MODE_OUTPUT ) { outputParameters.device = deviceID; outputParameters.channelCount = numChannels; @@ -308,8 +314,10 @@ static int TestAdvance( int mode, PaDeviceIndex deviceID, double sampleRate, opp = &outputParameters; } else - opp = NULL; - + { + opp = NULL; + } + if(paFormatIsSupported == Pa_IsFormatSupported( ipp, opp, sampleRate )) { printf("------ TestAdvance: %s, device = %d, rate = %g, numChannels = %d, format = %lu -------\n", @@ -341,7 +349,7 @@ static int TestAdvance( int mode, PaDeviceIndex deviceID, double sampleRate, oldStamp = Pa_GetStreamTime(stream); Pa_Sleep(msec); newStamp = Pa_GetStreamTime(stream); - printf("oldStamp = %g,newStamp = %g\n", oldStamp, newStamp ); /**/ + printf("oldStamp = %g, newStamp = %g\n", oldStamp, newStamp ); /**/ EXPECT( (oldStamp < newStamp) ); /* Check to make sure callback is decrementing framesLeft. */ oldFrames = myData.framesLeft; @@ -352,7 +360,8 @@ static int TestAdvance( int mode, PaDeviceIndex deviceID, double sampleRate, stream = NULL; } } + return 0; error: if( stream != NULL ) Pa_CloseStream( stream ); - return result; + return -1; } diff --git a/test/paqa_errs.c b/qa/paqa_errs.c similarity index 98% rename from test/paqa_errs.c rename to qa/paqa_errs.c index ac93300..524978d 100644 --- a/test/paqa_errs.c +++ b/qa/paqa_errs.c @@ -1,5 +1,5 @@ /** @file paqa_errs.c - @ingroup test_src + @ingroup qa_src @brief Self Testing Quality Assurance app for PortAudio Do lots of bad things to test error reporting. @author Phil Burk http://www.softsynth.com @@ -342,6 +342,7 @@ static int TestBadOpens( void ) static int TestBadActions( void ) { PaStream* stream = NULL; + const PaDeviceInfo* deviceInfo = NULL; PaError result; PaQaData myData; PaStreamParameters opp; @@ -365,7 +366,9 @@ static int TestBadActions( void ) SAMPLE_RATE, FRAMES_PER_BUFFER, paClipOff, QaCallback, &myData )) == paNoError)); } - + + HOPEFOR(((deviceInfo = Pa_GetDeviceInfo(paNoDevice)) == NULL)); + HOPEFOR(((deviceInfo = Pa_GetDeviceInfo(87654)) == NULL)); HOPEFOR(((result = Pa_StartStream(NULL)) == paBadStreamPtr)); HOPEFOR(((result = Pa_StopStream(NULL)) == paBadStreamPtr)); HOPEFOR(((result = Pa_IsStreamStopped(NULL)) == paBadStreamPtr)); diff --git a/qa/paqa_latency.c b/qa/paqa_latency.c index 130ee68..8fe08e7 100644 --- a/qa/paqa_latency.c +++ b/qa/paqa_latency.c @@ -1,6 +1,6 @@ -/** @file patest_sine.c - @ingroup test_src - @brief Play a sine wave for several seconds. +/** @file paqa_latency.c + @ingroup qa_src + @brief Test latency estimates. @author Ross Bencina @author Phil Burk */ @@ -138,7 +138,6 @@ PaError paqaCheckLatency( PaStreamParameters *outputParamsPtr, dataPtr->maxDeltaDacTime = 0.0; dataPtr->callbackCount = 0; - printf("-------------------------------------\n"); printf("Stream parameter: suggestedOutputLatency = %g\n", outputParamsPtr->suggestedLatency ); if( framesPerBuffer == paFramesPerBufferUnspecified ){ printf("Stream parameter: user framesPerBuffer = paFramesPerBufferUnspecified\n" ); @@ -178,10 +177,12 @@ PaError paqaCheckLatency( PaStreamParameters *outputParamsPtr, Pa_Sleep( 1 * 1000 ); + printf("-------------------------------------\n"); return err; error2: Pa_CloseStream( stream ); error1: + printf("-------------------------------------\n"); return err; } @@ -225,36 +226,44 @@ int main(void) printf("Device info: defaultHighOutputLatency = %f seconds\n", deviceInfo->defaultHighOutputLatency); outputParameters.hostApiSpecificStreamInfo = NULL; + // 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"); framesPerBuffer = 9; outputParameters.suggestedLatency = deviceInfo->defaultLowOutputLatency; err = paqaCheckLatency( &outputParameters, &data, sampleRate, framesPerBuffer ); if( err != paNoError ) goto error; + printf("------------- 64 frame buffer with 1.1 * defaultLow latency.\n"); framesPerBuffer = 64; outputParameters.suggestedLatency = deviceInfo->defaultLowOutputLatency * 1.1; err = paqaCheckLatency( &outputParameters, &data, sampleRate, framesPerBuffer ); if( err != paNoError ) goto error; // Try to create a huge buffer that is bigger than the allowed device maximum. + printf("------------- Try a huge buffer.\n"); framesPerBuffer = 16*1024; outputParameters.suggestedLatency = ((double)framesPerBuffer) / sampleRate; // approximate err = paqaCheckLatency( &outputParameters, &data, sampleRate, framesPerBuffer ); if( err != paNoError ) goto error; + printf("------------- Try suggestedLatency = 0.0\n"); outputParameters.suggestedLatency = 0.0; err = paqaCheckLatency( &outputParameters, &data, sampleRate, paFramesPerBufferUnspecified ); if( err != paNoError ) goto error; + printf("------------- Try suggestedLatency = defaultLowOutputLatency\n"); outputParameters.suggestedLatency = deviceInfo->defaultLowOutputLatency; err = paqaCheckLatency( &outputParameters, &data, sampleRate, paFramesPerBufferUnspecified ); if( err != paNoError ) goto error; + printf("------------- Try suggestedLatency = defaultHighOutputLatency\n"); outputParameters.suggestedLatency = deviceInfo->defaultHighOutputLatency; err = paqaCheckLatency( &outputParameters, &data, sampleRate, paFramesPerBufferUnspecified ); if( err != paNoError ) goto error; - + + printf("------------- Try suggestedLatency = defaultHighOutputLatency * 4\n"); outputParameters.suggestedLatency = deviceInfo->defaultHighOutputLatency * 4; err = paqaCheckLatency( &outputParameters, &data, sampleRate, paFramesPerBufferUnspecified ); if( err != paNoError ) goto error;