From 284a16cf4fa4285f0d15f7c273d6c9ede2a20306 Mon Sep 17 00:00:00 2001 From: philburk Date: Tue, 1 Mar 2011 09:22:48 +0000 Subject: [PATCH] Add loopback target to Makefile. Fixes to loopback test for ALSA. --- Makefile.in | 16 +++++++++++++++- qa/loopback/src/paqa.c | 43 ++++++++++++++++++++++-------------------- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/Makefile.in b/Makefile.in index 303cf5a..c7944d5 100644 --- a/Makefile.in +++ b/Makefile.in @@ -57,6 +57,14 @@ COMMON_OBJS = \ src/common/pa_stream.o \ src/common/pa_trace.o \ src/hostapi/skeleton/pa_hostapi_skeleton.o + +LOOPBACK_OBJS = \ + qa/loopback/src/audio_analyzer.o \ + qa/loopback/src/biquad_filter.o \ + qa/loopback/src/paqa_tools.o \ + qa/loopback/src/test_audio_analyzer.o \ + qa/loopback/src/write_wav.o \ + qa/loopback/src/paqa.o TESTS = \ bin/paqa_devs \ @@ -144,6 +152,8 @@ all: lib/$(PALIB) all-recursive tests tests: bin-stamp $(TESTS) +loopback: bin-stamp bin/paloopback + # With ASIO enabled we must link libportaudio and all test programs with CXX lib/$(PALIB): lib-stamp $(LTOBJS) $(MAKEFILE) $(PAINC) @WITH_ASIO_FALSE@ $(LIBTOOL) --mode=link $(CC) $(PA_LDFLAGS) -o lib/$(PALIB) $(LTOBJS) $(DLL_LIBS) @@ -153,6 +163,10 @@ $(ALL_TESTS): bin/%: lib/$(PALIB) $(MAKEFILE) $(PAINC) test/%.c @WITH_ASIO_FALSE@ $(LIBTOOL) --mode=link $(CC) -o $@ $(CFLAGS) $(top_srcdir)/test/$*.c lib/$(PALIB) $(LIBS) @WITH_ASIO_TRUE@ $(LIBTOOL) --mode=link --tag=CXX $(CXX) -o $@ $(CXXFLAGS) $(top_srcdir)/test/$*.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) + install: lib/$(PALIB) portaudio-2.0.pc $(INSTALL) -d $(DESTDIR)$(libdir) $(LIBTOOL) --mode=install $(INSTALL) lib/$(PALIB) $(DESTDIR)$(libdir) @@ -178,7 +192,7 @@ uninstall: $(MAKE) uninstall-recursive clean: - $(LIBTOOL) --mode=clean rm -f $(LTOBJS) $(ALL_TESTS) lib/$(PALIB) + $(LIBTOOL) --mode=clean rm -f $(LTOBJS) $(LOOPBACK_OBJS) $(ALL_TESTS) lib/$(PALIB) $(RM) bin-stamp lib-stamp -$(RM) -r bin lib diff --git a/qa/loopback/src/paqa.c b/qa/loopback/src/paqa.c index d4444d0..19f3574 100644 --- a/qa/loopback/src/paqa.c +++ b/qa/loopback/src/paqa.c @@ -284,8 +284,8 @@ static int RecordAndPlayBlockingIO( PaStream *inStream, ) { int i; - float *in = (float *)g_BigBuffer; - float *out = (float *)g_BigBuffer; + float *in = (float *)g_BigBuffer; + float *out = (float *)g_BigBuffer; PaError err; int done = 0; long available; @@ -307,12 +307,12 @@ static int RecordAndPlayBlockingIO( PaStream *inStream, } // Save in a recording. - for( i=0; itest->inputParameters.channelCount; i++ ) + for( i=0; itest->inputParameters.channelCount; i++ ) { done |= PaQa_WriteRecording( &loopbackContext->recordings[i], - in + i, - framesPerBuffer, - loopbackContext->test->inputParameters.channelCount ); + in + i, + framesPerBuffer, + loopbackContext->test->inputParameters.channelCount ); } // Synthesize audio. @@ -322,9 +322,9 @@ static int RecordAndPlayBlockingIO( PaStream *inStream, for( i=0; itest->outputParameters.channelCount; i++ ) { PaQa_MixSine( &loopbackContext->generators[i], - out + i, - available, - loopbackContext->test->outputParameters.channelCount ); + out + i, + available, + loopbackContext->test->outputParameters.channelCount ); } // Write out audio. @@ -705,6 +705,8 @@ static void PaQa_SetDefaultTestParameters( TestParameters *testParamsPtr, PaDevi static int PaQa_AnalyzeLoopbackConnection( UserOptions *userOptions, PaDeviceIndex inputDevice, PaDeviceIndex outputDevice, double expectedAmplitude ) { int i; + int iFlags; + int iRate; int iSize; int totalBadChannels = 0; TestParameters testParams; @@ -719,10 +721,10 @@ static int PaQa_AnalyzeLoopbackConnection( UserOptions *userOptions, PaDeviceInd int flagSettings[] = { 0, 1 }; int numFlagSettings = (sizeof(flagSettings)/sizeof(int)); - double sampleRates[] = { 8000.0, 11025.0, 16000.0, 22050.0, 32000.0, 44100.0, 48000.0, 96000.0 }; + double sampleRates[] = { 44100.0, 48000.0, 8000.0, 11025.0, 16000.0, 22050.0, 32000.0, 96000.0 }; int numRates = (sizeof(sampleRates)/sizeof(double)); - int framesPerBuffers[] = { 0, 16, 32, 40, 64, 100, 128, 512, 1024 }; + int framesPerBuffers[] = { 256, 16, 32, 40, 64, 100, 128, 512, 1024 }; int numBufferSizes = (sizeof(framesPerBuffers)/sizeof(int)); // Check to see if a specific value was requested. @@ -749,7 +751,7 @@ static int PaQa_AnalyzeLoopbackConnection( UserOptions *userOptions, PaDeviceInd printf("|-sRate-|-buffer-|-latency-|-channel results--------------------|\n"); // Loop though combinations of audio parameters. - testParams.framesPerBuffer = 128; + testParams.framesPerBuffer = framesPerBuffers[0]; for( iRate=0; iRate 0.1) && (magRightReverse>minAmplitude)) { @@ -866,6 +868,7 @@ error: */ static int ScanForLoopback(UserOptions *userOptions) { + PaDeviceIndex i,j; int numLoopbacks = 0; int numDevices; numDevices = Pa_GetDeviceCount(); @@ -881,7 +884,7 @@ static int ScanForLoopback(UserOptions *userOptions) else if (userOptions->inputDevice >= 0) { // Just scan for output. - for( PaDeviceIndex i=0; iinputDevice, i ); if( loopbackConnected > 0 ) @@ -894,7 +897,7 @@ static int ScanForLoopback(UserOptions *userOptions) else if (userOptions->outputDevice >= 0) { // Just scan for input. - for( PaDeviceIndex i=0; iinputDevice ); if( loopbackConnected > 0 ) @@ -907,9 +910,9 @@ static int ScanForLoopback(UserOptions *userOptions) else { // Scan both. - for( PaDeviceIndex i=0; i 0 ) -- 2.43.0