Handle multiple audio streams in a single piece of content
[dcpomatic.git] / src / lib / dcp_content.cc
index 51c7f8549ba504fe75a090509893317da526ca9d..b707754a78957bc2e3291659fc01c3e4d84606fe 100644 (file)
@@ -90,11 +90,13 @@ DCPContent::examine (shared_ptr<Job> job)
        take_from_video_examiner (examiner);
        take_from_audio_examiner (examiner);
 
-       boost::mutex::scoped_lock lm (_mutex);
-       _name = examiner->name ();
-       _has_subtitles = examiner->has_subtitles ();
-       _encrypted = examiner->encrypted ();
-       _kdm_valid = examiner->kdm_valid ();
+       {
+               boost::mutex::scoped_lock lm (_mutex);
+               _name = examiner->name ();
+               _has_subtitles = examiner->has_subtitles ();
+               _encrypted = examiner->encrypted ();
+               _kdm_valid = examiner->kdm_valid ();
+       }
 
        if (could_be_played != can_be_played ()) {
                signal_changed (DCPContentProperty::CAN_BE_PLAYED);
@@ -141,7 +143,8 @@ DCPContent::full_length () const
 {
        shared_ptr<const Film> film = _film.lock ();
        DCPOMATIC_ASSERT (film);
-       return DCPTime (video_length (), FrameRateChange (video_frame_rate (), film->video_frame_rate ()));
+       FrameRateChange const frc (video_frame_rate (), film->video_frame_rate ());
+       return DCPTime::from_frames (rint (video_length () * frc.factor ()), film->video_frame_rate ());
 }
 
 string
@@ -159,6 +162,7 @@ DCPContent::add_kdm (dcp::EncryptedKDM k)
 bool
 DCPContent::can_be_played () const
 {
+       boost::mutex::scoped_lock lm (_mutex);
        return !_encrypted || _kdm_valid;
 }