Move paqa_devs and paqa_errs to qa folder. Clean up tests.

This commit is contained in:
philburk 2011-09-08 05:32:07 +00:00
commit d2054b201e
4 changed files with 49 additions and 19 deletions

View file

@ -78,9 +78,12 @@ EXAMPLES = \
bin/paex_write_sine \ bin/paex_write_sine \
bin/paex_write_sine_nonint bin/paex_write_sine_nonint
TESTS = \ SELFTESTS = \
bin/paqa_devs \ bin/paqa_devs \
bin/paqa_errs \ bin/paqa_errs \
bin/paqa_latency
TESTS = \
bin/patest1 \ bin/patest1 \
bin/patest_buffer \ bin/patest_buffer \
bin/patest_callbackstop \ bin/patest_callbackstop \
@ -152,12 +155,14 @@ SRC_DIRS = \
SUBDIRS = SUBDIRS =
@ENABLE_CXX_TRUE@SUBDIRS += bindings/cpp @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) tests: bin-stamp $(TESTS)
examples: bin-stamp $(EXAMPLES) examples: bin-stamp $(EXAMPLES)
selftests: bin-stamp $(SELFTESTS)
loopback: bin-stamp bin/paloopback loopback: bin-stamp bin/paloopback
# With ASIO enabled we must link libportaudio and all test programs with CXX # 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_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) @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) bin/paloopback: lib/$(PALIB) $(MAKEFILE) $(PAINC) $(LOOPBACK_OBJS)
@WITH_ASIO_FALSE@ $(LIBTOOL) --mode=link $(CC) -o $@ $(CFLAGS) $(LOOPBACK_OBJS) lib/$(PALIB) $(LIBS) @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) @WITH_ASIO_TRUE@ $(LIBTOOL) --mode=link --tag=CXX $(CXX) -o $@ $(CXXFLAGS) $(LOOPBACK_OBJS) lib/$(PALIB) $(LIBS)

View file

@ -1,5 +1,5 @@
/** @file paqa_devs.c /** @file paqa_devs.c
@ingroup test_src @ingroup qa_src
@brief Self Testing Quality Assurance app for PortAudio @brief Self Testing Quality Assurance app for PortAudio
Try to open each device and run through all the Try to open each device and run through all the
possible configurations. This test does not verify possible configurations. This test does not verify
@ -213,7 +213,7 @@ int main(void)
error: error:
Pa_Terminate(); Pa_Terminate();
printf("QA Report: %d passed, %d failed.\n", gNumPassed, gNumFailed ); 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++ ) 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. */ /* Try each standard sample rate. */
for( i=0; standardSampleRates[i] > 0; i++ ) for( i=0; standardSampleRates[i] > 0; i++ )
{ {
@ -266,9 +268,10 @@ static int TestAdvance( int mode, PaDeviceIndex deviceID, double sampleRate,
PaError result = paNoError; PaError result = paNoError;
PaQaData myData; PaQaData myData;
#define FRAMES_PER_BUFFER (64) #define FRAMES_PER_BUFFER (64)
const int kNumSeconds = 100;
/* Setup data for synthesis thread. */ /* Setup data for synthesis thread. */
myData.framesLeft = (unsigned long) (sampleRate * 100); /* 100 seconds */ myData.framesLeft = (unsigned long) (sampleRate * kNumSeconds);
myData.numChannels = numChannels; myData.numChannels = numChannels;
myData.mode = mode; myData.mode = mode;
myData.format = format; myData.format = format;
@ -297,8 +300,11 @@ static int TestAdvance( int mode, PaDeviceIndex deviceID, double sampleRate,
ipp = &inputParameters; ipp = &inputParameters;
} }
else else
ipp = NULL; {
if( mode == MODE_OUTPUT ) /* Pa_GetDeviceInfo(paNoDevice) COREDUMPS!!! */ ipp = NULL;
}
if( mode == MODE_OUTPUT )
{ {
outputParameters.device = deviceID; outputParameters.device = deviceID;
outputParameters.channelCount = numChannels; outputParameters.channelCount = numChannels;
@ -308,8 +314,10 @@ static int TestAdvance( int mode, PaDeviceIndex deviceID, double sampleRate,
opp = &outputParameters; opp = &outputParameters;
} }
else else
opp = NULL; {
opp = NULL;
}
if(paFormatIsSupported == Pa_IsFormatSupported( ipp, opp, sampleRate )) if(paFormatIsSupported == Pa_IsFormatSupported( ipp, opp, sampleRate ))
{ {
printf("------ TestAdvance: %s, device = %d, rate = %g, numChannels = %d, format = %lu -------\n", 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); oldStamp = Pa_GetStreamTime(stream);
Pa_Sleep(msec); Pa_Sleep(msec);
newStamp = Pa_GetStreamTime(stream); newStamp = Pa_GetStreamTime(stream);
printf("oldStamp = %g,newStamp = %g\n", oldStamp, newStamp ); /**/ printf("oldStamp = %g, newStamp = %g\n", oldStamp, newStamp ); /**/
EXPECT( (oldStamp < newStamp) ); EXPECT( (oldStamp < newStamp) );
/* Check to make sure callback is decrementing framesLeft. */ /* Check to make sure callback is decrementing framesLeft. */
oldFrames = myData.framesLeft; oldFrames = myData.framesLeft;
@ -352,7 +360,8 @@ static int TestAdvance( int mode, PaDeviceIndex deviceID, double sampleRate,
stream = NULL; stream = NULL;
} }
} }
return 0;
error: error:
if( stream != NULL ) Pa_CloseStream( stream ); if( stream != NULL ) Pa_CloseStream( stream );
return result; return -1;
} }

View file

@ -1,5 +1,5 @@
/** @file paqa_errs.c /** @file paqa_errs.c
@ingroup test_src @ingroup qa_src
@brief Self Testing Quality Assurance app for PortAudio @brief Self Testing Quality Assurance app for PortAudio
Do lots of bad things to test error reporting. Do lots of bad things to test error reporting.
@author Phil Burk http://www.softsynth.com @author Phil Burk http://www.softsynth.com
@ -342,6 +342,7 @@ static int TestBadOpens( void )
static int TestBadActions( void ) static int TestBadActions( void )
{ {
PaStream* stream = NULL; PaStream* stream = NULL;
const PaDeviceInfo* deviceInfo = NULL;
PaError result; PaError result;
PaQaData myData; PaQaData myData;
PaStreamParameters opp; PaStreamParameters opp;
@ -365,7 +366,9 @@ static int TestBadActions( void )
SAMPLE_RATE, FRAMES_PER_BUFFER, SAMPLE_RATE, FRAMES_PER_BUFFER,
paClipOff, QaCallback, &myData )) == paNoError)); 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_StartStream(NULL)) == paBadStreamPtr));
HOPEFOR(((result = Pa_StopStream(NULL)) == paBadStreamPtr)); HOPEFOR(((result = Pa_StopStream(NULL)) == paBadStreamPtr));
HOPEFOR(((result = Pa_IsStreamStopped(NULL)) == paBadStreamPtr)); HOPEFOR(((result = Pa_IsStreamStopped(NULL)) == paBadStreamPtr));

View file

@ -1,6 +1,6 @@
/** @file patest_sine.c /** @file paqa_latency.c
@ingroup test_src @ingroup qa_src
@brief Play a sine wave for several seconds. @brief Test latency estimates.
@author Ross Bencina <rossb@audiomulch.com> @author Ross Bencina <rossb@audiomulch.com>
@author Phil Burk <philburk@softsynth.com> @author Phil Burk <philburk@softsynth.com>
*/ */
@ -138,7 +138,6 @@ PaError paqaCheckLatency( PaStreamParameters *outputParamsPtr,
dataPtr->maxDeltaDacTime = 0.0; dataPtr->maxDeltaDacTime = 0.0;
dataPtr->callbackCount = 0; dataPtr->callbackCount = 0;
printf("-------------------------------------\n");
printf("Stream parameter: suggestedOutputLatency = %g\n", outputParamsPtr->suggestedLatency ); printf("Stream parameter: suggestedOutputLatency = %g\n", outputParamsPtr->suggestedLatency );
if( framesPerBuffer == paFramesPerBufferUnspecified ){ if( framesPerBuffer == paFramesPerBufferUnspecified ){
printf("Stream parameter: user framesPerBuffer = paFramesPerBufferUnspecified\n" ); printf("Stream parameter: user framesPerBuffer = paFramesPerBufferUnspecified\n" );
@ -178,10 +177,12 @@ PaError paqaCheckLatency( PaStreamParameters *outputParamsPtr,
Pa_Sleep( 1 * 1000 ); Pa_Sleep( 1 * 1000 );
printf("-------------------------------------\n");
return err; return err;
error2: error2:
Pa_CloseStream( stream ); Pa_CloseStream( stream );
error1: error1:
printf("-------------------------------------\n");
return err; return err;
} }
@ -225,36 +226,44 @@ int main(void)
printf("Device info: defaultHighOutputLatency = %f seconds\n", deviceInfo->defaultHighOutputLatency); printf("Device info: defaultHighOutputLatency = %f seconds\n", deviceInfo->defaultHighOutputLatency);
outputParameters.hostApiSpecificStreamInfo = NULL; outputParameters.hostApiSpecificStreamInfo = NULL;
// Try to use a small buffer that is smaller than we think the device can handle. // 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. // Try to force combining multiple user buffers into a host buffer.
printf("------------- Try a very small buffer.\n");
framesPerBuffer = 9; framesPerBuffer = 9;
outputParameters.suggestedLatency = deviceInfo->defaultLowOutputLatency; outputParameters.suggestedLatency = deviceInfo->defaultLowOutputLatency;
err = paqaCheckLatency( &outputParameters, &data, sampleRate, framesPerBuffer ); err = paqaCheckLatency( &outputParameters, &data, sampleRate, framesPerBuffer );
if( err != paNoError ) goto error; if( err != paNoError ) goto error;
printf("------------- 64 frame buffer with 1.1 * defaultLow latency.\n");
framesPerBuffer = 64; framesPerBuffer = 64;
outputParameters.suggestedLatency = deviceInfo->defaultLowOutputLatency * 1.1; outputParameters.suggestedLatency = deviceInfo->defaultLowOutputLatency * 1.1;
err = paqaCheckLatency( &outputParameters, &data, sampleRate, framesPerBuffer ); err = paqaCheckLatency( &outputParameters, &data, sampleRate, framesPerBuffer );
if( err != paNoError ) goto error; if( err != paNoError ) goto error;
// Try to create a huge buffer that is bigger than the allowed device maximum. // Try to create a huge buffer that is bigger than the allowed device maximum.
printf("------------- Try a huge buffer.\n");
framesPerBuffer = 16*1024; framesPerBuffer = 16*1024;
outputParameters.suggestedLatency = ((double)framesPerBuffer) / sampleRate; // approximate outputParameters.suggestedLatency = ((double)framesPerBuffer) / sampleRate; // approximate
err = paqaCheckLatency( &outputParameters, &data, sampleRate, framesPerBuffer ); err = paqaCheckLatency( &outputParameters, &data, sampleRate, framesPerBuffer );
if( err != paNoError ) goto error; if( err != paNoError ) goto error;
printf("------------- Try suggestedLatency = 0.0\n");
outputParameters.suggestedLatency = 0.0; outputParameters.suggestedLatency = 0.0;
err = paqaCheckLatency( &outputParameters, &data, sampleRate, paFramesPerBufferUnspecified ); err = paqaCheckLatency( &outputParameters, &data, sampleRate, paFramesPerBufferUnspecified );
if( err != paNoError ) goto error; if( err != paNoError ) goto error;
printf("------------- Try suggestedLatency = defaultLowOutputLatency\n");
outputParameters.suggestedLatency = deviceInfo->defaultLowOutputLatency; outputParameters.suggestedLatency = deviceInfo->defaultLowOutputLatency;
err = paqaCheckLatency( &outputParameters, &data, sampleRate, paFramesPerBufferUnspecified ); err = paqaCheckLatency( &outputParameters, &data, sampleRate, paFramesPerBufferUnspecified );
if( err != paNoError ) goto error; if( err != paNoError ) goto error;
printf("------------- Try suggestedLatency = defaultHighOutputLatency\n");
outputParameters.suggestedLatency = deviceInfo->defaultHighOutputLatency; outputParameters.suggestedLatency = deviceInfo->defaultHighOutputLatency;
err = paqaCheckLatency( &outputParameters, &data, sampleRate, paFramesPerBufferUnspecified ); err = paqaCheckLatency( &outputParameters, &data, sampleRate, paFramesPerBufferUnspecified );
if( err != paNoError ) goto error; if( err != paNoError ) goto error;
printf("------------- Try suggestedLatency = defaultHighOutputLatency * 4\n");
outputParameters.suggestedLatency = deviceInfo->defaultHighOutputLatency * 4; outputParameters.suggestedLatency = deviceInfo->defaultHighOutputLatency * 4;
err = paqaCheckLatency( &outputParameters, &data, sampleRate, paFramesPerBufferUnspecified ); err = paqaCheckLatency( &outputParameters, &data, sampleRate, paFramesPerBufferUnspecified );
if( err != paNoError ) goto error; if( err != paNoError ) goto error;