Split audio; builds.
[dcpomatic.git] / test / audio_delay_test.cc
index 68e14ff3ca353f470d9f09f8c14112f6713b34a4..f12e8717ea3a87742daf8c87adff1271a0a9536c 100644 (file)
 #include <dcp/sound_frame.h>
 #include <dcp/cpl.h>
 #include <dcp/reel.h>
-#include <dcp/sound_mxf.h>
+#include <dcp/sound_asset.h>
 #include <dcp/reel_sound_asset.h>
 #include "lib/sndfile_content.h"
 #include "lib/dcp_content_type.h"
 #include "lib/ratio.h"
 #include "lib/film.h"
+#include "lib/audio_content.h"
 #include "test.h"
+#include <iostream>
 
 using std::string;
 using std::cout;
@@ -43,6 +45,8 @@ using boost::shared_ptr;
 static
 void test_audio_delay (int delay_in_ms)
 {
+       BOOST_TEST_MESSAGE ("Testing delay of " << delay_in_ms);
+
        string const film_name = "audio_delay_test_" + lexical_cast<string> (delay_in_ms);
        shared_ptr<Film> film = new_test_film (film_name);
        film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
@@ -50,7 +54,7 @@ void test_audio_delay (int delay_in_ms)
        film->set_name (film_name);
 
        shared_ptr<SndfileContent> content (new SndfileContent (film, "test/data/staircase.wav"));
-       content->set_audio_delay (delay_in_ms);
+       content->audio->set_audio_delay (delay_in_ms);
        film->examine_and_add_content (content);
        wait_for_jobs ();
 
@@ -73,11 +77,11 @@ void test_audio_delay (int delay_in_ms)
        /* Delay in frames */
        int const delay_in_frames = delay_in_ms * 48000 / 1000;
 
-       while (n < sound_asset->mxf()->intrinsic_duration()) {
-               shared_ptr<const dcp::SoundFrame> sound_frame = sound_asset->mxf()->get_frame (frame++);
+       while (n < sound_asset->asset()->intrinsic_duration()) {
+               shared_ptr<const dcp::SoundFrame> sound_frame = sound_asset->asset()->get_frame (frame++);
                uint8_t const * d = sound_frame->data ();
-               
-               for (int i = 0; i < sound_frame->size(); i += (3 * sound_asset->mxf()->channels())) {
+
+               for (int i = 0; i < sound_frame->size(); i += (3 * sound_asset->asset()->channels())) {
 
                        /* Mono input so it will appear on centre */
                        int const sample = d[i + 7] | (d[i + 8] << 8);
@@ -87,7 +91,7 @@ void test_audio_delay (int delay_in_ms)
                                delayed = 0;
                        }
 
-                       BOOST_CHECK_EQUAL (sample, delayed);
+                       BOOST_REQUIRE_EQUAL (sample, delayed);
                        ++n;
                }
        }