return _jump_to_selected;
}
+ /* This could be an enum class but we use the enum a lot to index _nagged
+ * so it means a lot of casts.
+ */
enum Nag {
NAG_DKDM_CONFIG,
NAG_ENCRYPTED_METADATA,
NAG_IMPORT_DECRYPTION_CHAIN,
NAG_DELETE_DKDM,
NAG_32_ON_64,
+ NAG_TOO_MANY_DROPPED_FRAMES,
NAG_COUNT
};
/*
- Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
/** @file src/film_viewer.cc
* @brief A wx widget to view a preview of a Film.
*/
-#include "film_viewer.h"
-#include "playhead_to_timecode_dialog.h"
-#include "playhead_to_frame_dialog.h"
-#include "wx_util.h"
+
#include "closed_captions_dialog.h"
+#include "film_viewer.h"
#include "gl_video_view.h"
+#include "nag_dialog.h"
+#include "playhead_to_frame_dialog.h"
+#include "playhead_to_timecode_dialog.h"
#include "simple_video_view.h"
+#include "wx_util.h"
#include "lib/film.h"
#include "lib/ratio.h"
#include "lib/util.h"
}
_video_view->Sized.connect (boost::bind(&FilmViewer::video_view_sized, this));
+ _video_view->TooManyDropped.connect (boost::bind(&FilmViewer::too_many_frames_dropped, this));
set_film (shared_ptr<Film> ());
emit (boost::bind(boost::ref(ImageChanged), pv));
}
+
+void
+FilmViewer::too_many_frames_dropped ()
+{
+ if (!Config::instance()->nagged(Config::NAG_TOO_MANY_DROPPED_FRAMES)) {
+ stop ();
+ }
+
+ bool shown = NagDialog::maybe_nag (
+ panel(),
+ Config::NAG_TOO_MANY_DROPPED_FRAMES,
+ _("The player is dropping a lot of frames, so playback may not be accurate.\n\n"
+ "<b>This does not necessarily mean that the DCP you are playing is defective!</b>\n\n"
+ "You may be able to improve player performance by:\n"
+ "• choosing 'decode at half resolution' or 'decode at quarter resolution' from the View menu\n"
+ "• using a more powerful computer.\n"
+ )
+ );
+}
void config_changed (Config::Property);
void film_length_change ();
void ui_finished ();
+ void too_many_frames_dropped ();
dcpomatic::DCPTime uncorrected_time () const;
Frame average_latency () const;
return false;
}
- NagDialog* d = new NagDialog (parent, nag, message, can_cancel);
+ auto d = new NagDialog (parent, nag, message, can_cancel);
int const r = d->ShowModal();
d->Destroy ();
#include "lib/butler.h"
#include "lib/dcpomatic_log.h"
#include <boost/optional.hpp>
+#include <sys/time.h>
+
using std::pair;
using std::shared_ptr;
using boost::optional;
+static constexpr int TOO_MANY_DROPPED_FRAMES = 20;
+static constexpr int TOO_MANY_DROPPED_PERIOD = 5.0;
+
+
VideoView::VideoView (FilmViewer* viewer)
: _viewer (viewer)
, _state_timer ("viewer")
boost::mutex::scoped_lock lm (_mutex);
_dropped = 0;
_errored = 0;
+ gettimeofday(&_dropped_check_period_start, nullptr);
}
return true;
}
+
+void
+VideoView::add_dropped ()
+{
+ bool too_many = false;
+
+ {
+ boost::mutex::scoped_lock lm (_mutex);
+ ++_dropped;
+ if (_dropped > TOO_MANY_DROPPED_FRAMES) {
+ struct timeval now;
+ gettimeofday (&now, nullptr);
+ double const elapsed = seconds(now) - seconds(_dropped_check_period_start);
+ too_many = elapsed < TOO_MANY_DROPPED_PERIOD;
+ _dropped = 0;
+ _dropped_check_period_start = now;
+ }
+ }
+
+ if (too_many) {
+ emit (boost::bind(boost::ref(TooManyDropped)));
+ }
+}
#include "lib/dcpomatic_time.h"
+#include "lib/exception_store.h"
+#include "lib/signaller.h"
#include "lib/timer.h"
#include "lib/types.h"
-#include "lib/exception_store.h"
#include <boost/signals2.hpp>
#include <boost/thread.hpp>
class PlayerVideo;
-class VideoView : public ExceptionStore
+class VideoView : public ExceptionStore, public Signaller
{
public:
VideoView (FilmViewer* viewer);
/** Emitted from the GUI thread when our display changes in size */
boost::signals2::signal<void()> Sized;
+ /** Emitted from the GUI thread when a lot of frames are being dropped */
+ boost::signals2::signal<void()> TooManyDropped;
/* Accessors for FilmViewer */
return _player_video;
}
- void add_dropped () {
- boost::mutex::scoped_lock lm (_mutex);
- ++_dropped;
- }
+ void add_dropped ();
void add_get () {
boost::mutex::scoped_lock lm (_mutex);
bool _three_d = false;
int _dropped = 0;
+ struct timeval _dropped_check_period_start;
int _errored = 0;
int _gets = 0;
};