X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fcontent.cc;h=7966219ff60a4bf186a3af6ce58a6b52aa0a97e5;hb=491daf8790f35611052d8954d5d74df275dcda18;hp=f09012765a7cbe7616d1e2ae40a870981b74604a;hpb=f0be0f0e060e40d9a0da1b44429ef41901b8a536;p=dcpomatic.git diff --git a/src/lib/content.cc b/src/lib/content.cc index f09012765..7966219ff 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -20,6 +20,7 @@ #include #include #include +#include #include "content.h" #include "util.h" #include "content_factory.h" @@ -35,8 +36,9 @@ using std::set; using std::list; using std::cout; using std::vector; +using std::max; using boost::shared_ptr; -using boost::lexical_cast; +using libdcp::raw_convert; int const ContentProperty::PATH = 400; int const ContentProperty::POSITION = 401; @@ -119,9 +121,9 @@ Content::as_xml (xmlpp::Node* node) const node->add_child("Path")->add_child_text (i->string ()); } node->add_child("Digest")->add_child_text (_digest); - node->add_child("Position")->add_child_text (lexical_cast (_position)); - node->add_child("TrimStart")->add_child_text (lexical_cast (_trim_start)); - node->add_child("TrimEnd")->add_child_text (lexical_cast (_trim_end)); + node->add_child("Position")->add_child_text (raw_convert (_position)); + node->add_child("TrimStart")->add_child_text (raw_convert (_trim_start)); + node->add_child("TrimEnd")->add_child_text (raw_convert (_trim_end)); } void @@ -150,6 +152,10 @@ Content::set_position (Time p) { { boost::mutex::scoped_lock lm (_mutex); + if (p == _position) { + return; + } + _position = p; } @@ -191,7 +197,10 @@ Content::clone () const xmlpp::Document doc; xmlpp::Node* node = doc.create_root_node ("Content"); as_xml (node); - return content_factory (film, cxml::NodePtr (new cxml::Node (node)), Film::state_version); + + /* notes is unused here (we assume) */ + list notes; + return content_factory (film, cxml::NodePtr (new cxml::Node (node)), Film::current_state_version, notes); } string @@ -203,7 +212,7 @@ Content::technical_summary () const Time Content::length_after_trim () const { - return full_length() - trim_start() - trim_end(); + return max (int64_t (0), full_length() - trim_start() - trim_end()); } /** @param t A time relative to the start of this content (not the position). @@ -232,7 +241,7 @@ Content::identifier () const } bool -Content::path_valid () const +Content::paths_valid () const { for (vector::const_iterator i = _paths.begin(); i != _paths.end(); ++i) { if (!boost::filesystem::exists (*i)) {