From 5aff601c454fa756c0ab71ae4bcf8f7f4ce28737 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 20 Nov 2019 23:07:55 +0100 Subject: [PATCH 1/1] Move _dropped into VideoView. --- src/wx/film_viewer.cc | 8 ++++++-- src/wx/film_viewer.h | 5 +---- src/wx/gl_video_view.cc | 3 +++ src/wx/simple_video_view.cc | 3 ++- src/wx/video_view.cc | 17 +++++++++++++++++ src/wx/video_view.h | 24 ++++++++++++++---------- 6 files changed, 43 insertions(+), 17 deletions(-) diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index c1d04be03..cb9c85b3d 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -86,7 +86,6 @@ FilmViewer::FilmViewer (wxWindow* p) , _playing (false) , _suspended (0) , _latency_history_count (0) - , _dropped (0) , _closed_captions_dialog (new ClosedCaptionsDialog(p, this)) , _outline_content (false) , _eyes (EYES_LEFT) @@ -326,7 +325,6 @@ FilmViewer::start () _audio.startStream (); } - _dropped = 0; _playing = true; _video_view->start (); Started (position()); @@ -656,3 +654,9 @@ FilmViewer::emit_finished () emit (boost::bind(boost::ref(Finished))); } +int +FilmViewer::dropped () const +{ + return _video_view->dropped (); +} + diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h index e42c37a8d..93a311981 100644 --- a/src/wx/film_viewer.h +++ b/src/wx/film_viewer.h @@ -92,9 +92,7 @@ public: void slow_refresh (); - int dropped () const { - return _dropped; - } + int dropped () const; int audio_callback (void* out, unsigned int frames); @@ -200,7 +198,6 @@ private: mutable boost::mutex _latency_history_mutex; int _latency_history_count; - int _dropped; boost::optional _dcp_decode_reduction; ClosedCaptionsDialog* _closed_captions_dialog; diff --git a/src/wx/gl_video_view.cc b/src/wx/gl_video_view.cc index 934a91ad5..55c6cc969 100644 --- a/src/wx/gl_video_view.cc +++ b/src/wx/gl_video_view.cc @@ -275,6 +275,8 @@ GLVideoView::set_image (shared_ptr image) void GLVideoView::start () { + VideoView::start (); + boost::mutex::scoped_lock lm (_playing_mutex); _playing = true; _playing_condition.notify_all (); @@ -319,6 +321,7 @@ try while (time_until_next_frame() < 5) { get_next_frame (true); + add_dropped (); } boost::this_thread::interruption_point (); diff --git a/src/wx/simple_video_view.cc b/src/wx/simple_video_view.cc index f928770ad..33e2834c5 100644 --- a/src/wx/simple_video_view.cc +++ b/src/wx/simple_video_view.cc @@ -169,6 +169,7 @@ SimpleVideoView::timer () void SimpleVideoView::start () { + VideoView::start (); timer (); } @@ -216,7 +217,7 @@ SimpleVideoView::display_player_video () /* Too late; just drop this frame before we try to get its image (which will be the time-consuming part if this frame is J2K). */ - ++_viewer->_dropped; + add_dropped (); return; } diff --git a/src/wx/video_view.cc b/src/wx/video_view.cc index ede0708c2..d54487a93 100644 --- a/src/wx/video_view.cc +++ b/src/wx/video_view.cc @@ -23,6 +23,17 @@ #include "film_viewer.h" #include "lib/butler.h" +VideoView::VideoView (FilmViewer* viewer) + : _viewer (viewer) +#ifdef DCPOMATIC_VARIANT_SWAROOP + , _in_watermark (false) +#endif + , _video_frame_rate (0) + , _dropped (0) +{ + +} + void VideoView::clear () { @@ -85,3 +96,9 @@ VideoView::time_until_next_frame () const return (next.seconds() - time.seconds()) * 1000; } +void +VideoView::start () +{ + boost::mutex::scoped_lock lm (_mutex); + _dropped = 0; +} diff --git a/src/wx/video_view.h b/src/wx/video_view.h index 656d8621e..8d9dce68d 100644 --- a/src/wx/video_view.h +++ b/src/wx/video_view.h @@ -34,14 +34,7 @@ class PlayerVideo; class VideoView { public: - VideoView (FilmViewer* viewer) - : _viewer (viewer) -#ifdef DCPOMATIC_VARIANT_SWAROOP - , _in_watermark (false) -#endif - , _video_frame_rate (0) - {} - + VideoView (FilmViewer* viewer); virtual ~VideoView () {} virtual void set_image (boost::shared_ptr image) = 0; @@ -51,8 +44,7 @@ public: */ virtual void update () = 0; - /* XXX_b: make pure */ - virtual void start () {} + virtual void start (); /* XXX_b: make pure */ virtual void stop () {} @@ -65,6 +57,11 @@ public: /* XXX_b: to remove */ virtual void display_player_video () {} + int dropped () const { + boost::mutex::scoped_lock lm (_mutex); + return _dropped; + } + dcpomatic::DCPTime position () const { boost::mutex::scoped_lock lm (_mutex); return _player_video.second; @@ -103,6 +100,11 @@ protected: return _player_video; } + void add_dropped () { + boost::mutex::scoped_lock lm (_mutex); + ++_dropped; + } + FilmViewer* _viewer; #ifdef DCPOMATIC_VARIANT_SWAROOP @@ -119,6 +121,8 @@ private: int _video_frame_rate; /** length of the film we are playing, or 0 if there is none */ dcpomatic::DCPTime _length; + + int _dropped; }; #endif -- 2.30.2