Change end() to only do one thing, and copy the required stuff into pause()
[dcpomatic.git] / src / lib / dcp_decoder.cc
index 0a57ce7f5922ccb810a19f73be3606b38f79d931..849c8ce78a8ae118b96306ac788084bd10e8792a 100644 (file)
@@ -181,7 +181,7 @@ DCPDecoder::pass ()
                                        AV_PIX_FMT_XYZ12LE,
                                        _forced_reduction
                                        ),
-                               _offset + frame
+                               ContentTime::from_frames(_offset + frame, vfr)
                                );
                } else {
                        video->emit (
@@ -193,7 +193,7 @@ DCPDecoder::pass ()
                                        AV_PIX_FMT_XYZ12LE,
                                        _forced_reduction
                                        ),
-                               _offset + frame
+                               ContentTime::from_frames(_offset + frame, vfr)
                                );
 
                        video->emit (
@@ -205,7 +205,7 @@ DCPDecoder::pass ()
                                        AV_PIX_FMT_XYZ12LE,
                                        _forced_reduction
                                        ),
-                               _offset + frame
+                               ContentTime::from_frames(_offset + frame, vfr)
                                );
                }
        }
@@ -372,8 +372,7 @@ DCPDecoder::get_readers ()
                return;
        }
 
-       DCPOMATIC_ASSERT(video);
-       if (!video->ignore() && (*_reel)->main_picture()) {
+       if (video && !video->ignore() && (*_reel)->main_picture()) {
                auto asset = (*_reel)->main_picture()->asset ();
                auto mono = dynamic_pointer_cast<dcp::MonoPictureAsset> (asset);
                auto stereo = dynamic_pointer_cast<dcp::StereoPictureAsset> (asset);
@@ -392,8 +391,7 @@ DCPDecoder::get_readers ()
                _stereo_reader.reset ();
        }
 
-       DCPOMATIC_ASSERT(audio);
-       if (!audio->ignore() && (*_reel)->main_sound()) {
+       if (audio && !audio->ignore() && (*_reel)->main_sound()) {
                _sound_reader = (*_reel)->main_sound()->asset()->start_read ();
                _sound_reader->set_check_hmac (false);
        } else {
@@ -449,10 +447,12 @@ DCPDecoder::seek (ContentTime t, bool accurate)
 
        /* Pass texts in the pre-roll */
 
-       auto const vfr = _dcp_content->active_video_frame_rate (film());
-       for (int i = 0; i < pre_roll_seconds * vfr; ++i) {
-               pass_texts (pre, (*_reel)->main_picture()->asset()->size());
-               pre += ContentTime::from_frames (1, vfr);
+       if (_reel != _reels.end()) {
+               auto const vfr = _dcp_content->active_video_frame_rate (film());
+               for (int i = 0; i < pre_roll_seconds * vfr; ++i) {
+                       pass_texts (pre, (*_reel)->main_picture()->asset()->size());
+                       pre += ContentTime::from_frames (1, vfr);
+               }
        }
 
        /* Seek to correct position */