diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-02-20 23:34:59 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-02-20 23:37:24 +0000 |
| commit | a0eff2446835a2a29d751a4810fe182c486a2eb6 (patch) | |
| tree | 3a6b9e6c6724d2356c97c2cf14810ef79c85af53 /src/lib/player.cc | |
| parent | d920b12b4d05fa1b0e95e1178ee21c671e0ae431 (diff) | |
Add a 2-frame `delay' on content arriving at the player to give
subtitle content the chance to catch up. Fixes problems observed
when overlaying a DCP subtitle onto an existing DCP and then seeking
into the first subtitle. After the seek the decoder positions were:
DCP: 0.
subtitle: first subtitle time.
This causes the DCP decoder to be pass()ed first and so the subtitle
for the video frame has not arrived yet.
I hope this does not cause unpredicted side effects...
Diffstat (limited to 'src/lib/player.cc')
| -rw-r--r-- | src/lib/player.cc | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/lib/player.cc b/src/lib/player.cc index 71b04e7b2..a8a72a229 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -49,6 +49,7 @@ #include "image_decoder.h" #include "compose.hpp" #include "shuffler.h" +#include "delay.h" #include <dcp/reel.h> #include <dcp/reel_sound_asset.h> #include <dcp/reel_subtitle_asset.h> @@ -89,6 +90,7 @@ Player::Player (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist , _play_referenced (false) , _audio_merger (_film->audio_frame_rate()) , _shuffler (0) + , _delay (0) { _film_changed_connection = _film->Changed.connect (bind (&Player::film_changed, this, _1)); _playlist_changed_connection = _playlist->Changed.connect (bind (&Player::playlist_changed, this)); @@ -103,6 +105,7 @@ Player::Player (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist Player::~Player () { delete _shuffler; + delete _delay; } void @@ -114,6 +117,10 @@ Player::setup_pieces () _shuffler = new Shuffler(); _shuffler->Video.connect(bind(&Player::video, this, _1, _2)); + delete _delay; + _delay = new Delay(); + _delay->Video.connect(bind(&Player::video, this, _1, _2)); + BOOST_FOREACH (shared_ptr<Content> i, _playlist->content ()) { if (!i->paths_valid ()) { @@ -149,9 +156,13 @@ Player::setup_pieces () if (decoder->video) { if (i->video->frame_type() == VIDEO_FRAME_TYPE_3D_LEFT || i->video->frame_type() == VIDEO_FRAME_TYPE_3D_RIGHT) { + /* We need a Shuffler to cope with 3D L/R video data arriving out of sequence */ decoder->video->Data.connect (bind (&Shuffler::video, _shuffler, weak_ptr<Piece>(piece), _1)); } else { - decoder->video->Data.connect (bind (&Player::video, this, weak_ptr<Piece>(piece), _1)); + /* We need a Delay to give a little wiggle room to ensure that relevent subtitles arrive at the + player before the video that requires them. + */ + decoder->video->Data.connect (bind (&Delay::video, _delay, weak_ptr<Piece>(piece), _1)); } } @@ -649,6 +660,7 @@ Player::pass () if (done) { _shuffler->flush (); + _delay->flush (); } return done; } @@ -931,6 +943,10 @@ Player::seek (DCPTime time, bool accurate) _shuffler->clear (); } + if (_delay) { + _delay->clear (); + } + if (_audio_processor) { _audio_processor->flush (); } |
