From: Carl Hetherington Date: Fri, 27 Jul 2018 15:14:41 +0000 (+0100) Subject: Merge branch 'master' of ssh://git.carlh.net/home/carl/git/dcpomatic X-Git-Tag: v2.13.41~13 X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;h=ae4f0d9f55489ddc50b3e5f0d713621ee8f50645;hp=3006dde72c92356165ef841910368d0dae27ddbe;p=dcpomatic.git Merge branch 'master' of ssh://git.carlh.net/home/carl/git/dcpomatic --- diff --git a/src/lib/butler.cc b/src/lib/butler.cc index 112778e25..138ee0fbd 100644 --- a/src/lib/butler.cc +++ b/src/lib/butler.cc @@ -198,6 +198,7 @@ Butler::get_video () } pair, DCPTime> const r = _video.get (); + cout << "BGV " << to_string(r.second) << " " << _video.size() << "\n"; _summon.notify_all (); return r; } @@ -233,6 +234,7 @@ Butler::prepare (weak_ptr weak_video) const void Butler::video (shared_ptr video, DCPTime time) { + cout << "BV: " << to_string(time) << " " << _video.size() << " " << (float(_video.size()) / 24) << "\n"; boost::mutex::scoped_lock lm (_mutex); if (_pending_seek_position) { /* Don't store any video while a seek is pending */ @@ -246,6 +248,7 @@ Butler::video (shared_ptr video, DCPTime time) void Butler::audio (shared_ptr audio) { + cout << "BA: " << audio->frames() << " " << _audio.size() << " " << (float(_audio.size()) / 48000) << "\n"; { boost::mutex::scoped_lock lm (_mutex); if (_pending_seek_position || _disable_audio) { @@ -265,6 +268,7 @@ bool Butler::get_audio (float* out, Frame frames) { bool const underrun = _audio.get (out, _audio_channels, frames); + cout << "BGA: " << frames << " " << _audio.size() << " " << (float(_audio.size()) / 48000) << "\n"; _summon.notify_all (); return underrun; } diff --git a/src/lib/player.cc b/src/lib/player.cc index 790d9a718..bb0aef458 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -268,14 +268,18 @@ Player::playlist_content_changed (weak_ptr w, int property, bool freque void Player::set_video_container_size (dcp::Size s) { - if (s == _video_container_size) { - return; - } + { + boost::mutex::scoped_lock lm (_mutex); + + if (s == _video_container_size) { + return; + } - _video_container_size = s; + _video_container_size = s; - _black_image.reset (new Image (AV_PIX_FMT_RGB24, _video_container_size, true)); - _black_image->make_black (); + _black_image.reset (new Image (AV_PIX_FMT_RGB24, _video_container_size, true)); + _black_image->make_black (); + } Changed (PlayerProperty::VIDEO_CONTAINER_SIZE, false); } @@ -424,6 +428,8 @@ Player::content_time_to_dcp (shared_ptr piece, ContentTime t) const list > Player::get_subtitle_fonts () { + /* Does not require a lock on _mutex as it's only called from DCPEncoder */ + if (!_have_valid_pieces) { setup_pieces (); } @@ -446,6 +452,7 @@ Player::get_subtitle_fonts () void Player::set_ignore_video () { + boost::mutex::scoped_lock lm (_mutex); _ignore_video = true; _have_valid_pieces = false; } @@ -460,6 +467,7 @@ Player::set_ignore_audio () void Player::set_ignore_text () { + boost::mutex::scoped_lock lm (_mutex); _ignore_text = true; } @@ -467,6 +475,7 @@ Player::set_ignore_text () void Player::set_always_burn_open_subtitles () { + boost::mutex::scoped_lock lm (_mutex); _always_burn_open_subtitles = true; } @@ -474,6 +483,7 @@ Player::set_always_burn_open_subtitles () void Player::set_fast () { + boost::mutex::scoped_lock lm (_mutex); _fast = true; _have_valid_pieces = false; } @@ -481,6 +491,7 @@ Player::set_fast () void Player::set_play_referenced () { + boost::mutex::scoped_lock lm (_mutex); _play_referenced = true; _have_valid_pieces = false; } @@ -488,6 +499,8 @@ Player::set_play_referenced () list Player::get_reel_assets () { + /* Does not require a lock on _mutex as it's only called from DCPEncoder */ + list a; BOOST_FOREACH (shared_ptr i, _playlist->content ()) { @@ -564,6 +577,8 @@ Player::get_reel_assets () bool Player::pass () { + boost::mutex::scoped_lock lm (_mutex); + if (!_have_valid_pieces) { setup_pieces (); } @@ -698,6 +713,7 @@ Player::pass () list Player::closed_captions_for_frame (DCPTime time) const { + boost::mutex::scoped_lock _lm (_mutex); return _active_texts[TEXT_CLOSED_CAPTION].get ( DCPTimePeriod(time, time + DCPTime::from_frames(1, _film->video_frame_rate())) ); @@ -990,6 +1006,8 @@ Player::subtitle_stop (weak_ptr wp, weak_ptr wc, Conte void Player::seek (DCPTime time, bool accurate) { + boost::mutex::scoped_lock lm (_mutex); + if (!_have_valid_pieces) { setup_pieces (); } @@ -1138,18 +1156,25 @@ Player::discard_audio (shared_ptr audio, DCPTime time, DCPTi void Player::set_dcp_decode_reduction (optional reduction) { - if (reduction == _dcp_decode_reduction) { - return; + { + boost::mutex::scoped_lock lm (_mutex); + + if (reduction == _dcp_decode_reduction) { + return; + } + + _dcp_decode_reduction = reduction; + _have_valid_pieces = false; } - _dcp_decode_reduction = reduction; - _have_valid_pieces = false; Changed (PlayerProperty::DCP_DECODE_REDUCTION, false); } DCPTime Player::content_time_to_dcp (shared_ptr content, ContentTime t) { + boost::mutex::scoped_lock lm (_mutex); + if (_have_valid_pieces) { setup_pieces (); } diff --git a/src/lib/player.h b/src/lib/player.h index 3d774e1d9..a4fd80c16 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -73,6 +73,7 @@ public: std::list > get_subtitle_fonts (); std::list get_reel_assets (); dcp::Size video_container_size () const { + boost::mutex::scoped_lock lm (_mutex); return _video_container_size; } @@ -142,6 +143,12 @@ private: void do_emit_video (boost::shared_ptr pv, DCPTime time); void emit_audio (boost::shared_ptr data, DCPTime time); + /** Mutex to protect the whole Player state. When it's used for the preview we have + seek() and pass() called from the Butler thread and lots of other stuff called + from the GUI thread. + */ + mutable boost::mutex _mutex; + boost::shared_ptr _film; boost::shared_ptr _playlist; diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index ef28018e9..8c1a79113 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -529,6 +529,8 @@ FilmViewer::start () _audio.startStream (); } + cout << "start playback at " << to_string(_video_position) << "\n"; + _playing = true; _dropped = 0; timer ();