From 0b7c380031db6aa2ce546a2a0c89926f40eae6b5 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 14 Aug 2017 22:55:05 +0100 Subject: [PATCH] Primitive dropped frame count in display. --- src/tools/dcpomatic_player.cc | 17 ++++++++++++++++- src/wx/film_viewer.cc | 3 +++ src/wx/film_viewer.h | 6 ++++++ src/wx/player_information.cc | 15 +++++++++++++-- src/wx/player_information.h | 7 ++++++- 5 files changed, 44 insertions(+), 4 deletions(-) diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc index 567440f88..5ea341fe9 100644 --- a/src/tools/dcpomatic_player.cc +++ b/src/tools/dcpomatic_player.cc @@ -35,10 +35,12 @@ #include "wx/film_viewer.h" #include "wx/player_information.h" #include "wx/update_dialog.h" +#include "wx/config_dialog.h" #include #include #include #include +#include #include #include @@ -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()), ID_view_scale_appropriate); Bind (wxEVT_MENU, boost::bind (&DOMFrame::set_decode_reduction, this, optional(0)), ID_view_scale_full); Bind (wxEVT_MENU, boost::bind (&DOMFrame::set_decode_reduction, this, optional(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; }; diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index 50e357b54..036646ba5 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -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 (); } diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h index c08409529..419ee4c29 100644 --- a/src/wx/film_viewer.h +++ b/src/wx/film_viewer.h @@ -60,6 +60,10 @@ public: void refresh (); + int dropped () const { + return _dropped; + } + int audio_callback (void* out, unsigned int frames); boost::signals2::signal)> 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; }; diff --git a/src/wx/player_information.cc b/src/wx/player_information.cc index baeae838c..0a2921227 100644 --- a/src/wx/player_information.cc +++ b/src/wx/player_information.cc @@ -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 dcp; if (_viewer->film()) { diff --git a/src/wx/player_information.h b/src/wx/player_information.h index af18cfb76..7eafeb122 100644 --- a/src/wx/player_information.h +++ b/src/wx/player_information.h @@ -19,6 +19,7 @@ */ #include +#include 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 _timer; }; -- 2.30.2