diff options
| author | Carl Hetherington <cth@carlh.net> | 2017-07-12 15:17:50 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2017-07-12 15:17:50 +0100 |
| commit | 19c8f785894306bfa7998775d462f7f80cde8eaf (patch) | |
| tree | f1007ba7dc48ded78567bb133c5bcfbe58149e1e /src/lib/empty.cc | |
| parent | dbaeeb06e7bc4bb1667a5a17076a0723284ed66c (diff) | |
Use Film::length() rather than Playlist::length() (former is rounded up
to the next video frame). Fix thinko in ::done(). Fix initial value
of _position when the first empty period does not start at time 0.
Diffstat (limited to 'src/lib/empty.cc')
| -rw-r--r-- | src/lib/empty.cc | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/lib/empty.cc b/src/lib/empty.cc index 2233b4342..98bf1f3d1 100644 --- a/src/lib/empty.cc +++ b/src/lib/empty.cc @@ -19,6 +19,7 @@ */ #include "empty.h" +#include "film.h" #include "playlist.h" #include "content.h" #include "content_part.h" @@ -33,16 +34,20 @@ using boost::shared_ptr; using boost::dynamic_pointer_cast; using boost::function; -Empty::Empty (shared_ptr<const Playlist> playlist, function<shared_ptr<ContentPart> (Content *)> part) +Empty::Empty (shared_ptr<const Film> film, function<shared_ptr<ContentPart> (Content *)> part) { list<DCPTimePeriod> full; - BOOST_FOREACH (shared_ptr<Content> i, playlist->content()) { + BOOST_FOREACH (shared_ptr<Content> i, film->content()) { if (part (i.get())) { full.push_back (DCPTimePeriod (i->position(), i->end())); } } - _periods = subtract (DCPTimePeriod(DCPTime(), playlist->length()), coalesce(full)); + _periods = subtract (DCPTimePeriod(DCPTime(), film->length()), coalesce(full)); + + if (!_periods.empty ()) { + _position = _periods.front().from; + } } void @@ -79,11 +84,10 @@ Empty::period_at_position () const bool Empty::done () const { + DCPTime latest; BOOST_FOREACH (DCPTimePeriod i, _periods) { - if (i.contains(_position)) { - return false; - } + latest = max (latest, i.to); } - return true; + return _position >= latest; } |
