+ switch (which) {
+ case CONTENT:
+ {
+ LOG_DEBUG_PLAYER ("Calling pass() on %1", earliest_content->content->path(0));
+ earliest_content->done = earliest_content->decoder->pass ();
+ 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 _last_audio_time
+ to `hide' the fact that no audio was emitted during the referenced DCP (though
+ we need to behave as though it was).
+ */
+ _last_audio_time = dcp->end (_film);
+ }
+ break;
+ }
+ case BLACK:
+ LOG_DEBUG_PLAYER ("Emit black for gap at %1", to_string(_black.position()));
+ emit_video (black_player_video_frame(Eyes::BOTH), _black.position());
+ _black.set_position (_black.position() + one_video_frame());
+ break;
+ case SILENT:
+ {
+ LOG_DEBUG_PLAYER ("Emit silence for gap at %1", to_string(_silent.position()));
+ DCPTimePeriod period (_silent.period_at_position());
+ if (_last_audio_time) {
+ /* Sometimes the thing that happened last finishes fractionally before
+ or after this silence. Bodge the start time of the silence to fix it.
+ I think this is nothing to worry about since we will just add or
+ remove a little silence at the end of some content.
+ */
+ int64_t const error = labs(period.from.get() - _last_audio_time->get());
+ /* Let's not worry about less than a frame at 24fps */
+ int64_t const too_much_error = DCPTime::from_frames(1, 24).get();
+ if (error >= too_much_error) {
+ _film->log()->log(String::compose("Silence starting before or after last audio by %1", error), LogEntry::TYPE_ERROR);
+ }
+ DCPOMATIC_ASSERT (error < too_much_error);
+ period.from = *_last_audio_time;
+ }
+ if (period.duration() > one_video_frame()) {
+ period.to = period.from + one_video_frame();
+ }
+ fill_audio (period);
+ _silent.set_position (period.to);
+ break;
+ }
+ case NONE:
+ done = true;
+ break;