Basics of splitting up Decoder tree like Content.
[dcpomatic.git] / test / audio_decoder_test.cc
index f714e06822e580638fc20465a24b159dbb1d96c0..5eabc4074c80abf25c15b4b3524af062cb2b1ebe 100644 (file)
@@ -58,14 +58,15 @@ public:
        }
 };
 
-class TestAudioDecoder : public AudioDecoder
+class TestAudioDecoder : public Decoder
 {
 public:
        TestAudioDecoder (shared_ptr<TestAudioContent> content, shared_ptr<Log> log)
-               : AudioDecoder (content->audio, false, log)
-               , _test_audio_content (content)
+               : _test_audio_content (content)
                , _position (0)
-       {}
+       {
+               audio.reset (new AudioDecoder (this, content->audio, false, log));
+       }
 
        bool pass (PassReason, bool)
        {
@@ -81,7 +82,7 @@ public:
                        }
                }
 
-               audio (_test_audio_content->audio->stream(), buffers, ContentTime::from_frames (_position, 48000));
+               audio->audio (_test_audio_content->audio->stream(), buffers, ContentTime::from_frames (_position, 48000));
                _position += N;
 
                return N < 2000;
@@ -89,8 +90,8 @@ public:
 
        void seek (ContentTime t, bool accurate)
        {
-               AudioDecoder::seek (t, accurate);
-               _position = t.frames_round (_test_audio_content->audio->resampled_audio_frame_rate ());
+               audio->seek (t, accurate);
+               _position = t.frames_round (_test_audio_content->audio->resampled_frame_rate ());
        }
 
 private:
@@ -104,8 +105,8 @@ shared_ptr<TestAudioDecoder> decoder;
 static ContentAudio
 get (Frame from, Frame length)
 {
-       decoder->seek (ContentTime::from_frames (from, content->audio->resampled_audio_frame_rate ()), true);
-       ContentAudio ca = decoder->get_audio (content->audio->stream(), from, length, true);
+       decoder->seek (ContentTime::from_frames (from, content->audio->resampled_frame_rate ()), true);
+       ContentAudio ca = decoder->audio->get_audio (content->audio->stream(), from, length, true);
        BOOST_CHECK_EQUAL (ca.frame, from);
        return ca;
 }
@@ -137,8 +138,8 @@ BOOST_AUTO_TEST_CASE (audio_decoder_get_audio_test)
 
        /* Read off the end */
 
-       Frame const from = content->audio->resampled_audio_frame_rate() * 61;
-       Frame const length = content->audio->resampled_audio_frame_rate() * 4;
+       Frame const from = content->audio->resampled_frame_rate() * 61;
+       Frame const length = content->audio->resampled_frame_rate() * 4;
        ContentAudio ca = get (from, length);
 
        for (int i = 0; i < content->audio->stream()->channels(); ++i) {