Merge master.
[dcpomatic.git] / src / lib / player.cc
index 3859915f87520cb69beb9d21d84f2355b8b83919..f83e4ed26b7368228db0cad5e476d27c05a1ab7b 100644 (file)
@@ -81,7 +81,7 @@ Player::Player (shared_ptr<const Film> f, shared_ptr<const Playlist> p)
        _playlist_changed_connection = _playlist->Changed.connect (bind (&Player::playlist_changed, this));
        _playlist_content_changed_connection = _playlist->ContentChanged.connect (bind (&Player::content_changed, this, _1, _2, _3));
        _film_changed_connection = _film->Changed.connect (bind (&Player::film_changed, this, _1));
-       set_video_container_size (fit_ratio_within (_film->container()->ratio (), _film->full_frame ()));
+       set_video_container_size (_film->frame_size ());
 }
 
 void
@@ -123,10 +123,8 @@ Player::pass ()
                                break;
                        }
 
-
                        dec->set_dcp_times ((*i)->frc, offset);
                        DCPTime const t = dec->dcp_time - offset;
-                       cout << "Peeked " << (*i)->content->paths()[0] << " for " << t << " cf " << ((*i)->content->full_length() - (*i)->content->trim_end ()) << "\n";
                        if (t >= ((*i)->content->full_length() - (*i)->content->trim_end ())) {
                                /* In the end-trimmed part; decoder has nothing else to give us */
                                dec.reset ();
@@ -164,7 +162,7 @@ Player::pass ()
                if (earliest_audio.get() < 0) {
                        earliest_audio = DCPTime ();
                }
-               TimedAudioBuffers<DCPTime> tb = _audio_merger.pull (earliest_audio);
+               TimedAudioBuffers tb = _audio_merger.pull (earliest_audio);
                Audio (tb.audio, tb.time);
                /* This assumes that the audio-frames-to-time conversion is exact
                   so that there are no accumulated errors caused by rounding.
@@ -385,7 +383,7 @@ Player::emit_audio (weak_ptr<Piece> weak_piece, shared_ptr<DecodedAudio> audio)
 void
 Player::flush ()
 {
-       TimedAudioBuffers<DCPTime> tb = _audio_merger.flush ();
+       TimedAudioBuffers tb = _audio_merger.flush ();
        if (_audio && tb.audio) {
                Audio (tb.audio, tb.time);
                _audio_position += DCPTime::from_frames (tb.audio->frames (), _film->audio_frame_rate ());
@@ -488,7 +486,7 @@ Player::setup_pieces ()
                /* FFmpeg */
                shared_ptr<const FFmpegContent> fc = dynamic_pointer_cast<const FFmpegContent> (*i);
                if (fc) {
-                       decoder.reset (new FFmpegDecoder (_film, fc, _video, _audio));
+                       decoder.reset (new FFmpegDecoder (fc, _film->log(), _video, _audio, _film->with_subtitles ()));
                        frc = FrameRateChange (fc->video_frame_rate(), _film->video_frame_rate());
                }
 
@@ -504,7 +502,7 @@ Player::setup_pieces ()
                        }
 
                        if (!decoder) {
-                               decoder.reset (new ImageDecoder (_film, ic));
+                               decoder.reset (new ImageDecoder (ic));
                        }
 
                        frc = FrameRateChange (ic->video_frame_rate(), _film->video_frame_rate());
@@ -513,14 +511,14 @@ Player::setup_pieces ()
                /* SndfileContent */
                shared_ptr<const SndfileContent> sc = dynamic_pointer_cast<const SndfileContent> (*i);
                if (sc) {
-                       decoder.reset (new SndfileDecoder (_film, sc));
+                       decoder.reset (new SndfileDecoder (sc));
                        frc = best_overlap_frc;
                }
 
                /* SubRipContent */
                shared_ptr<const SubRipContent> rc = dynamic_pointer_cast<const SubRipContent> (*i);
                if (rc) {
-                       decoder.reset (new SubRipDecoder (_film, rc));
+                       decoder.reset (new SubRipDecoder (rc));
                        frc = best_overlap_frc;
                }
 
@@ -621,7 +619,7 @@ Player::emit_black ()
 void
 Player::emit_silence (DCPTime most)
 {
-       if (most == 0) {
+       if (most == DCPTime ()) {
                return;
        }
        
@@ -774,7 +772,7 @@ void
 PlayerStatistics::dump (shared_ptr<Log> log) const
 {
        log->log (String::compose ("Video: %1 good %2 skipped %3 black %4 repeat", video.good, video.skip, video.black, video.repeat));
-       log->log (String::compose ("Audio: %1 good %2 skipped %3 silence", audio.good, audio.skip, audio.silence));
+       log->log (String::compose ("Audio: %1 good %2 skipped %3 silence", audio.good, audio.skip, audio.silence.seconds()));
 }
 
 PlayerStatistics const &