Primitive dropped frame count in display.
authorCarl Hetherington <cth@carlh.net>
Mon, 14 Aug 2017 21:55:05 +0000 (22:55 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 14 Aug 2017 21:55:05 +0000 (22:55 +0100)
src/tools/dcpomatic_player.cc
src/wx/film_viewer.cc
src/wx/film_viewer.h
src/wx/player_information.cc
src/wx/player_information.h

index 567440f8809013343fae99c75ebf0aeef2786be5..5ea341fe97718929bde1c9d880e81b2e037d48e5 100644 (file)
 #include "wx/film_viewer.h"
 #include "wx/player_information.h"
 #include "wx/update_dialog.h"
+#include "wx/config_dialog.h"
 #include <wx/wx.h>
 #include <wx/stdpaths.h>
 #include <wx/splash.h>
 #include <wx/cmdline.h>
+#include <wx/preferences.h>
 #include <boost/bind.hpp>
 #include <iostream>
 
@@ -64,6 +66,9 @@ public:
        DOMFrame ()
                : wxFrame (0, -1, _("DCP-o-matic Player"))
                , _update_news_requested (false)
+               , _info (0)
+               , _config_dialog (0)
+               , _viewer (0)
        {
 
 #if defined(DCPOMATIC_WINDOWS)
@@ -81,6 +86,7 @@ public:
 
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_open, this), ID_file_open);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_exit, this), wxID_EXIT);
+               Bind (wxEVT_MENU, boost::bind (&DOMFrame::edit_preferences, this), wxID_PREFERENCES);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::set_decode_reduction, this, optional<int>()), ID_view_scale_appropriate);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::set_decode_reduction, this, optional<int>(0)), ID_view_scale_full);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::set_decode_reduction, this, optional<int>(1)), ID_view_scale_half);
@@ -136,7 +142,7 @@ public:
                }
 
                _viewer->set_film (_film);
-               _info->update ();
+               _info->triggered_update ();
        }
 
 private:
@@ -216,6 +222,14 @@ private:
                Close ();
        }
 
+       void edit_preferences ()
+       {
+               if (!_config_dialog) {
+                       _config_dialog = create_config_dialog ();
+               }
+               _config_dialog->Show (this);
+       }
+
        void tools_check_for_updates ()
        {
                UpdateChecker::instance()->run ();
@@ -268,6 +282,7 @@ private:
 
        bool _update_news_requested;
        PlayerInformation* _info;
+       wxPreferencesEditor* _config_dialog;
        FilmViewer* _viewer;
        boost::shared_ptr<Film> _film;
 };
index 50e357b5444442b110d9366109ab4e0d7603f149..036646ba5179f78aa62a21c9a39100341c821dc9 100644 (file)
@@ -93,6 +93,7 @@ FilmViewer::FilmViewer (wxWindow* p, bool outline_content, bool jump_to_selected
        , _audio_block_size (1024)
        , _playing (false)
        , _latency_history_count (0)
+       , _dropped (0)
 {
 #ifndef __WXOSX__
        _panel->SetDoubleBuffered (true);
@@ -286,6 +287,7 @@ FilmViewer::get ()
                   part if this frame is J2K).
                */
                _video_position = video.second;
+               ++_dropped;
                return;
        }
 
@@ -473,6 +475,7 @@ FilmViewer::start ()
        }
 
        _playing = true;
+       _dropped = 0;
        timer ();
 }
 
index c08409529569a8ca1c4becc9f5ed919da5f9c948..419ee4c294b1be9db7d8d23e91c98961446cb20c 100644 (file)
@@ -60,6 +60,10 @@ public:
 
        void refresh ();
 
+       int dropped () const {
+               return _dropped;
+       }
+
        int audio_callback (void* out, unsigned int frames);
 
        boost::signals2::signal<void (boost::weak_ptr<PlayerVideo>)> ImageChanged;
@@ -142,5 +146,7 @@ private:
        mutable boost::mutex _latency_history_mutex;
        int _latency_history_count;
 
+       int _dropped;
+
        boost::signals2::scoped_connection _config_changed_connection;
 };
index baeae838cf0baaa53e85cfb7791c6144fbb41ad8..0a2921227c7e819947380117b35e58e30d312a14 100644 (file)
@@ -50,16 +50,27 @@ PlayerInformation::PlayerInformation (wxWindow* parent, FilmViewer* viewer)
        {
                wxSizer* s = new wxBoxSizer (wxVERTICAL);
                add_label_to_sizer(s, this, _("Performance"), false, 0)->SetFont(title_font);
+               _dropped = add_label_to_sizer(s, this, wxT(""), false, 0);
                _sizer->Add (s, 1, wxEXPAND | wxALL, 6);
        }
 
        SetSizerAndFit (_sizer);
 
-       update ();
+       triggered_update ();
+
+       Bind (wxEVT_TIMER, boost::bind (&PlayerInformation::periodic_update, this));
+       _timer.reset (new wxTimer (this));
+       _timer->Start (500);
+}
+
+void
+PlayerInformation::periodic_update ()
+{
+       checked_set (_dropped, wxString::Format(_("Dropped frames: %d"), _viewer->dropped()));
 }
 
 void
-PlayerInformation::update ()
+PlayerInformation::triggered_update ()
 {
        shared_ptr<DCPContent> dcp;
        if (_viewer->film()) {
index af18cfb76dc8646dccae7f559fee48832d585591..7eafeb122cfb25f3f61c3fedce044a4133ab9871 100644 (file)
@@ -19,6 +19,7 @@
 */
 
 #include <wx/wx.h>
+#include <boost/scoped_ptr.hpp>
 
 class FilmViewer;
 
@@ -27,13 +28,17 @@ class PlayerInformation : public wxPanel
 public:
        PlayerInformation (wxWindow* parent, FilmViewer* viewer);
 
-       void update ();
+       void triggered_update ();
 
 private:
 
+       void periodic_update ();
+
        FilmViewer* _viewer;
        wxSizer* _sizer;
        wxStaticText* _cpl_name;
        wxStaticText* _size;
        wxStaticText* _length;
+       wxStaticText* _dropped;
+       boost::scoped_ptr<wxTimer> _timer;
 };