Move _dropped into VideoView.
authorCarl Hetherington <cth@carlh.net>
Wed, 20 Nov 2019 22:07:55 +0000 (23:07 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 8 Jan 2020 20:56:47 +0000 (21:56 +0100)
src/wx/film_viewer.cc
src/wx/film_viewer.h
src/wx/gl_video_view.cc
src/wx/simple_video_view.cc
src/wx/video_view.cc
src/wx/video_view.h

index c1d04be..cb9c85b 100644 (file)
@@ -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 ();
+}
+
index e42c37a..93a3119 100644 (file)
@@ -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<int> _dcp_decode_reduction;
 
        ClosedCaptionsDialog* _closed_captions_dialog;
index 934a91a..55c6cc9 100644 (file)
@@ -275,6 +275,8 @@ GLVideoView::set_image (shared_ptr<const Image> 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 ();
index f928770..33e2834 100644 (file)
@@ -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;
        }
 
index ede0708..d54487a 100644 (file)
 #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;
+}
index 656d862..8d9dce6 100644 (file)
@@ -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<const Image> 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