From 8a905a2a19c422e6eeb8ab57b52e86dcf016f1ac Mon Sep 17 00:00:00 2001 From: philburk Date: Tue, 1 Mar 2011 01:54:20 +0000 Subject: [PATCH] Added paloopback test to the automated build. --- Makefile.in | 16 ++++++++++++++-- qa/loopback/src/audio_analyzer.c | 16 ++++------------ qa/loopback/src/qa_tools.h | 2 +- qa/loopback/src/test_audio_analyzer.c | 21 ++++++++++++--------- 4 files changed, 31 insertions(+), 24 deletions(-) diff --git a/Makefile.in b/Makefile.in index c613ca1..ba89041 100644 --- a/Makefile.in +++ b/Makefile.in @@ -58,6 +58,14 @@ COMMON_OBJS = \ 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 \ bin/paqa_errs \ @@ -140,10 +148,11 @@ SRC_DIRS = \ SUBDIRS = @ENABLE_CXX_TRUE@SUBDIRS += bindings/cpp -all: lib/$(PALIB) all-recursive tests +all: lib/$(PALIB) all-recursive tests loopback 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) @@ -154,6 +163,9 @@ $(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) @@ -180,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/audio_analyzer.c b/qa/loopback/src/audio_analyzer.c index aff93d0..a8a22c8 100644 --- a/qa/loopback/src/audio_analyzer.c +++ b/qa/loopback/src/audio_analyzer.c @@ -146,9 +146,6 @@ int PaQa_WriteRecording( PaQaRecording *recording, float *buffer, int numFrames, } recording->numFrames += framesToWrite; return (recording->numFrames >= recording->maxFrames); - -error: - return -1; } /*==========================================================================================*/ @@ -166,9 +163,6 @@ int PaQa_WriteSilence( PaQaRecording *recording, int numFrames ) } recording->numFrames += framesToRecord; return (recording->numFrames >= recording->maxFrames); - -error: - return -1; } /*==========================================================================================*/ @@ -187,9 +181,6 @@ int PaQa_RecordFreeze( PaQaRecording *recording, int numFrames ) } recording->numFrames += framesToRecord; return (recording->numFrames >= recording->maxFrames); - -error: - return -1; } /*==========================================================================================*/ @@ -518,7 +509,7 @@ int PaQa_DetectPhaseError( PaQaRecording *recording, PaQaTestTone *testTone, PaQ double phase = 666.0; double mag = PaQa_CorrelateSine( recording, testTone->frequency, testTone->sampleRate, i, windowSize, &phase ); - if( loopCount > 1) + if( (loopCount > 1) && (mag > 0.0) ) { double phaseDelta = PaQa_ComputePhaseDifference( phase, previousPhase ); double phaseError = PaQa_ComputePhaseDifference( phaseDelta, expectedPhaseIncrement ); @@ -573,7 +564,7 @@ int PaQa_AnalyseRecording( PaQaRecording *recording, PaQaTestTone *testTone, PaQ if( (analysisResult->latency >= 0) && (analysisResult->amplitudeRatio > 0.1) ) { - analysisResult->valid = 1; + analysisResult->valid = (1); result = PaQa_DetectPop( recording, testTone, analysisResult ); QA_ASSERT_EQUALS( "detect pop", 0, result ); @@ -584,4 +575,5 @@ int PaQa_AnalyseRecording( PaQaRecording *recording, PaQaTestTone *testTone, PaQ return 0; error: return -1; -} +} + diff --git a/qa/loopback/src/qa_tools.h b/qa/loopback/src/qa_tools.h index 9a60d04..32be215 100755 --- a/qa/loopback/src/qa_tools.h +++ b/qa/loopback/src/qa_tools.h @@ -53,7 +53,7 @@ extern int g_testsFailed; #define QA_ASSERT_EQUALS( message, expected, actual ) \ - if( (expected) != (actual) ) \ + if( ((expected) != (actual)) ) \ { \ printf( "%s:%d - ERROR - %s, expected %d, got %d\n", __FILE__, __LINE__, message, expected, actual ); \ g_testsFailed++; \ diff --git a/qa/loopback/src/test_audio_analyzer.c b/qa/loopback/src/test_audio_analyzer.c index 08a4fca..4f6112e 100644 --- a/qa/loopback/src/test_audio_analyzer.c +++ b/qa/loopback/src/test_audio_analyzer.c @@ -48,6 +48,8 @@ #define FRAMES_PER_BLOCK (64) #define PRINT_REPORTS 0 +#define TEST_SAVED_WAVE (0) + /*==========================================================================================*/ /** * Detect a single tone. @@ -425,7 +427,7 @@ static int TestDetectPops( void ) return 0; } - +#if TEST_SAVED_WAVE /*==========================================================================================*/ /** * Simple test that write a sawtooth waveform to a file. @@ -464,6 +466,7 @@ error: printf("ERROR: result = %d\n", result ); return result; } +#endif /* TEST_SAVED_WAVE */ /*==========================================================================================*/ /** @@ -558,26 +561,26 @@ error: int PaQa_TestAnalyzer( void ) { int result; - +#if TEST_SAVED_WAVE // Write a simple wave file. - //if (result = TestSavedWave()) return result; + if ((result = TestSavedWave()) != 0) return result; +#endif /* TEST_SAVED_WAVE */ // Generate single tone and verify presence. - if (result = TestSingleMonoTone()) return result; + if ((result = TestSingleMonoTone()) != 0) return result; // Generate prime series of tones and verify presence. - if (result = TestMixedMonoTones()) return result; + if ((result = TestMixedMonoTones()) != 0) return result; // Detect dropped or added samples in a sine wave recording. - if (result = TestDetectPhaseErrors()) return result; + if ((result = TestDetectPhaseErrors()) != 0) return result; // Test to see if notch filter can knock out the test tone. - if (result = TestNotchFilter()) return result; + if ((result = TestNotchFilter()) != 0) return result; // Detect pops that get back in phase. - if (result = TestDetectPops()) return result; + if ((result = TestDetectPops()) != 0) return result; - return 0; } -- 2.43.0