X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Flib%2Factive_text.cc;h=3a7e1a27ebeff7a43e63877e65416fc82b102bb0;hb=7066750d52663968960d496d256a0dfd8c96c856;hp=885aa034ce88d131ced81e892a3de6e8c8e66186;hpb=0ab83642f0c96ae2681beae04873b3226338a570;p=dcpomatic.git diff --git a/src/lib/active_text.cc b/src/lib/active_text.cc index 885aa034c..3a7e1a27e 100644 --- a/src/lib/active_text.cc +++ b/src/lib/active_text.cc @@ -19,7 +19,6 @@ */ #include "active_text.h" -#include "piece.h" #include "text_content.h" #include #include @@ -30,25 +29,28 @@ using std::make_pair; using boost::weak_ptr; using boost::shared_ptr; using boost::optional; +using namespace dcpomatic; -/** Get the subtitles that should be burnt into a given period. +/** Get the open captions that should be burnt into a given period. * @param period Period of interest. - * @param always_burn_subtitles Always burn subtitles even if their content is not set to burn. + * @param always_burn_captions Always burn captions even if their content is not set to burn. */ list -ActiveText::get_burnt (DCPTimePeriod period, bool always_burn_subtitles) const +ActiveText::get_burnt (DCPTimePeriod period, bool always_burn_captions) const { + boost::mutex::scoped_lock lm (_mutex); + list ps; for (Map::const_iterator i = _data.begin(); i != _data.end(); ++i) { - shared_ptr piece = i->first.lock (); - if (!piece) { + shared_ptr caption = i->first.lock (); + if (!caption) { continue; } - if (!piece->content->subtitle->use() || (!always_burn_subtitles && !piece->content->subtitle->burn())) { - /* Not burning this piece */ + if (!caption->use() || (!always_burn_captions && !caption->burn())) { + /* Not burning this content */ continue; } @@ -70,6 +72,8 @@ ActiveText::get_burnt (DCPTimePeriod period, bool always_burn_subtitles) const void ActiveText::clear_before (DCPTime time) { + boost::mutex::scoped_lock lm (_mutex); + Map updated; for (Map::const_iterator i = _data.begin(); i != _data.end(); ++i) { list as; @@ -86,45 +90,51 @@ ActiveText::clear_before (DCPTime time) } /** Add a new subtitle with a from time. - * @param piece Piece that the subtitle is from. + * @param content Content that the subtitle is from. * @param ps Subtitles. * @param from From time for these subtitles. */ void -ActiveText::add_from (weak_ptr piece, PlayerText ps, DCPTime from) +ActiveText::add_from (weak_ptr content, PlayerText ps, DCPTime from) { - if (_data.find(piece) == _data.end()) { - _data[piece] = list(); + boost::mutex::scoped_lock lm (_mutex); + + if (_data.find(content) == _data.end()) { + _data[content] = list(); } - _data[piece].push_back (Period (ps, from)); + _data[content].push_back (Period (ps, from)); } -/** Add the to time for the last subtitle added from a piece. - * @param piece Piece that the subtitle is from. - * @param to To time for the last subtitle submitted to add_from for this piece. +/** Add the to time for the last subtitle added from a piece of content. + * @param content Content that the subtitle is from. + * @param to To time for the last subtitle submitted to add_from for this content. * @return Return the corresponding subtitles and their from time. */ pair -ActiveText::add_to (weak_ptr piece, DCPTime to) +ActiveText::add_to (weak_ptr content, DCPTime to) { - DCPOMATIC_ASSERT (_data.find(piece) != _data.end()); + boost::mutex::scoped_lock lm (_mutex); - _data[piece].back().to = to; + DCPOMATIC_ASSERT (_data.find(content) != _data.end()); - BOOST_FOREACH (PlainText& i, _data[piece].back().subs.text) { + _data[content].back().to = to; + + BOOST_FOREACH (StringText& i, _data[content].back().subs.string) { i.set_out (dcp::Time(to.seconds(), 1000)); } - return make_pair (_data[piece].back().subs, _data[piece].back().from); + return make_pair (_data[content].back().subs, _data[content].back().from); } -/** @param piece A piece. - * @return true if we have any active subtitles from this piece. +/** @param content Some content. + * @return true if we have any active subtitles from this content. */ bool -ActiveText::have (weak_ptr piece) const +ActiveText::have (weak_ptr content) const { - Map::const_iterator i = _data.find(piece); + boost::mutex::scoped_lock lm (_mutex); + + Map::const_iterator i = _data.find(content); if (i == _data.end()) { return false; } @@ -135,5 +145,6 @@ ActiveText::have (weak_ptr piece) const void ActiveText::clear () { + boost::mutex::scoped_lock lm (_mutex); _data.clear (); }