summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2017-07-12 15:17:50 +0100
committerCarl Hetherington <cth@carlh.net>2017-07-12 15:17:50 +0100
commit19c8f785894306bfa7998775d462f7f80cde8eaf (patch)
treef1007ba7dc48ded78567bb133c5bcfbe58149e1e /src/lib
parentdbaeeb06e7bc4bb1667a5a17076a0723284ed66c (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')
-rw-r--r--src/lib/empty.cc18
-rw-r--r--src/lib/empty.h6
2 files changed, 16 insertions, 8 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;
}
diff --git a/src/lib/empty.h b/src/lib/empty.h
index 3c676deeb..ee1171428 100644
--- a/src/lib/empty.h
+++ b/src/lib/empty.h
@@ -24,12 +24,14 @@
#include <list>
struct empty_test1;
+struct empty_test2;
+struct player_subframe_test;
class Empty
{
public:
Empty () {}
- Empty (boost::shared_ptr<const Playlist> playlist, boost::function<boost::shared_ptr<ContentPart> (Content *)> part);
+ Empty (boost::shared_ptr<const Film> film, boost::function<boost::shared_ptr<ContentPart> (Content *)> part);
DCPTime position () const {
return _position;
@@ -43,6 +45,8 @@ public:
private:
friend struct ::empty_test1;
+ friend struct ::empty_test2;
+ friend struct ::player_subframe_test;
std::list<DCPTimePeriod> _periods;
DCPTime _position;