Nicer fix for 86102d30bf0aad89115bbeb3d8aaa2a27a0aa432
authorCarl Hetherington <cth@carlh.net>
Thu, 23 Apr 2020 13:48:19 +0000 (15:48 +0200)
committerCarl Hetherington <cth@carlh.net>
Thu, 23 Apr 2020 13:48:19 +0000 (15:48 +0200)
17 files changed:
src/lib/analyse_audio_job.cc
src/lib/encoder.cc
src/lib/hints.cc
src/lib/player.cc
src/lib/player.h
src/tools/server_test.cc
src/wx/film_viewer.cc
test/butler_test.cc
test/dcp_decoder_test.cc
test/dcp_playback_test.cc
test/ffmpeg_audio_only_test.cc
test/ffmpeg_audio_test.cc
test/ffmpeg_decoder_sequential_test.cc
test/player_test.cc
test/time_calculation_test.cc
test/upmixer_a_test.cc
test/vf_test.cc

index ead36bca1e031ccc1c1eb3e25db8b826d40d270f..e77f83bdedfd8c8b82dd21f8c28d287f2b8b8ab8 100644 (file)
@@ -140,7 +140,7 @@ AnalyseAudioJob::json_name () const
 void
 AnalyseAudioJob::run ()
 {
-       shared_ptr<Player> player (new Player(_film, _playlist, _playlist->length(_film)));
+       shared_ptr<Player> player (new Player(_film, _playlist));
        player->set_ignore_video ();
        player->set_ignore_text ();
        player->set_fast ();
index b52507ed1ede219ccd9d6a50e1624c608011c687..0a29989b175045fcc6eaeab46266ee55fb358ad7 100644 (file)
@@ -41,7 +41,7 @@ using boost::shared_ptr;
 Encoder::Encoder (shared_ptr<const Film> film, weak_ptr<Job> job)
        : _film (film)
        , _job (job)
-       , _player (new Player(film, film->playlist(), film->length()))
+       , _player (new Player(film))
 {
 
 }
index 68cf82b8409faf4227f8078012003269f44a77f2..581d63972a1cac97b0c257243b0482a1fded12f5 100644 (file)
@@ -259,7 +259,7 @@ Hints::thread ()
 
        emit (bind(boost::ref(Progress), _("Examining closed captions")));
 
-       shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
+       shared_ptr<Player> player (new Player(film));
        player->set_ignore_video ();
        player->set_ignore_audio ();
        player->Text.connect (bind(&Hints::text, this, _1, _2, _4));
index 00650d88dc9412648d2c298ac11594e0601122c4..e41cecf13f353b417ceeca4b63649e084cea39bc 100644 (file)
@@ -85,7 +85,23 @@ int const PlayerProperty::FILM_VIDEO_FRAME_RATE = 703;
 int const PlayerProperty::DCP_DECODE_REDUCTION = 704;
 int const PlayerProperty::PLAYBACK_LENGTH = 705;
 
-Player::Player (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist_, DCPTime playback_length)
+Player::Player (shared_ptr<const Film> film)
+       : _film (film)
+       , _suspended (0)
+       , _ignore_video (false)
+       , _ignore_audio (false)
+       , _ignore_text (false)
+       , _always_burn_open_subtitles (false)
+       , _fast (false)
+       , _tolerant (film->tolerant())
+       , _play_referenced (false)
+       , _audio_merger (_film->audio_frame_rate())
+       , _shuffler (0)
+{
+       construct ();
+}
+
+Player::Player (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist_)
        : _film (film)
        , _playlist (playlist_)
        , _suspended (0)
@@ -98,7 +114,12 @@ Player::Player (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist
        , _play_referenced (false)
        , _audio_merger (_film->audio_frame_rate())
        , _shuffler (0)
-       , _playback_length (playback_length)
+{
+       construct ();
+}
+
+void
+Player::construct ()
 {
        _film_changed_connection = _film->Change.connect (bind (&Player::film_change, this, _1, _2));
        /* The butler must hear about this first, so since we are proxying this through to the butler we must
@@ -127,15 +148,6 @@ Player::setup_pieces ()
 }
 
 
-void
-Player::set_playback_length (DCPTime len)
-{
-       Change (CHANGE_TYPE_PENDING, PlayerProperty::PLAYBACK_LENGTH, false);
-       _playback_length = len;
-       Change (CHANGE_TYPE_DONE, PlayerProperty::PLAYBACK_LENGTH, false);
-       setup_pieces ();
-}
-
 bool
 have_video (shared_ptr<const Content> content)
 {
@@ -151,6 +163,8 @@ have_audio (shared_ptr<const Content> content)
 void
 Player::setup_pieces_unlocked ()
 {
+       _playback_length = _playlist ? _playlist->length(_film) : _film->length();
+
        list<shared_ptr<Piece> > old_pieces = _pieces;
        _pieces.clear ();
 
@@ -1247,6 +1261,6 @@ Player::content_time_to_dcp (shared_ptr<Content> content, ContentTime t)
 shared_ptr<const Playlist>
 Player::playlist () const
 {
-       return _playlist;
+       return _playlist ? _playlist : _film->playlist();
 }
 
index 407f7651a8848f11f48bfc1620477a1759c37e26..51de78982da44ba352caf796f16277a38c095aa8 100644 (file)
@@ -69,7 +69,8 @@ public:
 class Player : public boost::enable_shared_from_this<Player>, public boost::noncopyable
 {
 public:
-       Player (boost::shared_ptr<const Film>, boost::shared_ptr<const Playlist> playlist, dcpomatic::DCPTime playback_length);
+       Player (boost::shared_ptr<const Film>);
+       Player (boost::shared_ptr<const Film>, boost::shared_ptr<const Playlist> playlist);
        ~Player ();
 
        bool pass ();
@@ -82,7 +83,6 @@ public:
                return _video_container_size;
        }
 
-       void set_playback_length (dcpomatic::DCPTime len);
        void set_video_container_size (dcp::Size);
        void set_ignore_video ();
        void set_ignore_audio ();
@@ -115,6 +115,7 @@ private:
        friend struct empty_test2;
        friend struct check_reuse_old_data_test;
 
+       void construct ();
        void setup_pieces ();
        void setup_pieces_unlocked ();
        void flush ();
@@ -151,6 +152,7 @@ private:
        mutable boost::mutex _mutex;
 
        boost::shared_ptr<const Film> _film;
+       /** Playlist, or 0 if we are using the one from the _film */
        boost::shared_ptr<const Playlist> _playlist;
 
        /** > 0 if we are suspended (i.e. pass() and seek() do nothing) */
index 4c410eadeccf4c2081411c6a8c8e96bebb33540b..03a99b2e521be6329e3b73b8018ad60064ed69d4 100644 (file)
@@ -145,7 +145,7 @@ main (int argc, char* argv[])
                film.reset (new Film (film_dir));
                film->read_metadata ();
 
-               shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
+               shared_ptr<Player> player (new Player(film));
                player->Video.connect (bind (&process_video, _1));
                while (!player->pass ()) {}
        } catch (std::exception& e) {
index bb59122aaff0605f5c46b89625ffe607950b2f2c..4b9528bc04fe64113f3f4e478446139c8745ef9c 100644 (file)
@@ -164,7 +164,7 @@ FilmViewer::set_film (shared_ptr<Film> film)
        }
 
        try {
-               _player.reset (new Player(_film, _film->playlist(), _film->length()));
+               _player.reset (new Player(_film));
                _player->set_fast ();
                if (_dcp_decode_reduction) {
                        _player->set_dcp_decode_reduction (_dcp_decode_reduction);
@@ -406,7 +406,6 @@ void
 FilmViewer::film_length_change ()
 {
        _video_view->set_length (_film->length());
-       _player->set_playback_length (_film->length());
 }
 
 /** Re-get the current frame slowly by seeking */
index 13efc31313d1af876141abb597232a991c443b75..7575728fd3fce3bc6364df24145ff3013960cce2 100644 (file)
@@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE (butler_test1)
                map.set (i, i, 1);
        }
 
-       Butler butler (shared_ptr<Player>(new Player(film, film->playlist(), film->length())), map, 6, bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), false, false);
+       Butler butler (shared_ptr<Player>(new Player(film)), map, 6, bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), false, false);
 
        BOOST_CHECK (butler.get_video(true, 0).second == DCPTime());
        BOOST_CHECK (butler.get_video(true, 0).second == DCPTime::from_frames(1, 24));
index 36df09834ad4f4c932ba65c8fa11736743e5c793..231a99da2268c67a350bc4f1da04e773d5ff454e 100644 (file)
@@ -89,7 +89,7 @@ BOOST_AUTO_TEST_CASE (check_reuse_old_data_test)
        ov_content.reset (new DCPContent(ov->dir(ov->dcp_name(false))));
        test->examine_and_add_content (ov_content);
        BOOST_REQUIRE (!wait_for_jobs());
-       shared_ptr<Player> player (new Player(test, test->playlist(), test->length()));
+       shared_ptr<Player> player (new Player(test));
 
        shared_ptr<DCPDecoder> decoder = boost::dynamic_pointer_cast<DCPDecoder>(player->_pieces.front()->decoder);
        BOOST_REQUIRE (decoder);
@@ -107,7 +107,7 @@ BOOST_AUTO_TEST_CASE (check_reuse_old_data_test)
        shared_ptr<DCPContent> vf_content (new DCPContent(vf->dir(vf->dcp_name(false))));
        test->examine_and_add_content (vf_content);
        BOOST_REQUIRE (!wait_for_jobs());
-       player.reset (new Player(test, test->playlist(), test->length()));
+       player.reset (new Player(test));
 
        decoder = boost::dynamic_pointer_cast<DCPDecoder>(player->_pieces.front()->decoder);
        BOOST_REQUIRE (decoder);
@@ -125,7 +125,7 @@ BOOST_AUTO_TEST_CASE (check_reuse_old_data_test)
        shared_ptr<DCPContent> encrypted_content (new DCPContent(encrypted->dir(encrypted->dcp_name(false))));
        test->examine_and_add_content (encrypted_content);
        BOOST_REQUIRE (!wait_for_jobs());
-       player.reset (new Player(test, test->playlist(), test->length()));
+       player.reset (new Player(test));
 
        decoder = boost::dynamic_pointer_cast<DCPDecoder>(player->_pieces.front()->decoder);
        BOOST_REQUIRE (decoder);
index e8d91648702907b7dec20e5c7c95d1c491e0d5f9..0f639587bd45232f0e94dcca322ec8ec08b39f36 100644 (file)
@@ -40,7 +40,7 @@ BOOST_AUTO_TEST_CASE (dcp_playback_test)
 
        shared_ptr<Butler> butler (
                new Butler(
-                       shared_ptr<Player>(new Player(film, film->playlist(), film->length())),
+                       shared_ptr<Player>(new Player(film)),
                        AudioMapping(6, 6),
                        6,
                        bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24),
index df32cadd49e89da85cf4af378d7e1f5b9cd3141b..6fc9f9f2cda58f03a5beef38abaed9edc115589b 100644 (file)
@@ -92,7 +92,7 @@ test (boost::filesystem::path file)
        ref_buffer_size = info.samplerate * info.channels;
        ref_buffer = new float[ref_buffer_size];
 
-       shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
+       shared_ptr<Player> player (new Player(film));
 
        player->Audio.connect (bind (&audio, _1, info.channels));
        while (!player->pass ()) {}
index 7a9aaf3463d131c6e064a9f0bb1bdcf68c60cbd5..6ad6c1fdb8d2ae38aaf27188f752c0a143c139d7 100644 (file)
@@ -134,7 +134,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_audio_test2)
        film->examine_and_add_content (content);
        BOOST_REQUIRE (!wait_for_jobs ());
 
-       shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
+       shared_ptr<Player> player (new Player(film));
        while (!player->pass ()) {}
 }
 
@@ -146,7 +146,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_audio_test3)
        film->examine_and_add_content (content);
        BOOST_REQUIRE (!wait_for_jobs ());
 
-       shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
+       shared_ptr<Player> player (new Player(film));
        player->set_fast ();
        while (!player->pass ()) {}
 }
index 041d976fe38cb74b35af8b465b48d8f0602a5b39..d761d946556291db329d92d297cee36edc80b206 100644 (file)
@@ -65,7 +65,7 @@ ffmpeg_decoder_sequential_test_one (boost::filesystem::path file, float fps, int
        film->examine_and_add_content (content);
        BOOST_REQUIRE (!wait_for_jobs());
        film->write_metadata ();
-       shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
+       shared_ptr<Player> player (new Player(film));
 
        BOOST_REQUIRE (content->video_frame_rate());
        BOOST_CHECK_CLOSE (content->video_frame_rate().get(), fps, 0.01);
index 378e0af9b3f8ff44f789465c3e3952e5399f6d43..6877d7e21f5ef37a37c850691845b1ae8e1dc2dc 100644 (file)
@@ -74,7 +74,7 @@ BOOST_AUTO_TEST_CASE (player_silence_padding_test)
 
        accumulated.reset (new AudioBuffers (film->audio_channels(), 0));
 
-       shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
+       shared_ptr<Player> player (new Player(film));
        player->Audio.connect (bind (&accumulate, _1, _2));
        while (!player->pass ()) {}
        BOOST_REQUIRE (accumulated->frames() >= 48000);
@@ -149,7 +149,7 @@ BOOST_AUTO_TEST_CASE (player_subframe_test)
        /* Length should be rounded up from B's length to the next video frame */
        BOOST_CHECK (film->length() == DCPTime::from_frames(3 * 24 + 1, 24));
 
-       shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
+       shared_ptr<Player> player (new Player(film));
        player->setup_pieces ();
        BOOST_REQUIRE_EQUAL (player->_black._periods.size(), 1);
        BOOST_CHECK (player->_black._periods.front() == DCPTimePeriod(DCPTime::from_frames(3 * 24, 24), DCPTime::from_frames(3 * 24 + 1, 24)));
@@ -188,7 +188,7 @@ BOOST_AUTO_TEST_CASE (player_interleave_test)
        film->examine_and_add_content (s);
        BOOST_REQUIRE (!wait_for_jobs ());
 
-       shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
+       shared_ptr<Player> player (new Player(film));
        player->Video.connect (bind (&video, _1, _2));
        player->Audio.connect (bind (&audio, _1, _2));
        video_frames = audio_frames = 0;
@@ -210,7 +210,7 @@ BOOST_AUTO_TEST_CASE (player_seek_test)
        BOOST_REQUIRE (!wait_for_jobs ());
        dcp->only_text()->set_use (true);
 
-       shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
+       shared_ptr<Player> player (new Player(film));
        player->set_fast ();
        player->set_always_burn_open_subtitles ();
        player->set_play_referenced ();
@@ -241,7 +241,7 @@ BOOST_AUTO_TEST_CASE (player_seek_test2)
        BOOST_REQUIRE (!wait_for_jobs ());
        dcp->only_text()->set_use (true);
 
-       shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
+       shared_ptr<Player> player (new Player(film));
        player->set_fast ();
        player->set_always_burn_open_subtitles ();
        player->set_play_referenced ();
@@ -310,7 +310,7 @@ BOOST_AUTO_TEST_CASE (player_ignore_video_and_audio_test)
        text->only_text()->set_type (TEXT_CLOSED_CAPTION);
        text->only_text()->set_use (true);
 
-       shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
+       shared_ptr<Player> player (new Player(film));
        player->set_ignore_video ();
        player->set_ignore_audio ();
 
@@ -329,7 +329,7 @@ BOOST_AUTO_TEST_CASE (player_trim_crash)
        film->examine_and_add_content (boon);
        BOOST_REQUIRE (!wait_for_jobs());
 
-       shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
+       shared_ptr<Player> player (new Player(film));
        player->set_fast ();
        shared_ptr<Butler> butler (new Butler(player, AudioMapping(), 6, bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), false, true));
 
index f6412d9de5e2c014464edb4541569609837fd698..dbcf2677becd4195296f135af82a7dc0ee728a0d 100644 (file)
@@ -190,7 +190,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test1)
        film->set_sequence (false);
        film->add_content (content);
 
-       shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
+       shared_ptr<Player> player (new Player(film));
 
        /* Position 0, no trim, content rate = DCP rate */
        content->set_position (film, DCPTime());
@@ -396,7 +396,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test2)
        film->set_sequence (false);
        film->add_content (content);
 
-       shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
+       shared_ptr<Player> player (new Player(film));
 
        /* Position 0, no trim, content rate = DCP rate */
        content->set_position (film, DCPTime());
@@ -573,7 +573,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3)
        film->set_sequence (false);
        film->add_content (content);
 
-       shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
+       shared_ptr<Player> player (new Player(film));
 
        /* Position 0, no trim, video/audio content rate = video/audio DCP rate */
        content->set_position (film, DCPTime());
index a00a77addcde806b56eb985a7d7e3a165fbffc23..ba07eafd157d11cda985371dc862c431713acbfa 100644 (file)
@@ -79,7 +79,7 @@ BOOST_AUTO_TEST_CASE (upmixer_a_test)
        Ls = sf_open ("build/test/upmixer_a_test/Ls.wav", SFM_WRITE, &info);
        Rs = sf_open ("build/test/upmixer_a_test/Rs.wav", SFM_WRITE, &info);
 
-       shared_ptr<Player> player (new Player(film, film->playlist(), film->length()));
+       shared_ptr<Player> player (new Player(film));
        player->Audio.connect (bind (&write, _1, _2));
        while (!player->pass()) {}
 
index 35c32e603f4e1eba37fd3487dce9306087ee76a6..6fd0a00e8de3c8596355d38d3943ff14f50a71f0 100644 (file)
@@ -287,7 +287,7 @@ BOOST_AUTO_TEST_CASE (vf_test5)
        BOOST_REQUIRE (!wait_for_jobs());
 
        /* Check that the selected reel assets are right */
-       shared_ptr<Player> player (new Player(vf, vf->playlist(), vf->length()));
+       shared_ptr<Player> player (new Player(vf));
        list<ReferencedReelAsset> a = player->get_reel_assets();
        BOOST_REQUIRE_EQUAL (a.size(), 4);
        list<ReferencedReelAsset>::const_iterator i = a.begin();