New DCPTime/ContentTime types.
[dcpomatic.git] / test / audio_merger_test.cc
index 31d055ab703b2961e5d447198e7758c5cc53075e..e8af22d2ae56a54b0361fe04ef90e3806c3a7e02 100644 (file)
@@ -29,27 +29,22 @@ using boost::bind;
 
 static shared_ptr<const AudioBuffers> last_audio;
 
-static int
-pass_through (int x)
-{
-       return x;
-}
-
 BOOST_AUTO_TEST_CASE (audio_merger_test1)
 {
-       AudioMerger<int, int> merger (1, bind (&pass_through, _1), boost::bind (&pass_through, _1));
+       int const frame_rate = 48000;
+       AudioMerger merger (1, frame_rate);
 
        /* Push 64 samples, 0 -> 63 at time 0 */
        shared_ptr<AudioBuffers> buffers (new AudioBuffers (1, 64));
        for (int i = 0; i < 64; ++i) {
                buffers->data()[0][i] = i;
        }
-       merger.push (buffers, 0);
+       merger.push (buffers, DCPTime ());
 
        /* Push 64 samples, 0 -> 63 at time 22 */
-       merger.push (buffers, 22);
+       merger.push (buffers, DCPTime::from_frames (22, frame_rate));
 
-       TimedAudioBuffers<int> tb = merger.pull (22);
+       TimedAudioBuffers<DCPTime> tb = merger.pull (DCPTime::from_frames (22, frame_rate));
        BOOST_CHECK (tb.audio != shared_ptr<const AudioBuffers> ());
        BOOST_CHECK_EQUAL (tb.audio->frames(), 22);
        BOOST_CHECK_EQUAL (tb.time, 0);
@@ -63,7 +58,7 @@ BOOST_AUTO_TEST_CASE (audio_merger_test1)
 
        /* That flush should give us 64 samples at 22 */
        BOOST_CHECK_EQUAL (tb.audio->frames(), 64);
-       BOOST_CHECK_EQUAL (tb.time, 22);
+       BOOST_CHECK_EQUAL (tb.time, DCPTime::from_frames (22, frame_rate));
 
        /* Check the sample values */
        for (int i = 0; i < 64; ++i) {
@@ -77,16 +72,17 @@ BOOST_AUTO_TEST_CASE (audio_merger_test1)
 
 BOOST_AUTO_TEST_CASE (audio_merger_test2)
 {
-       AudioMerger<int, int> merger (1, bind (&pass_through, _1), boost::bind (&pass_through, _1));
+       int const frame_rate = 48000;
+       AudioMerger merger (1, frame_rate);
 
        /* Push 64 samples, 0 -> 63 at time 9 */
        shared_ptr<AudioBuffers> buffers (new AudioBuffers (1, 64));
        for (int i = 0; i < 64; ++i) {
                buffers->data()[0][i] = i;
        }
-       merger.push (buffers, 9);
+       merger.push (buffers, DCPTime::from_frames (9, frame_rate));
 
-       TimedAudioBuffers<int> tb = merger.pull (9);
+       TimedAudioBuffers<DCPTime> tb = merger.pull (DCPTime::from_frames (9, frame_rate));
        BOOST_CHECK_EQUAL (tb.audio->frames(), 9);
        BOOST_CHECK_EQUAL (tb.time, 0);