From 8da27200d18fe4c471a759dde8e10d85ff29d277 Mon Sep 17 00:00:00 2001 From: Sakari Bergen Date: Sun, 27 Dec 2009 22:09:40 +0000 Subject: - Fix process callbakc handling during export - Fix filename handling when exporting multiple files - Some updates to audiographer git-svn-id: svn://localhost/ardour2/branches/3.0@6402 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/audiographer/tests/sr_converter_test.cc | 28 ++++++++++++++++++++++++++++ libs/audiographer/tests/utils.h | 16 ++++++++++++++++ 2 files changed, 44 insertions(+) (limited to 'libs/audiographer/tests') diff --git a/libs/audiographer/tests/sr_converter_test.cc b/libs/audiographer/tests/sr_converter_test.cc index 59c05806c6..e7b49a1b71 100644 --- a/libs/audiographer/tests/sr_converter_test.cc +++ b/libs/audiographer/tests/sr_converter_test.cc @@ -9,6 +9,7 @@ class SampleRateConverterTest : public CppUnit::TestFixture CPPUNIT_TEST (testNoConversion); CPPUNIT_TEST (testUpsampleLength); CPPUNIT_TEST (testDownsampleLength); + CPPUNIT_TEST (testRespectsEndOfInput); CPPUNIT_TEST_SUITE_END (); public: @@ -17,6 +18,7 @@ class SampleRateConverterTest : public CppUnit::TestFixture frames = 128; random_data = TestUtils::init_random_data(frames); sink.reset (new AppendingVectorSink()); + grabber.reset (new ProcessContextGrabber()); converter.reset (new SampleRateConverter (1)); } @@ -88,10 +90,36 @@ class SampleRateConverterTest : public CppUnit::TestFixture CPPUNIT_ASSERT (half_frames - tolerance < frames_output && frames_output < half_frames + tolerance); } + void testRespectsEndOfInput() + { + assert (frames % 2 == 0); + nframes_t const half_frames = frames / 2; + + converter->init (44100, 48000); + converter->allocate_buffers (half_frames); + converter->add_output (grabber); + + ProcessContext c (random_data, half_frames, 1); + converter->process (c); + ProcessContext c2 (&random_data[half_frames], half_frames / 2, 1); + c2.set_flag (ProcessContext::EndOfInput); + converter->process (c2); + + for (std::list >::iterator it = grabber->contexts.begin(); it != grabber->contexts.end(); ++it) { + std::list >::iterator next = it; ++next; + if (next == grabber->contexts.end()) { + CPPUNIT_ASSERT (it->has_flag (ProcessContext::EndOfInput)); + } else { + CPPUNIT_ASSERT (!it->has_flag (ProcessContext::EndOfInput)); + } + } + } + private: boost::shared_ptr converter; boost::shared_ptr > sink; + boost::shared_ptr > grabber; float * random_data; nframes_t frames; diff --git a/libs/audiographer/tests/utils.h b/libs/audiographer/tests/utils.h index 6b6a1fea0f..b13a7b7f07 100644 --- a/libs/audiographer/tests/utils.h +++ b/libs/audiographer/tests/utils.h @@ -12,6 +12,7 @@ #include "audiographer/exception.h" #include +#include #include #include #include @@ -116,4 +117,19 @@ class ThrowingSink : public AudioGrapher::Sink using AudioGrapher::Sink::process; }; +template +class ProcessContextGrabber : public AudioGrapher::Sink +{ + public: + void process (AudioGrapher::ProcessContext const & c) + { + contexts.push_back (c); + } + using AudioGrapher::Sink::process; + + typedef std::list > ContextList; + ContextList contexts; + +}; + #endif // AUDIOGRAPHER_TESTS_UTILS_H -- cgit v1.2.3