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 c1d04be03f05e5d9f4a88d6de7f85a13409e773f..cb9c85b3d2acf38b6738394c320403e54ba446d3 100644 (file)
@@ -86,7 +86,6 @@ FilmViewer::FilmViewer (wxWindow* p)
        , _playing (false)
        , _suspended (0)
        , _latency_history_count (0)
        , _playing (false)
        , _suspended (0)
        , _latency_history_count (0)
-       , _dropped (0)
        , _closed_captions_dialog (new ClosedCaptionsDialog(p, this))
        , _outline_content (false)
        , _eyes (EYES_LEFT)
        , _closed_captions_dialog (new ClosedCaptionsDialog(p, this))
        , _outline_content (false)
        , _eyes (EYES_LEFT)
@@ -326,7 +325,6 @@ FilmViewer::start ()
                _audio.startStream ();
        }
 
                _audio.startStream ();
        }
 
-       _dropped = 0;
        _playing = true;
        _video_view->start ();
        Started (position());
        _playing = true;
        _video_view->start ();
        Started (position());
@@ -656,3 +654,9 @@ FilmViewer::emit_finished ()
        emit (boost::bind(boost::ref(Finished)));
 }
 
        emit (boost::bind(boost::ref(Finished)));
 }
 
+int
+FilmViewer::dropped () const
+{
+       return _video_view->dropped ();
+}
+
index e42c37a8d4ffab33c7f06aacf165bea4aa44351d..93a31198135f0854e87f80056095f411b844d852 100644 (file)
@@ -92,9 +92,7 @@ public:
 
        void slow_refresh ();
 
 
        void slow_refresh ();
 
-       int dropped () const {
-               return _dropped;
-       }
+       int dropped () const;
 
        int audio_callback (void* out, unsigned int frames);
 
 
        int audio_callback (void* out, unsigned int frames);
 
@@ -200,7 +198,6 @@ private:
        mutable boost::mutex _latency_history_mutex;
        int _latency_history_count;
 
        mutable boost::mutex _latency_history_mutex;
        int _latency_history_count;
 
-       int _dropped;
        boost::optional<int> _dcp_decode_reduction;
 
        ClosedCaptionsDialog* _closed_captions_dialog;
        boost::optional<int> _dcp_decode_reduction;
 
        ClosedCaptionsDialog* _closed_captions_dialog;
index 934a91ad5784d47f30ac8d615031fee5ac8edde2..55c6cc9699f45f08f3a069efff293b7020c68d69 100644 (file)
@@ -275,6 +275,8 @@ GLVideoView::set_image (shared_ptr<const Image> image)
 void
 GLVideoView::start ()
 {
 void
 GLVideoView::start ()
 {
+       VideoView::start ();
+
        boost::mutex::scoped_lock lm (_playing_mutex);
        _playing = true;
        _playing_condition.notify_all ();
        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);
 
                while (time_until_next_frame() < 5) {
                        get_next_frame (true);
+                       add_dropped ();
                }
 
                boost::this_thread::interruption_point ();
                }
 
                boost::this_thread::interruption_point ();
index f928770ad38bb56e534e3c23041de8ace20d4075..33e2834c5bba8820855d3eeba336455c87dbae4c 100644 (file)
@@ -169,6 +169,7 @@ SimpleVideoView::timer ()
 void
 SimpleVideoView::start ()
 {
 void
 SimpleVideoView::start ()
 {
+       VideoView::start ();
        timer ();
 }
 
        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).
                */
                /* 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;
        }
 
                return;
        }
 
index ede0708c220a6eecb434df4bfd9a3a36978863f4..d54487a937f9c70f7f01e1038359d3db24c4b85e 100644 (file)
 #include "film_viewer.h"
 #include "lib/butler.h"
 
 #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 ()
 {
 void
 VideoView::clear ()
 {
@@ -85,3 +96,9 @@ VideoView::time_until_next_frame () const
        return (next.seconds() - time.seconds()) * 1000;
 }
 
        return (next.seconds() - time.seconds()) * 1000;
 }
 
+void
+VideoView::start ()
+{
+       boost::mutex::scoped_lock lm (_mutex);
+       _dropped = 0;
+}
index 656d8621e779cdda57723918381656aa69231cd5..8d9dce68d07e71a32a799ffb1778fede718d704c 100644 (file)
@@ -34,14 +34,7 @@ class PlayerVideo;
 class VideoView
 {
 public:
 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;
        virtual ~VideoView () {}
 
        virtual void set_image (boost::shared_ptr<const Image> image) = 0;
@@ -51,8 +44,7 @@ public:
         */
        virtual void update () = 0;
 
         */
        virtual void update () = 0;
 
-       /* XXX_b: make pure */
-       virtual void start () {}
+       virtual void start ();
        /* XXX_b: make pure */
        virtual void stop () {}
 
        /* XXX_b: make pure */
        virtual void stop () {}
 
@@ -65,6 +57,11 @@ public:
        /* XXX_b: to remove */
        virtual void display_player_video () {}
 
        /* 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;
        dcpomatic::DCPTime position () const {
                boost::mutex::scoped_lock lm (_mutex);
                return _player_video.second;
@@ -103,6 +100,11 @@ protected:
                return _player_video;
        }
 
                return _player_video;
        }
 
+       void add_dropped () {
+               boost::mutex::scoped_lock lm (_mutex);
+               ++_dropped;
+       }
+
        FilmViewer* _viewer;
 
 #ifdef DCPOMATIC_VARIANT_SWAROOP
        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 _video_frame_rate;
        /** length of the film we are playing, or 0 if there is none */
        dcpomatic::DCPTime _length;
+
+       int _dropped;
 };
 
 #endif
 };
 
 #endif