X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fwriter.cc;h=1a11a482bf0b0155d948848474e5cc18333b0296;hb=8d20417855c563afa08bda167ccf8ab8609208fa;hp=8d73b31267a368f768598a9e3e5ab1343f024bef;hpb=2898a88b4554335439891d8198bed8c820c20396;p=dcpomatic.git diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 8d73b3126..1a11a482b 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -46,6 +46,8 @@ #include #include #include +#include +#include #include #include @@ -364,21 +366,24 @@ try } DCPOMATIC_ASSERT (i != _queue.rend()); - QueueItem qi = *i; - ++_pushed_to_disk; - lock.unlock (); + /* i is valid here, even though we don't hold a lock on the mutex, + since list iterators are unaffected by insertion and only this + thread could erase the last item in the list. + */ + LOG_GENERAL ( "Writer full (awaiting %1 [last eye was %2]); pushes %3 to disk", _last_written_frame + 1, - _last_written_eyes, qi.frame + _last_written_eyes, i->frame ); - qi.encoded->write (_film, qi.frame, qi.eyes); + i->encoded->write (_film, i->frame, i->eyes); + lock.lock (); - qi.encoded.reset (); + i->encoded.reset (); --_queued_full_in_memory; } @@ -503,7 +508,31 @@ Writer::finish () } if (_subtitle_content) { - _subtitle_content->write_xml (_film->dir (_film->dcp_name ()) / _film->subtitle_xml_filename ()); + boost::filesystem::path const liberation = shared_path () / "LiberationSans-Regular.ttf"; + + /* Add all the fonts to the subtitle content and as assets to the DCP */ + BOOST_FOREACH (shared_ptr i, _fonts) { + boost::filesystem::path const from = i->file.get_value_or (liberation); + _subtitle_content->add_font (i->id, from.leaf().string ()); + + boost::filesystem::path to = _film->dir (_film->dcp_name ()) / _subtitle_content->id (); + boost::filesystem::create_directories (to, ec); + if (ec) { + throw FileError (_("Could not create directory"), to); + } + + to /= from.leaf(); + + boost::system::error_code ec; + boost::filesystem::copy_file (from, to, ec); + if (ec) { + throw FileError ("Could not copy font to DCP", from); + } + + dcp.add (shared_ptr (new dcp::Font (to))); + } + + _subtitle_content->write_xml (_film->dir (_film->dcp_name ()) / _subtitle_content->id () / _film->subtitle_xml_filename ()); reel->add (shared_ptr ( new dcp::ReelSubtitleAsset ( _subtitle_content, @@ -643,7 +672,11 @@ Writer::write (PlayerSubtitles subs) } if (!_subtitle_content) { - _subtitle_content.reset (new dcp::InteropSubtitleContent (_film->name(), _film->subtitle_language ())); + string lang = _film->subtitle_language (); + if (lang.empty ()) { + lang = "Unknown"; + } + _subtitle_content.reset (new dcp::InteropSubtitleContent (_film->name(), lang)); } for (list::const_iterator i = subs.text.begin(); i != subs.text.end(); ++i) { @@ -654,18 +687,8 @@ Writer::write (PlayerSubtitles subs) void Writer::write (list > fonts) { - if (fonts.empty ()) { - return; - } - - if (!_subtitle_content) { - _subtitle_content.reset (new dcp::InteropSubtitleContent (_film->name(), _film->subtitle_language ())); - } - - for (list >::const_iterator i = fonts.begin(); i != fonts.end(); ++i) { - /* XXX: this LiberationSans-Regular needs to be a path to a DCP-o-matic-distributed copy */ - _subtitle_content->add_font ((*i)->id, (*i)->file.get_value_or ("LiberationSans-Regular.ttf").leaf().string ()); - } + /* Just keep a list of fonts and we'll deal with them in ::finish */ + copy (fonts.begin (), fonts.end (), back_inserter (_fonts)); } bool