diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/butler.cc | 8 | ||||
| -rw-r--r-- | src/lib/butler.h | 2 | ||||
| -rw-r--r-- | src/lib/ffmpeg_encoder.cc | 2 | ||||
| -rw-r--r-- | src/wx/film_viewer.cc | 21 | ||||
| -rw-r--r-- | src/wx/film_viewer.h | 2 |
5 files changed, 24 insertions, 11 deletions
diff --git a/src/lib/butler.cc b/src/lib/butler.cc index 8c46d5190..2d6c46c7e 100644 --- a/src/lib/butler.cc +++ b/src/lib/butler.cc @@ -216,12 +216,16 @@ try _arrived.notify_all (); } +/** @param blocking true if we should block until video is available. If blocking is false + * and no video is immediately available the method will return a 0 PlayerVideo and the error AGAIN. + * @param e if non-0 this is filled with an error code (if an error occurs) or is untouched if no error occurs. + */ pair<shared_ptr<PlayerVideo>, DCPTime> -Butler::get_video (Error* e) +Butler::get_video (bool blocking, Error* e) { boost::mutex::scoped_lock lm (_mutex); - if (_suspended) { + if (_suspended || (_video.empty() && !blocking)) { if (e) { *e = AGAIN; } diff --git a/src/lib/butler.h b/src/lib/butler.h index 09c182f9c..e5581ccb4 100644 --- a/src/lib/butler.h +++ b/src/lib/butler.h @@ -54,7 +54,7 @@ public: AGAIN }; - std::pair<boost::shared_ptr<PlayerVideo>, dcpomatic::DCPTime> get_video (Error* e = 0); + std::pair<boost::shared_ptr<PlayerVideo>, dcpomatic::DCPTime> get_video (bool blocking, Error* e = 0); boost::optional<dcpomatic::DCPTime> get_audio (float* out, Frame frames); boost::optional<TextRingBuffers::Data> get_closed_caption (); diff --git a/src/lib/ffmpeg_encoder.cc b/src/lib/ffmpeg_encoder.cc index 7c641f5ab..572e7ae16 100644 --- a/src/lib/ffmpeg_encoder.cc +++ b/src/lib/ffmpeg_encoder.cc @@ -150,7 +150,7 @@ FFmpegEncoder::go () } for (int j = 0; j < gets_per_frame; ++j) { - pair<shared_ptr<PlayerVideo>, DCPTime> v = _butler->get_video (); + pair<shared_ptr<PlayerVideo>, DCPTime> v = _butler->get_video (true, 0); encoder->get(v.first->eyes())->video(v.first, v.second); } diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index a2b055934..edb451e74 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -231,17 +231,22 @@ FilmViewer::refresh_view () _state_timer.unset (); } +/** @param lazy true if it is *not* important that the display be updated as quickly as possible. + * If lazy is true we will try to return from this method quickly and postpone any time-consuming + * work until the UI is next idle. Otherwise we will block here and try to get the image on + * screen as soon as possible. + */ void -FilmViewer::get () +FilmViewer::get (bool lazy) { DCPOMATIC_ASSERT (_butler); ++_gets; do { Butler::Error e; - _player_video = _butler->get_video (&e); + _player_video = _butler->get_video (!lazy, &e); if (!_player_video.first && e == Butler::AGAIN) { - signal_manager->when_idle (boost::bind(&FilmViewer::get, this)); + signal_manager->when_idle (boost::bind(&FilmViewer::get, this, lazy)); return; } } while ( @@ -257,7 +262,11 @@ FilmViewer::get () error_dialog (_video_view->get(), e.what()); } - display_player_video (); + if (lazy) { + signal_manager->when_idle (boost::bind(&FilmViewer::display_player_video, this)); + } else { + display_player_video (); + } } void @@ -322,7 +331,7 @@ FilmViewer::timer () return; } - get (); + get (false); PositionChanged (); DCPTime const next = _video_position + one_video_frame(); @@ -541,7 +550,7 @@ FilmViewer::seek (DCPTime t, bool accurate) _closed_captions_dialog->clear (); _butler->seek (t, accurate); - get (); + get (true); if (was_running) { start (); diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h index 5ddb12baf..298e9dd00 100644 --- a/src/wx/film_viewer.h +++ b/src/wx/film_viewer.h @@ -151,7 +151,7 @@ private: void timer (); void calculate_sizes (); void player_change (ChangeType type, int, bool); - void get (); + void get (bool lazy); void display_player_video (); void film_change (ChangeType, Film::Property); void recreate_butler (); |
