Remove Film dependency from Empty.
authorCarl Hetherington <cth@carlh.net>
Wed, 2 Aug 2017 15:00:47 +0000 (16:00 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 14 Aug 2017 20:07:48 +0000 (21:07 +0100)
src/lib/empty.cc
src/lib/empty.h
src/lib/player.cc
test/empty_test.cc

index 98bf1f3d186e2619d864706e82dbebde22b2b108..68a153b0755d39a4869781847f12451fe042a4f8 100644 (file)
@@ -34,16 +34,16 @@ using boost::shared_ptr;
 using boost::dynamic_pointer_cast;
 using boost::function;
 
-Empty::Empty (shared_ptr<const Film> film, function<shared_ptr<ContentPart> (Content *)> part)
+Empty::Empty (ContentList content, DCPTime length, function<shared_ptr<ContentPart> (Content *)> part)
 {
        list<DCPTimePeriod> full;
-       BOOST_FOREACH (shared_ptr<Content> i, film->content()) {
+       BOOST_FOREACH (shared_ptr<Content> i, content) {
                if (part (i.get())) {
                        full.push_back (DCPTimePeriod (i->position(), i->end()));
                }
        }
 
-       _periods = subtract (DCPTimePeriod(DCPTime(), film->length()), coalesce(full));
+       _periods = subtract (DCPTimePeriod(DCPTime(), length), coalesce(full));
 
        if (!_periods.empty ()) {
                _position = _periods.front().from;
index ee11714289eaa42fe729c20d0854f00e019a849c..d8b00047fbe2e3520ed2a91349e4cb130bc173db 100644 (file)
@@ -31,7 +31,7 @@ class Empty
 {
 public:
        Empty () {}
-       Empty (boost::shared_ptr<const Film> film, boost::function<boost::shared_ptr<ContentPart> (Content *)> part);
+       Empty (ContentList content, DCPTime length, boost::function<boost::shared_ptr<ContentPart> (Content *)> part);
 
        DCPTime position () const {
                return _position;
index db09d1768740f83ca12c47136a0e98a5903d022a..3d191a302db213f651e8a3a02bfb3b8d5ed5b375 100644 (file)
@@ -156,8 +156,8 @@ Player::setup_pieces ()
                }
        }
 
-       _black = Empty (_film, bind(&Content::video, _1));
-       _silent = Empty (_film, bind(&Content::audio, _1));
+       _black = Empty (_film->content(), _film->length(), bind(&Content::video, _1));
+       _silent = Empty (_film->content(), _film->length(), bind(&Content::audio, _1));
 
        _last_video_time = DCPTime ();
        _last_audio_time = DCPTime ();
index 326ae9530cb15d248d85f6866dace92a3c58902b..71397273942bbbe8312ec90bc1b4a42ffd0a8ff8 100644 (file)
@@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE (empty_test1)
        contentB->video->set_length (1);
        contentB->set_position (DCPTime::from_frames (7, vfr));
 
-       Empty black (film, bind(&Content::video, _1));
+       Empty black (film->content(), film->length(), bind(&Content::video, _1));
        BOOST_REQUIRE_EQUAL (black._periods.size(), 2);
        BOOST_CHECK (black._periods.front().from == DCPTime());
        BOOST_CHECK (black._periods.front().to == DCPTime::from_frames(2, vfr));
@@ -84,7 +84,7 @@ BOOST_AUTO_TEST_CASE (empty_test2)
        contentB->video->set_length (1);
        contentB->set_position (DCPTime::from_frames (7, vfr));
 
-       Empty black (film, bind(&Content::video, _1));
+       Empty black (film->content(), film->length(), bind(&Content::video, _1));
        BOOST_REQUIRE_EQUAL (black._periods.size(), 1);
        BOOST_CHECK (black._periods.front().from == DCPTime::from_frames(3, vfr));
        BOOST_CHECK (black._periods.front().to == DCPTime::from_frames(7, vfr));