wip: Error when failing to read MXF frame.
[dcpomatic.git] / src / lib / player.cc
index 76e7239aa83f02c7dc7699023a1fd958ff8fc478..dce495eb00140fce0bf8efe9c84b8e913aaa30da 100644 (file)
@@ -381,10 +381,26 @@ Player::setup_pieces ()
        for (auto piece = _pieces.begin(); piece != _pieces.end(); ++piece) {
                if (ignore_overlap((*piece)->content->video)) {
                        /* Look for content later in the content list with in-use video that overlaps this */
-                       auto const period = DCPTimePeriod((*piece)->content->position(), (*piece)->content->end(film));
+                       auto const period = (*piece)->content->period(film);
                        for (auto later_piece = std::next(piece); later_piece != _pieces.end(); ++later_piece) {
                                if (ignore_overlap((*later_piece)->content->video)) {
-                                       (*piece)->ignore_video = DCPTimePeriod((*later_piece)->content->position(), (*later_piece)->content->end(film)).overlap(period);
+                                       if (auto overlap = (*later_piece)->content->period(film).overlap(period)) {
+                                               (*piece)->ignore_video.push_back(*overlap);
+                                       }
+                               }
+                       }
+               }
+       }
+
+       for (auto piece = _pieces.begin(); piece != _pieces.end(); ++piece) {
+               if ((*piece)->content->atmos) {
+                       /* Look for content later in the content list with ATMOS that overlaps this */
+                       auto const period = (*piece)->content->period(film);
+                       for (auto later_piece = std::next(piece); later_piece != _pieces.end(); ++later_piece) {
+                               if ((*later_piece)->content->atmos) {
+                                       if (auto overlap = (*later_piece)->content->period(film).overlap(period)) {
+                                               (*piece)->ignore_atmos.push_back(*overlap);
+                                       }
                                }
                        }
                }
@@ -741,7 +757,11 @@ Player::pass ()
        case CONTENT:
        {
                LOG_DEBUG_PLAYER ("Calling pass() on %1", earliest_content->content->path(0));
-               earliest_content->done = earliest_content->decoder->pass ();
+               auto result = earliest_content->decoder->pass();
+               earliest_content->done = result.is_finished();
+               if (result.is_error()) {
+                       Error(result.error_message());
+               }
                auto dcp = dynamic_pointer_cast<DCPContent>(earliest_content->content);
                if (dcp && !_play_referenced && dcp->reference_audio()) {
                        /* We are skipping some referenced DCP audio content, so we need to update _next_audio_time
@@ -1004,7 +1024,12 @@ Player::video (weak_ptr<Piece> weak_piece, ContentVideo video)
                return;
        }
 
-       if (piece->ignore_video && piece->ignore_video->contains(time)) {
+       auto ignore_video = std::find_if(
+               piece->ignore_video.begin(),
+               piece->ignore_video.end(),
+               [time](DCPTimePeriod period) { return period.contains(time); }
+               );
+       if (ignore_video != piece->ignore_video.end()) {
                return;
        }
 
@@ -1592,6 +1617,15 @@ Player::atmos (weak_ptr<Piece> weak_piece, ContentAtmos data)
                return;
        }
 
+       auto ignore_atmos = std::find_if(
+               piece->ignore_atmos.begin(),
+               piece->ignore_atmos.end(),
+               [dcp_time](DCPTimePeriod period) { return period.contains(dcp_time); }
+               );
+       if (ignore_atmos != piece->ignore_atmos.end()) {
+               return;
+       }
+
        Atmos (data.data, dcp_time, data.metadata);
 }