Fix pull timing; fix units of ReelWriter::total_written_audio_frames.
[dcpomatic.git] / src / lib / reel_writer.cc
index 6432c294bbee29746280a953fd5bce5052bb9dfe..e008bf6311ae5acbcbcfa8a1b1d41bbfb75aa225 100644 (file)
@@ -88,6 +88,7 @@ ReelWriter::ReelWriter (
 
        if (_film->encrypted ()) {
                _picture_asset->set_key (_film->key ());
+               _picture_asset->set_context_id (_film->context_id ());
        }
 
        _picture_asset->set_file (
@@ -134,10 +135,14 @@ ReelWriter::write_frame_info (Frame frame, Eyes eyes, dcp::FrameInfo info) const
        bool const read = boost::filesystem::exists (info_file);
 
 #ifdef DCPOMATIC_WINDOWS
-       LOG_GENERAL (
-               "Checked %1 (exists %2) length is %3 perms are %4",
-               info_file, read ? 1 : 0, boost::filesystem::file_size (info_file), int(boost::filesystem::status(info_file).permissions())
-               );
+       if (read) {
+               LOG_GENERAL (
+                       "Checked %1 (which exists) length is %2 perms are %3",
+                       info_file, boost::filesystem::file_size (info_file), int(boost::filesystem::status(info_file).permissions())
+                       );
+       } else {
+               LOG_GENERAL ("Checked %1 (which does not exist)", info_file);
+       }
 #endif
 
        if (read) {
@@ -271,6 +276,7 @@ ReelWriter::finish ()
 {
        if (!_picture_asset_writer->finalize ()) {
                /* Nothing was written to the picture asset */
+               LOG_GENERAL ("Nothing was written to reel %1 of %2", _reel_index, _reel_count);
                _picture_asset.reset ();
        }
 
@@ -339,15 +345,21 @@ ReelWriter::create_reel (list<ReferencedReelAsset> const & refs, list<shared_ptr
                        reel_picture_asset.reset (new dcp::ReelStereoPictureAsset (stereo, 0));
                }
        } else {
+               LOG_GENERAL ("no picture asset of our own; look through %1", refs.size());
                /* We don't have a picture asset of our own; hopefully we have one to reference */
                BOOST_FOREACH (ReferencedReelAsset j, refs) {
                        shared_ptr<dcp::ReelPictureAsset> k = dynamic_pointer_cast<dcp::ReelPictureAsset> (j.asset);
+                       if (k) {
+                               LOG_GENERAL ("candidate picture asset period is %1-%2", j.period.from.get(), j.period.to.get());
+                       }
                        if (k && j.period == _period) {
                                reel_picture_asset = k;
                        }
                }
        }
 
+       LOG_GENERAL ("create_reel for %1-%2; %3 of %4", _period.from.get(), _period.to.get(), _reel_index, _reel_count);
+
        DCPOMATIC_ASSERT (reel_picture_asset);
        reel->add (reel_picture_asset);
 
@@ -468,7 +480,7 @@ ReelWriter::write (shared_ptr<const AudioBuffers> audio)
                _sound_asset_writer->write (audio->data(), audio->frames());
        }
 
-       ++_total_written_audio_frames;
+       _total_written_audio_frames += audio->frames ();
 }
 
 void